How to fake an MDI modal window

This is a bit quick and dirty but should give you the idea!


  PROGRAM

  MAP
ProxyMDIChild   PROCEDURE()
MyFakeModal PROCEDURE()
  END

 INCLUDE('equates.clw'),ONCE 

AppFrame  APPLICATION('Application'),AT(,,505,318),CENTER,MASK,SYSTEM,MAX,ICON('WAFRAME.ICO'),STATUS(-1,80,120,45),FONT('Microsoft Sans Serif',8,, |
          FONT:regular),RESIZE
            MENUBAR,USE(?Menubar)
              MENU('&File'),USE(?FileMenu)
                ITEM('&Print Setup ...'),USE(?PrintSetup),MSG('Setup printer'), |
                STD(STD:PrintSetup)
                ITEM(''),SEPARATOR,USE(?SEPARATOR1)
                ITEM('E&xit'),USE(?Exit),MSG('Exit this application'),STD(STD:Close)
              END
              MENU('&Edit'),USE(?EditMenu)
                ITEM('Cu&t'),USE(?Cut),MSG('Remove item to Windows Clipboard'),STD(STD:Cut)
                ITEM('&Copy'),USE(?Copy),MSG('Copy item to Windows Clipboard'),STD(STD:Copy)
                ITEM('&Paste'),USE(?Paste),MSG('Paste contents of Windows Clipboard'), |
                STD(STD:Paste)
              END
              ITEM('Open Modal'),USE(?MenuOpenModal)
              MENU('&Window'),USE(?WindowMenu),STD(STD:WindowList)
                ITEM('T&ile'),USE(?Tile),MSG('Make all open windows visible'), |
                STD(STD:TileWindow)
                ITEM('&Cascade'),USE(?Cascade),MSG('Stack all open windows'),STD(STD:CascadeWindow) |
            
                ITEM('&Arrange Icons'),USE(?Arrange),MSG('Align all window icons'), |
                STD(STD:ArrangeIcons)
              END
              MENU('&Help'),USE(?HelpMenu)
                ITEM('&Contents'),USE(?Helpindex),MSG('View the contents of the help file'), |
                STD(STD:HelpIndex)
                ITEM('&Search for Help On...'),USE(?HelpSearch),MSG('Search for help on ' & |
                'a subject'),STD(STD:HelpSearch)
                ITEM('&How to Use Help'),USE(?HelpOnHelp),MSG('How to use Windows Help'), |
                STD(STD:HelpOnHelp)
              END
            END
          END

  CODE
  Open(AppFrame)
  ACCEPT
    CASE ACCEPTED()
    OF ?MenuOpenModal
      Start(ProxyMDIChild)
    END
    
  END
  
  
ProxyMDIChild PROCEDURE()
Window          WINDOW('Caption'),AT(,,185,92),MDI,GRAY,SYSTEM,FONT('Microsoft Sans Serif' & |
                '',8,,FONT:regular),RESIZE
                END
  CODE
  Open(Window)
  0{PROP:Hide} = TRUE
  ACCEPT
    CASE Event()
    OF EVENT:OpenWindow
      MyFakeModal()
    END
  END
  
  
MyFakeModal   PROCEDURE()
Window          WINDOW('Caption'),AT(,,199,92),CENTER,GRAY,SYSTEM,FONT('Microsoft Sans S' & |
                'erif',8),DOUBLE
                  PROMPT('HI THERE!'),AT(76,23),USE(?PROMPT1)
                END
  CODE
  Open(Window)
  ACCEPT
  END
1 Like

After @Brahn suggested this technique on Skype
I wrote my own example program of the technique
and then he posted this thread here…
So I figured I’d add my own version here too :wink:

1 Like

Please explain?

What is the purpose of this technique?

I assume we are all on the same page as to what a “modal” means yeah?

A modal dialog is a window that forces the user to interact with it before they can go back to using the parent application.
– usability - What is a Modal Dialog Window? - User Experience Stack Exchange

Clarion has a MODAL attribute that can be applied to windows but as per the help:

MODAL has no effect for 32-bit applications, and has been deprecated in this release. The Microsoft Win32 API does not support system modal windows.

The solutions above are not system modal of course but MDI Application modal. Randy described it as opening a window via an MDI “proxy”.

The effect is that you can open a window that sits on top of your MDI frame and stops all user interaction with that frame until the window is closed. You could do the same by opening a window on the same thread as the MDI frame but then you block that thread. This technique allows the MDI Frame thread to keep running and also provide the effect of application modal.

Oh, and also there was some discussion about making sure that the window is opened centered on the app frame, which it is :slight_smile:

Screenshot just for fun:

1 Like