On Click Open window (like about window)
Posted: Tue Nov 10, 2015 8:22 pm
I have attempted by trail and error to load a window when i click File -> Load
Can not get it to work, the examples are very lacking. Can anyone give some guidance?
Code: Select all
;
; ------------------------------------------------------------
;
; PureBasic - ToolBar example file
;
; (c) Fantaisie Software
;
; ------------------------------------------------------------
;
Procedure CloseWindowEvent()
;Debug "Closing window: " + EventWindow()
CloseWindow(EventWindow()) ; Close the specific window
EndProcedure
Procedure LoadAboutWindows()
OpenWindow(0, 100, 100, 320, 200, "Window 0")
;OpenWindow(1, 500, 100, 320, 200, "Window 1")
;OpenWindow(2, 100, 400, 320, 200, "Window 2")
EndProcedure
Procedure MenuEvents()
Select EventMenu()
Case 1
OpenWindow(0, 100, 100, 320, 200, "Window 0")
Debug "ToolBar or menu item selected: " + EventMenu()
EndSelect
EndProcedure
Procedure Start()
If OpenWindow(0, 0, 0, 0, 0, "Desktop example", #PB_Window_Background)
If CreateToolBar(0, WindowID(0))
ToolBarImageButton(0, ImageID(0))
ToolBarImageButton(1, ImageID(1))
ToolBarImageButton(2, ImageID(2))
ToolBarSeparator()
ToolBarImageButton(3, ImageID(3))
ToolBarToolTip(0, 3, "Cut")
ToolBarImageButton(4, ImageID(4))
ToolBarToolTip(0, 4, "Copy")
ToolBarImageButton(5, ImageID(5))
ToolBarToolTip(0, 5, "Paste")
ToolBarSeparator()
ToolBarImageButton(6, ImageID(6))
ToolBarToolTip(0, 6, "Find a document")
EndIf
If CreateMenu(0, WindowID(0))
MenuTitle("File")
MenuItem( 1, "Load...", ImageID(0))
MenuItem( 2, "Save")
MenuItem( 3, "Save As...")
MenuBar()
OpenSubMenu("Recents", ImageID(0))
MenuItem( 5, "Spider.png")
MenuItem( 6, "Basic.jpg")
OpenSubMenu("Even more !")
MenuItem( 12, "Yeah")
CloseSubMenu()
MenuItem( 13, "Rocks.tga")
CloseSubMenu()
MenuBar()
MenuItem( 7, "Quit")
MenuTitle("Edition")
MenuItem( 8, "Cut")
MenuItem( 9, "Copy")
MenuItem(10, "Paste")
MenuTitle("?")
MenuItem(11, "About")
EndIf
DisableToolBarButton(0, 2, 1) ; Disable the button '2'
BindEvent(#PB_Event_Menu, @MenuEvents())
EndIf
EndProcedure
Procedure Loading(Type, Filename$)
Static NbLoadedElements
Debug Filename$ + " loaded"
NbLoadedElements+1
If NbLoadedElements = 7 ; Finished the loading of all images, we can start the application
Start()
EndIf
EndProcedure
Procedure LoadingError(Type, Filename$)
Debug Filename$ + ": loading error"
EndProcedure
BindEvent(#PB_Event_CloseWindow, @CloseWindowEvent())
; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading, @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())
LoadImage(0, "Data/ToolBar/New.png")
LoadImage(1, "Data/ToolBar/Open.png")
LoadImage(2, "Data/ToolBar/Save.png")
LoadImage(3, "Data/ToolBar/Cut.png")
LoadImage(4, "Data/ToolBar/Copy.png")
LoadImage(5, "Data/ToolBar/Paste.png")
LoadImage(6, "Data/ToolBar/Find.png")