Page 1 of 1

Posted: Mon Jun 17, 2002 10:22 am
by BackupUser
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

Posted: Thu May 20, 2004 6:22 am
by PolyVector
I LOVE YOU!!! :oops:

Even tho' this is an ancient post... It's exactly what I needed :)

Posted: Fri May 21, 2004 1:45 am
by Kale
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
:D

Posted: Sun May 23, 2004 9:14 am
by PolyVector
That one's neeto burito too :)
It could be adapted to create clone-ish windows :)

Posted: Mon May 24, 2004 4:35 am
by DARKGuy
The code seems very useful but, forgive my ignorance...what's a modal window? XD

Posted: Mon May 24, 2004 6:19 am
by PolyVector
It's a window that takes all user input so that no other window recieves input (until the modal window closes)... Like an error dialog

Posted: Mon May 24, 2004 6:27 am
by DARKGuy
ohhh ok, now I understand, thanks PolyVector :)