• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 685
  • Last Modified:

get showmessage handle

Experts:
    I like to use "showmessage" box to hold my program. I try to  get the "showmessage" box 's handle.How to?Thanks.
   
0
Cheng_sam
Asked:
Cheng_sam
1 Solution
 
JaccoCommented:
But when the Box is showing how will you execute code? Are you using an extra thread?

The MessageBox shown when ShowMessage is executed, is a normal Delphi form which is in the Screen.Forms list when the box is showing.

The class of the form is TMessageForm so to find it use

function GetMessageBoxHandle: THandle;
var
  liForm: Integer;
begin
  Result := 0;
  for liForm := 0 to Screen.FormCount-1 do
    if SameText(Screen.Forms[liForm].ClassName, 'TMessageForm') then
    begin
      Result := Screen.Forms[liForm].Handle;
      Exit;
    end;
end;

This will only work fro within the same application in a separate thread though.

Regards Jacco
0
 
Cheng_samAuthor Commented:
thanks Jacco .it works.I use a timer to get the handle.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now