• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 656
  • 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

Featured Post

Independent Software Vendors: 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!

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