Solved

Processing to occur right after displaying form

Posted on 1998-04-12
1
128 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
APK file name 7 64
Delphi OLE Error 8 84
indy Tmemory stream non latin charcter issue 2 80
Multiple image collision 13 45
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now