Solved

Processing to occur right after displaying form

Posted on 1998-04-12
1
134 Views
Last Modified: 2010-04-06
I often find myself in the situation where I wish to do some processing immediately after displaying a form.  

Steps I wish to follow:

  1 - Modal Form is called by main application
  2 - Modal form is fully displayed and visible by user
  3 - Processing occurs here...

The TForm event OnShow won't show my form before the processing is done.  

Thank you.
0
Comment
Question by:ymailhot
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 3

Accepted Solution

by:
KE earned 100 total points
ID: 1361472
You can actually not process any code after a call to the showmodal method. Showmodal will halt the current thread until the ModalResult is<>0.
You can only process code before setting the form in a modal state. If the code is concerning the form, you may want to make a special method in your form object - which initializes your form and call's the showModal method.
Ex:

MyForm = class(TForm)
bla, bla,
Public
  // This line is inserted in to your existing form declaration
  Function MyNewSpecialMethod( MyParams ) : TModalResult;
End;

Function MyForm.MyNewSpecialMethod : TModalResult;
begin
  <Initialize here>
  Result := ShowModal;
  Case result of
    bla, bla,
  end;
end;

Function MyForm.AnotherNewSpecialMethod : TModalResult;
begin
  <Initialize here>
  Repeat
     // Make the Controls work
     Application.ProcessMessages;

    <Do something here>

    // Let the thread sleep a little so you dont spend all the CPU time in this loop;
    Sleep( 100 );
  Until ModalResult<>0;
  Result := ModalResult;
end;

If it's necessary to do processing after a showModal try to use the events of your controls on the form, or if necessary use a TTimer to trigger an event.
Another way is to create a new thread, but i don't think it's what your'e looking for.


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question