Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6938903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:33:05+00:00 2026-05-27T12:33:05+00:00

I am currently writing a windowing system for an existing Delphi application. Currently, the

  • 0

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

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.

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.

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.

EDIT:

Here is what I have so far based of Remy’s advice 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;

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:33:06+00:00Added an answer on May 27, 2026 at 12:33 pm

    ShowModal() explicitally calls Show() just before entering its modal processing loop, and explicitally calls Hide() immediately after exiting the loop. You cannot change that without altering the code in the VCL’s Forms.pas source file.

    If you need finer control over the windows, without editing VCL source code, then don’t use ShowModal() at all. Use Show(), Hide(), DisableTaskWindows(), and EnableTaskWindows() yourself as needed. I would sugest you look at Forms.pas to see how they are used. Copy the implementation of ShowModal() into your own function, then you can customize it as needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing an application ( App1 ) which retrieves portions of text
I'm currently writing an application that accepts a series of Clojure forms and when
I'm currently writing a programme which has a function to hash a number of
I'm currently writing a TYPO3 extension which is configured with a list of tt_content
The application I'm currently writing is using MVVM with the ViewModel-first pattern. I have
I am currently writing a genre classification application as my final year project in
I'm currently writing an application that allows one to store images, and then tag
I'm currently writing a tag cloud system. So I wrote the following sql schema
I'm currently writing a application that needs to capture some images. I start the
I'm currently writing a program to shut down a computer when over a period

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.