Delphi - overriding anti-aliasing behavior TForm.showModal

I am currently writing a window system for an existing Delphi application.

Currently, the program consists of several full-sized forms, which are shown modally in the order in which they are required, and none of them can be moved by the user. My goal is to provide the ability to move all of these forms. Previously, the shapes were stacked on top of each other, but since none of them could be moved, the background shapes were not visible to the user. My solution so far has been to hide the parent form when opening a new child and repurpose it when this child is closed.

Unfortunately, since each child element is called with showModal, a call that makes the parent form visible does not occur until the modal process is complete and, therefore, after the child form has been hidden, so that the user sees a broken second flash drive where there is no form.

Is there a way to prevent the automatic hiding of modal forms after the completion of their process? This will allow me to manually hide them as soon as the parent form is visible again. I tried to schedule this in the FormHide event for each child form, but this does not work, since the child form is also hidden when opening one of its own children.

EDIT:

Here is what I have so far based on Remy's recommendations below

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 <> 0 then closeModal(child as TCustomForm);
      until ModalResult <> 0;
      Result := ModalResult;
      SendMessage(Handle, CM_DEACTIVATE, 0, 0);
      if GetActiveWindow <> Handle then ActiveWindow := 0;
    finally
      parent.Show;
      Hide;
    end;
  finally
    EnableTaskWindows(WindowList);
    parent.Show; //reshow the parent form
    if ActiveWindow <> 0 then SetActiveWindow(ActiveWindow);
  end;
  finally
    Application.ModalFinished;
  end;
  end;
end;

, , , , , . ?

+5
1

ShowModal() Show() Hide() . , VCL Forms.pas.

, VCL, ShowModal() . Show(), Hide(), DisableTaskWindows() EnableTaskWindows() . , Forms.pas, , . ShowModal() , .

+10

All Articles