Code: Alles auswählen
;-TOP
Enumeration Windows
#Main
#Dialog
EndEnumeration
Enumeration MenuBar
#MainMenu
EndEnumeration
Enumeration MenuItems
EndEnumeration
Enumeration Gadgets
#MainEdit
#MainButtonOk
#MainButtonCancel
#MainButtonDialog
#DialogList
EndEnumeration
Enumeration StatusBar
#MainStatusBar
EndEnumeration
Procedure UpdateWindow()
Protected dx, dy
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar)
; Resize gadgets
ResizeGadget(#MainEdit, 5, 5, dx -10, dy - 45)
ResizeGadget(#MainButtonok, 10, dy - 35, 120, 30)
ResizeGadget(#MainButtonCancel, dx - 130, dy - 35, 120, 30)
ResizeGadget(#MainButtonDialog, dx / 2 - 60, dy - 35, 120, 30)
EndProcedure
Procedure DialogWin(parent)
If OpenWindow(#Dialog, #PB_Ignore, #PB_Ignore, 600, 400, "Dialog", #PB_Window_SystemMenu, WindowID(parent))
ListViewGadget(#DialogList, 5, 5, 590, 390)
;
EndIf
EndProcedure
Procedure Main()
Protected dx, dy
#MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, "Window" , #MainStyle)
; Menu
CreateMenu(#MainMenu, WindowID(#Main))
; StatusBar
CreateStatusBar(#MainStatusBar, WindowID(#Main))
AddStatusBarField(#PB_Ignore)
; Gadgets
dx = WindowWidth(#Main)
dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar)
EditorGadget(#MainEdit, 5, 5, dx -10, dy - 45)
ButtonGadget(#MainButtonok, 10, dy - 35, 120, 30, "Ok")
ButtonGadget(#MainButtonCancel, dx - 130, dy - 35, 120, 30, "Abbruch")
ButtonGadget(#MainButtonDialog, dx / 2 - 60, dy - 35, 120, 30, "Dialog")
; Bind Events
BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
;-- Main event loop
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Select EventWindow()
Case #Main
Break
Case #Dialog
; TODO before close window
;
CloseWindow(#Dialog)
EndSelect
Case #PB_Event_Menu
Select EventMenu()
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
Case #PB_Menu_About
Case #PB_Menu_Preferences
Case #PB_Menu_Quit
PostEvent(#PB_Event_CloseWindow, #Main, #Null)
CompilerEndIf
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
Case #MainEdit
Select EventType()
Case #PB_EventType_Change
;
EndSelect
Case #MainButtonOk
Select EventType()
Case #PB_EventType_LeftClick
;
EndSelect
Case #MainButtonCancel
Select EventType()
Case #PB_EventType_LeftClick
;
EndSelect
Case #MainButtonDialog
Select EventType()
Case #PB_EventType_LeftClick
If Not IsWindow(#Dialog)
DialogWin(#main)
EndIf
EndSelect
EndSelect
EndSelect
ForEver
EndIf
EndProcedure : Main()
; TODO before close programm
;
End