Note that there are some explanatory texts on larger screens.

plurals
  1. PODelphi - overriding hide behaviour of TForm.showModal
    primarykey
    data
    text
    <p>I am currently writing a windowing system for an existing Delphi application.</p> <p>Currently, the program consists of a number of full-sized forms which are shown modally in the order they are required and none of which can be moved by the user. My aim is to allow all of these forms to be moveable. Previously forms were stacked on top of each other but since none could be moved the background forms were not visible to the user. My solution so far has been to hide the 'parent' form when opening a new child, and reshowing it when that child is closed.</p> <p>Unfortunately since each child is called with showModal, the call the make the parent form visible does not come until after the modal process has completed and hence after the child form has been hidden so the user sees a split second flash where no form is visible.</p> <p>Is there a way I can prevent the modal forms from being hidden automatically after their process has completed? This would allow me to manually hide them once the parent form is visible again. I have tried to schedule this in the FormHide event of each child form but this does not work as a child form is also hidden when opening one of its own children.</p> <p>EDIT:</p> <p>Here is what I have so far based of Remy's advice below</p> <pre><code>procedure openModalChild(child: TForm; parent: TForm); var WindowList: Pointer; SaveFocusCount: Integer; SaveCursor: TCursor; SaveCount: Integer; ActiveWindow: HWnd; Result: integer; begin CancelDrag; with child do begin Application.ModalStarted; try ActiveWindow := GetActiveWindow; WindowList := DisableTaskWindows(0); //set the window to fullscreen if required setScreenMode(child); try Show; //show the child form try SendMessage(Handle, CM_ACTIVATE, 0, 0); ModalResult := 0; repeat Application.HandleMessage; //if Forms.Application.FTerminate then ModalResult := mrCancel else if ModalResult &lt;&gt; 0 then closeModal(child as TCustomForm); until ModalResult &lt;&gt; 0; Result := ModalResult; SendMessage(Handle, CM_DEACTIVATE, 0, 0); if GetActiveWindow &lt;&gt; Handle then ActiveWindow := 0; finally parent.Show; Hide; end; finally EnableTaskWindows(WindowList); parent.Show; //reshow the parent form if ActiveWindow &lt;&gt; 0 then SetActiveWindow(ActiveWindow); end; finally Application.ModalFinished; end; end; end; </code></pre> <p>This works well but the only problem is the active repeat loop never breaks, even after the child has been escaped and so the parent form is never reshown. Is there any way I can resolve this?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload