get showmessage handle

Posted on 2006-04-20
Last Modified: 2010-04-04
    I like to use "showmessage" box to hold my program. I try to  get the "showmessage" box 's handle.How to?Thanks.
Question by:Cheng_sam
    LVL 10

    Accepted Solution

    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;
      liForm: Integer;
      Result := 0;
      for liForm := 0 to Screen.FormCount-1 do
        if SameText(Screen.Forms[liForm].ClassName, 'TMessageForm') then
          Result := Screen.Forms[liForm].Handle;

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

    Regards Jacco

    Author Comment

    thanks Jacco .it works.I use a timer to get the handle.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    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…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now