Being new to programming, I need soem help please.
I want to write a small data input program that has data menu on the first screen, but I need to include a top bar menu with a preference options.
Enumeration
#WINDOW_MAIN
#MENU_MAIN
#MENU_QUIT
#MENU_ABOUT
#TEXT_INPUT
#STRING_INPUT
#LIST_INPUT
#BUTTON_INTERACT
#BUTTON_CLOSE
EndEnumeration
Global Quit.b = #False
#FLAGS = #PB_Window_SystemMenu | #PB_Window_ScreenCentered
If OpenWindow(#WINDOW_MAIN, 0, 0, 300, 222, "Interaction", #FLAGS)
If CreateMenu(#MENU_MAIN, WindowID(#WINDOW_MAIN))
MenuTitle("File")
MenuItem(#MENU_QUIT, "Quit")
MenuTitle("Help")
MenuItem(#MENU_ABOUT, "About...")
If CreateGadgetList(WindowID(#WINDOW_MAIN))
TextGadget(#TEXT_INPUT, 10, 10, 280, 20, "Enter text here:")
StringGadget(#STRING_INPUT, 10, 30, 280, 20, "")
ListViewGadget(#LIST_INPUT, 10, 60, 280, 100)
ButtonGadget(#BUTTON_INTERACT, 10, 170, 120, 20, "Enter text")
ButtonGadget(#BUTTON_CLOSE, 190, 170, 100, 20, "Close window")
SetActiveGadget(#STRING_INPUT)
Repeat
Event.l = WaitWindowEvent()
Select Event
Case #PB_Event_Menu
Select EventMenu()
Case #MENU_QUIT
Quit = #True
Case #MENU_ABOUT
MessageRequester("About", "This is your program description.")
EndSelect
I copied this from the book.
I was able to put in the preference menu, but try as I might I can not get it to open a new window, and have a button on the bottom that allows you to come out of that window when you have finsihed with the preferences option.
Any ideas pse
Menu
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
This show you how to manage the event handling of two windows:
PS: Please use code tags!
Code: Select all
OpenWindow(0,0,0,400,300,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ButtonGadget(0,5,5,120,23,"Open Dialog")
Repeat
EventID = WaitWindowEvent()
Select EventID
Case #PB_Event_Gadget
Select EventGadget()
Case 0
DisableWindow(0,1)
OpenWindow(1,0,0,320,200,"Preferences",#PB_Window_SystemMenu | #PB_Window_ScreenCentered,WindowID(0))
CreateGadgetList(WindowID(1))
ButtonGadget(1,5,5,120,23,"Close Dialog")
Case 1
DisableWindow(0,0)
CloseWindow(1)
EndSelect
Case #PB_Event_CloseWindow
Select EventWindow()
Case 0
Quit = 1
Case 1
DisableWindow(0,0)
CloseWindow(1)
EndSelect
EndSelect
Until Quit = 1
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
BEcause I am new to PB can I just confirm I am understanding the code above.
You are basically saying:
Select EventGadget() : If xxx gadget is selected.
Case 0 : If on Window 0
Case 1 : If On Window 1
etc
Is that right? I could not follow this Case and Select commands as they are a strange way of working to me. Just want to make sure I have the right gist of the premise.
Thanks
Arcee
You are basically saying:
Select EventGadget() : If xxx gadget is selected.
Case 0 : If on Window 0
Case 1 : If On Window 1
etc
Is that right? I could not follow this Case and Select commands as they are a strange way of working to me. Just want to make sure I have the right gist of the premise.
Thanks
Arcee
- Kaeru Gaman
- Addict
- Posts: 4826
- Joined: Sun Mar 19, 2006 1:57 pm
- Location: Germany
nope
etc...
this is similar to:
http://www.purebasic.fr/english/viewtop ... 031#175031
Code: Select all
Select EventWindow()
Case #Win_Main
; Main Window
Case #Win_Sub1
; First Subwindow
Case #Win_Sub2
; second Subwindow
this is similar to:
Code: Select all
WindowThatHasEvent = EventWindow()
If WindowThatHasEvent = #Win_Main
; Main Window
EndIf
If WindowThatHasEvent = #Win_Sub1
; First Subwindow
EndIf
If WindowThatHasEvent = #Win_Sub2
; second Subwindow
EndIf
oh... and have a nice day.
-
- User
- Posts: 27
- Joined: Sun Jul 13, 2008 9:47 am
- Location: UK
Thanks
Thanks very much for those who helped me here.
I have finsihed the programs, which seem to working well.
Thanks again
Danny
I have finsihed the programs, which seem to working well.
Thanks again
Danny
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )