Dialog boxes in PureBasic
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Joseph.
Hello all
I've started reading the PureBAsic documentation and testing the samples
Now, while everything is OK with Purebasic windows (ie: OpenWindow stuff etc.) i couldn't find any example showing a dialog box (especially a modal one). You know, sometimes its nice using a dialog box, not a window
Has anybody some sample/trick about the above (even made by calling some API funcs)?
any tip/info will be greatly appreciated
thanks in advance
best regards
Joseph
Hello all
I've started reading the PureBAsic documentation and testing the samples
Now, while everything is OK with Purebasic windows (ie: OpenWindow stuff etc.) i couldn't find any example showing a dialog box (especially a modal one). You know, sometimes its nice using a dialog box, not a window
Has anybody some sample/trick about the above (even made by calling some API funcs)?
any tip/info will be greatly appreciated
thanks in advance
best regards
Joseph
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Joseph.
André, thank you for your quick reply
What I actually meant was not, say, standard 'common dialogs' (like font requester, color requester or message requester etc.) but 'general purpose' dialog boxes, especially modal dialog boxes, fully configurable by programmer, i mean somtehing just like the current purebasic 'windows' (where you add gadgets and other elements etc.) but acting in 'typical' modal (or, possibily, also non modal) way'.
I know that Windows manages differently windows and dialog boxes.
For example in my program I usually need an 'Options' dialog box and i need the user can't access the other windows until he/she has filled the form fields and so on. Yes, of course I can get a 'similar' result using a window in place (setting up i suppose a TOP_MOST flag or something like that), but i'd like to have the chance to use a real dialog box when needed
Is there some sample about that?
thanks again
best regards
Joseph
(PureBasic Registered User)
André, thank you for your quick reply
What I actually meant was not, say, standard 'common dialogs' (like font requester, color requester or message requester etc.) but 'general purpose' dialog boxes, especially modal dialog boxes, fully configurable by programmer, i mean somtehing just like the current purebasic 'windows' (where you add gadgets and other elements etc.) but acting in 'typical' modal (or, possibily, also non modal) way'.
I know that Windows manages differently windows and dialog boxes.
For example in my program I usually need an 'Options' dialog box and i need the user can't access the other windows until he/she has filled the form fields and so on. Yes, of course I can get a 'similar' result using a window in place (setting up i suppose a TOP_MOST flag or something like that), but i'd like to have the chance to use a real dialog box when needed
Is there some sample about that?
thanks again
best regards
Joseph
(PureBasic Registered User)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by blueb.
Joseph,
You might take a look in the Win32 Programmer's reference...
Dialogs can be used easily with PB.
The topics below will interest you:
Following are the functions used to create and manage dialog boxes and controls within dialog boxes.
CreateDialog
CreateDialogIndirect
CreateDialogIndirectParam
CreateDialogParam
DefDlgProc
DialogBox
DialogBoxIndirect
DialogBoxIndirectParam
DialogBoxParam
DialogProc
EndDialog
GetDialogBaseUnits
GetDlgCtrlID
GetDlgItem
GetDlgItemInt
GetDlgItemText
GetNextDlgGroupItem
GetNextDlgTabItem
IsDialogMessage
MapDialogRect
MessageBox
MessageBoxEx
SendDlgItemMessage
SetDlgItemInt
SetDlgItemText
MessageBoxIndirect
Regards,
--blueb
Joseph,
You might take a look in the Win32 Programmer's reference...
Dialogs can be used easily with PB.
The topics below will interest you:
Following are the functions used to create and manage dialog boxes and controls within dialog boxes.
CreateDialog
CreateDialogIndirect
CreateDialogIndirectParam
CreateDialogParam
DefDlgProc
DialogBox
DialogBoxIndirect
DialogBoxIndirectParam
DialogBoxParam
DialogProc
EndDialog
GetDialogBaseUnits
GetDlgCtrlID
GetDlgItem
GetDlgItemInt
GetDlgItemText
GetNextDlgGroupItem
GetNextDlgTabItem
IsDialogMessage
MapDialogRect
MessageBox
MessageBoxEx
SendDlgItemMessage
SetDlgItemInt
SetDlgItemText
MessageBoxIndirect
Regards,
--blueb
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by fweil.
Hi Justin,
Maybe you can start with this snippet. It allows to have a simple "input requester" build with a window where you can put all the gadgets you want. This skeleton should be easy to enhance.
;==========================================================
;
; InputRequesterS is a Requester function displaying a string box
; and returning the entered string.
;
; A title and a default value are passed, and return key or OK button
; allow to return from procedure.
;
; If Escape key is pushed or the requester is closed without return or OK
; validation , the returned value is the default.
;
Procedure.s InputRequesterS(lTitle.s, lDefault.s)
;
; Constants are set for possible integration
;
#InputRequesterSWID = 99
#InputRequesterSGID = 198
lXSize.l = 200
lYSize.l = 25
;
; GetSystemMetrics_ API function gives access to screen dimensions
;
If OpenWindow(#InputRequesterSWID, (GetSystemMetrics_(#SM_CXSCREEN) - lXSize) / 2, (GetSystemMetrics_(#SM_CYSCREEN) - lYSize) / 2, lXSize + 40, lYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, lTitle)
AddKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_Return, 10)
AddKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_Escape, 99)
If CreateGadgetList(WindowID())
StringGadget(#InputRequesterSGID, 2, 2, lXSize - 4, lYSize - 5, lDefault)
ButtonGadget(#InputRequesterSGID + 1, lXSize + 5, lYSize - 25, 30, 20, "OK")
EndIf
lResult.s = GetGadgetText(#InputRequesterSGID)
lQuit.l = #FALSE
Repeat
Select WaitWindowEvent()
Case #PB_EventCloseWindow
lQuit = #TRUE
Case #PB_EventMenu
Select EventMenuID()
Case 10
lResult = GetGadgetText(#InputRequesterSGID)
lQuit = #TRUE
Case 99
lQuit = #TRUE
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
Case (#InputRequesterSGID + 1)
lResult = GetGadgetText(#InputRequesterSGID)
lQuit = #TRUE
EndSelect
EndSelect
Until lQuit
RemoveKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_All)
CloseWindow(#InputRequesterSWID)
EndIf
ProcedureReturn lResult
EndProcedure
;
; InputRequesterSML is a multilined string input requester.
; It is like InputRequesterS but does not return when using the return key
; and allows mulitple lines handling.
;
; Also this requester gives the possibility of resizing to meet user's needs
;
Procedure.s InputRequesterSML(lTitle.s, lDefault.s)
#InputRequesterSWID = 99
#InputRequesterSGID = 198
lXSize.l = 200
lYSize.l = 80
If OpenWindow(#InputRequesterSWID, (GetSystemMetrics_(#SM_CXSCREEN) - lXSize) / 2, (GetSystemMetrics_(#SM_CYSCREEN) - lYSize) / 2, lXSize + 40, lYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, lTitle)
AddKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_Escape, 99)
If CreateGadgetList(WindowID())
StringGadget(#InputRequesterSGID, 2, 2, lXSize - 4, lYSize - 5, lDefault, #PB_String_Multiline | #ES_AUTOVSCROLL | #WS_VSCROLL | #WS_HSCROLL)
ButtonGadget(#InputRequesterSGID + 1, lXSize + 5, lYSize - 25, 30, 20, "OK")
EndIf
lResult.s = GetGadgetText(#InputRequesterSGID)
lQuit.l = #FALSE
Repeat
Select WaitWindowEvent()
Case #PB_EventCloseWindow
lQuit = #TRUE
Case #PB_EventMenu
Select EventMenuID()
Case 99
lQuit = #TRUE
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
Case (#InputRequesterSGID + 1)
lResult = GetGadgetText(#InputRequesterSGID)
lQuit = #TRUE
EndSelect
EndSelect
If WindowWidth() lXSize + 40 Or WindowHeight() lYSize
lXSize = WindowWidth() - 40
lYSize = WindowHeight()
ResizeGadget(#InputRequesterSGID, 2, 2, lXSize - 4, lYSize - 5)
ResizeGadget(#InputRequesterSGID + 1, lXSize + 5, lYSize - 25, 30, 20)
EndIf
Until lQuit
RemoveKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_All)
CloseWindow(#InputRequesterSWID)
EndIf
ProcedureReturn lResult
EndProcedure
;
; Main test code
;
sString.s
; sString = InputRequesterS("Enter a text", "Default")
; Debug sString
sString = InputRequesterSML("Enter a text", "Default")
Debug sString
End
;==========================================================
Francois Weil
14, rue Douer
F64100 Bayonne
Hi Justin,
Maybe you can start with this snippet. It allows to have a simple "input requester" build with a window where you can put all the gadgets you want. This skeleton should be easy to enhance.
;==========================================================
;
; InputRequesterS is a Requester function displaying a string box
; and returning the entered string.
;
; A title and a default value are passed, and return key or OK button
; allow to return from procedure.
;
; If Escape key is pushed or the requester is closed without return or OK
; validation , the returned value is the default.
;
Procedure.s InputRequesterS(lTitle.s, lDefault.s)
;
; Constants are set for possible integration
;
#InputRequesterSWID = 99
#InputRequesterSGID = 198
lXSize.l = 200
lYSize.l = 25
;
; GetSystemMetrics_ API function gives access to screen dimensions
;
If OpenWindow(#InputRequesterSWID, (GetSystemMetrics_(#SM_CXSCREEN) - lXSize) / 2, (GetSystemMetrics_(#SM_CYSCREEN) - lYSize) / 2, lXSize + 40, lYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, lTitle)
AddKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_Return, 10)
AddKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_Escape, 99)
If CreateGadgetList(WindowID())
StringGadget(#InputRequesterSGID, 2, 2, lXSize - 4, lYSize - 5, lDefault)
ButtonGadget(#InputRequesterSGID + 1, lXSize + 5, lYSize - 25, 30, 20, "OK")
EndIf
lResult.s = GetGadgetText(#InputRequesterSGID)
lQuit.l = #FALSE
Repeat
Select WaitWindowEvent()
Case #PB_EventCloseWindow
lQuit = #TRUE
Case #PB_EventMenu
Select EventMenuID()
Case 10
lResult = GetGadgetText(#InputRequesterSGID)
lQuit = #TRUE
Case 99
lQuit = #TRUE
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
Case (#InputRequesterSGID + 1)
lResult = GetGadgetText(#InputRequesterSGID)
lQuit = #TRUE
EndSelect
EndSelect
Until lQuit
RemoveKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_All)
CloseWindow(#InputRequesterSWID)
EndIf
ProcedureReturn lResult
EndProcedure
;
; InputRequesterSML is a multilined string input requester.
; It is like InputRequesterS but does not return when using the return key
; and allows mulitple lines handling.
;
; Also this requester gives the possibility of resizing to meet user's needs
;
Procedure.s InputRequesterSML(lTitle.s, lDefault.s)
#InputRequesterSWID = 99
#InputRequesterSGID = 198
lXSize.l = 200
lYSize.l = 80
If OpenWindow(#InputRequesterSWID, (GetSystemMetrics_(#SM_CXSCREEN) - lXSize) / 2, (GetSystemMetrics_(#SM_CYSCREEN) - lYSize) / 2, lXSize + 40, lYSize, #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget, lTitle)
AddKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_Escape, 99)
If CreateGadgetList(WindowID())
StringGadget(#InputRequesterSGID, 2, 2, lXSize - 4, lYSize - 5, lDefault, #PB_String_Multiline | #ES_AUTOVSCROLL | #WS_VSCROLL | #WS_HSCROLL)
ButtonGadget(#InputRequesterSGID + 1, lXSize + 5, lYSize - 25, 30, 20, "OK")
EndIf
lResult.s = GetGadgetText(#InputRequesterSGID)
lQuit.l = #FALSE
Repeat
Select WaitWindowEvent()
Case #PB_EventCloseWindow
lQuit = #TRUE
Case #PB_EventMenu
Select EventMenuID()
Case 99
lQuit = #TRUE
EndSelect
Case #PB_EventGadget
Select EventGadgetID()
Case (#InputRequesterSGID + 1)
lResult = GetGadgetText(#InputRequesterSGID)
lQuit = #TRUE
EndSelect
EndSelect
If WindowWidth() lXSize + 40 Or WindowHeight() lYSize
lXSize = WindowWidth() - 40
lYSize = WindowHeight()
ResizeGadget(#InputRequesterSGID, 2, 2, lXSize - 4, lYSize - 5)
ResizeGadget(#InputRequesterSGID + 1, lXSize + 5, lYSize - 25, 30, 20)
EndIf
Until lQuit
RemoveKeyboardShortcut(#InputRequesterSWID, #PB_Shortcut_All)
CloseWindow(#InputRequesterSWID)
EndIf
ProcedureReturn lResult
EndProcedure
;
; Main test code
;
sString.s
; sString = InputRequesterS("Enter a text", "Default")
; Debug sString
sString = InputRequesterSML("Enter a text", "Default")
Debug sString
End
;==========================================================
Francois Weil
14, rue Douer
F64100 Bayonne
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Joseph.
hello thank you for your replies
as far as the 'API way' is concerned, it seems to me not much confortable to create and manage dialog boxes and controls within dialog boxes... basically what i need is a PureBasic commands set just similar to the current one for windows (ie OpenWindow(...) etc.), but dedicated to dialog boxes.
hope the author will add that in the future
thanks again
best regards
Joseph
(PureBasic Registered User)
hello thank you for your replies
as far as the 'API way' is concerned, it seems to me not much confortable to create and manage dialog boxes and controls within dialog boxes... basically what i need is a PureBasic commands set just similar to the current one for windows (ie OpenWindow(...) etc.), but dedicated to dialog boxes.
hope the author will add that in the future
thanks again
best regards
Joseph
(PureBasic Registered User)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by El_Choni.
Hi,
The PopUpWindow lib allows using windows which don't get 'backgrounded' when clicked, but ATM they allow input in other windows, as PB windows do. After reading some posts here, and in the 'Callbacks' issue topic, I'm considering adding a flag to make windows exclusive -that is, like a MessageRequester, not allowing input in ather app's windows-.
But maybe I don't get the point. Correct me if I'm wrong before messing with the code, plz.
Have a nice day,
El_Choni
Hi,
The PopUpWindow lib allows using windows which don't get 'backgrounded' when clicked, but ATM they allow input in other windows, as PB windows do. After reading some posts here, and in the 'Callbacks' issue topic, I'm considering adding a flag to make windows exclusive -that is, like a MessageRequester, not allowing input in ather app's windows-.
But maybe I don't get the point. Correct me if I'm wrong before messing with the code, plz.
Have a nice day,
El_Choni
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Danilo.
Dialog Boxes in PureBasic
Compile it and look at the FileSize... h3h3h3h3 
cya,
...Danilo
(registered PureBasic user)
Dialog Boxes in PureBasic
Code: Select all
Procedure Dialog1proc(hWnd,Msg,wParam,lParam) Select Msg
Case #WM_CLOSE
EndDialog_(hWnd,1)
Case #WM_COMMAND
If wParam = 1: beep_(800,100): EndIf
EndSelect
ProcedureReturn 0
EndProcedure
hDialog1 = DialogBoxIndirectParam_(0,?Dialog1,0,@Dialog1proc(),0)
End
Dialog1:
!ALIGN 4
!db 0, 8, 200, 16, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 200, 0
!db 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0
!db 10, 0, 10, 0, 50, 0, 20, 0, 1, 0, 255, 255, 128, 0, 68, 0
!db 97, 0, 110, 0, 105, 0, 108, 0, 111, 0, 0, 0, 0, 0cya,
...Danilo
(registered PureBasic user)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm