Restored from previous forum. Originally posted by teachco.
1. Save the WindowID of the main window in a variable, for example MainWinID.
I inserted MainWinID = WindowID() directly after the openWindow-statement.
2. After the openWindow-statement of the modal dialog window I inserted
EnableWindow_(WindowID(),#FALSE)
3. Attention! Don't forget to enable the calling window again, if you close the dialog window. In the event-loop you have to insert
EnableWindow_(WindowID),#TRUE) at every button(-event), which close the dialog window. That's it.
Edited by - teachco on 17 June 2002 11:26:16
Modal Window: A solution with Windows API
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
Another old example:

Code: Select all
Enumeration
#WINDOW_0
#WINDOW_1
#STRING_0
#BUTTON_0
#BUTTON_1
EndEnumeration
Procedure OpenModalWindow()
CallerID = WindowID(#WINDOW_0)
CallerNumber = EventWindowID()
If OpenWindow(#WINDOW_1, 300, 300, 200, 200, #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar, "Modal Window")
EnableWindow_(CallerID, #FALSE)
SetWindowPos_(WindowID(#WINDOW_1), #HWND_TOPMOST, 0, 0, 0, 0, #SWP_NOMOVE | #SWP_NOSIZE)
SetForegroundWindow_(WindowID(#WINDOW_1))
If CreateGadgetList(WindowID(#WINDOW_1))
ButtonGadget(#BUTTON_1, 40, 65, 110, 35, "Close")
EndIf
Repeat
EventID.l = WaitWindowEvent()
Select EventID
Case #PB_EventGadget
Select EventGadgetID()
Case #BUTTON_1
Quit = 1
EndSelect
Case #PB_EventCloseWindow
Quit = 1
EndSelect
Until Quit = 1
CloseWindow(#WINDOW_1)
EndIf
EnableWindow_(CallerID, #TRUE)
SetForegroundWindow_(CallerID)
UseWindow(CallerNumber)
EndProcedure
;Open main window
If OpenWindow(#WINDOW_0, 200, 200, 200, 200, #PB_Window_SystemMenu | #PB_Window_TitleBar , "Parent Window")
If CreateGadgetList(WindowID())
ButtonGadget(#BUTTON_0, 40, 65, 110, 35, "open new window")
EndIf
EndIf
Repeat
EventID.l = WaitWindowEvent()
If EventID = #PB_EventGadget
GadgetID = EventGadgetID()
If GadgetID = #BUTTON_0
OpenModalWindow()
EndIf
EndIf
Until EventID = #PB_EventCloseWindow
End

-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact:
-
- Enthusiast
- Posts: 499
- Joined: Wed Sep 17, 2003 9:17 pm
- Location: Southern California
- Contact: