Proper modal dialog boxes in PB
Posted: Sun May 04, 2003 8:42 pm
Code updated For 5.20+
Well I hope someone finds this usefull, I figured out you don't need resources to use proper modal dialog boxes.
If something similar has been posted before I apologise in advance.
Well I hope someone finds this usefull, I figured out you don't need resources to use proper modal dialog boxes.
If something similar has been posted before I apologise in advance.
Code: Select all
; Proper Dialogs in Purebasic
; Hacked together by Spangly
Structure DLG_TEMPLATE
style.l
dwExtendedStyle.l
cdit.w
x.w
y.w
cx.w
cy.w
menu.w
class.w
title.l
EndStructure
dlg.DLG_TEMPLATE
dlg\style=#WS_POPUP | #WS_BORDER | #WS_SYSMENU | #DS_MODALFRAME | #WS_CAPTION | #DS_CENTER
dlg\cx=200
dlg\cy=100
Procedure DlgProc(hWnd, uMsg, wParam, lParam)
Select uMsg
Case #WM_INITDIALOG
ButtonGadget(0,20,20,100,22,"OK")
ButtonGadget(1,20,50,100,22,"Cancel")
ButtonGadget(2,20,80,100,22,"Quit")
SetWindowText_(hWnd,"Dialog Title")
Case #WM_COMMAND
EndDialog_(hWnd,wParam&$FFFF)
EndSelect
ProcedureReturn 0
EndProcedure
OpenWindow(0, 325, 185, 600, 330, "Proper Dialogs", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget | #PB_Window_TitleBar )
Debug DialogBoxIndirectParam_(0,dlg,WindowID(0),@DlgProc(),0)
Repeat
event.l=WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Debug EventGadget()
EndSelect
Until event=#PB_Event_CloseWindow
End
; ExecutableFormat=Windows
; EnableAsm
; EnableXP
; EOF