?
Solved

Close Form in OnShow

Posted on 1999-11-08
6
Medium Priority
?
1,078 Views
Last Modified: 2008-03-10
I have a dll that does certain modem communication processes and thus displays updates via modal forms.

The process is started in the OnShow of a modal form and can terminate depending on certain conditions after which I display a status (on the modal form) and then it terminates after a short time. (same as a normal modem connection dialog box does with for example closing connection... etc.)

??What can I do to close the modal form in the OnShow event, or workaround except posting a message to myself to start the process.
0
Comment
Question by:karoo
  • 3
  • 2
6 Comments
 
LVL 7

Accepted Solution

by:
RBertora earned 300 total points
ID: 2191443
Have you tried:

sendmessage(Form.Handle,'WM_CLOSE',0,0);
or
sendmessage(Form.Handle,'WM_DESTROY',0,0);

Rob ;-)
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2191460
Do something like

  ModalResult := mrOk;

or

  ModalResult := mrCancel;
0
 
LVL 4

Author Comment

by:karoo
ID: 2191607
Rob,
I tried Sendmessage(Self.Handle, WM_CLOSE, 0, 0) in a small app in the OnShow event, it doesn't work.
Did not try WM_DESTROY because that will mess with the inherited close from my base form which needs to be executed in the OnClose, anyway it is my callers job to free the form and.

Epsylon,
Tried it(didn't work), I think that setting the modalresult is esentially the same as close for a modal form and that the Close method is called in the forms vcl unit.

0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
LVL 4

Author Comment

by:karoo
ID: 2191628
aaaah:)

Rob,
this works:
Sendmessage(Application.Handle, WM_CLOSE, 0, 0);

obviously i have to pass the Applications handle and not the Modal forms handle

Thanks for the help just post an answer and i will award the points.

Ben.:)
0
 
LVL 4

Author Comment

by:karoo
ID: 2191632
do'h,

accepted the comment as the answer:)
0
 
LVL 7

Expert Comment

by:RBertora
ID: 2191652
Glad it helped
Rob :-)
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…

601 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