Loading ...
Sorry, an error occurred while loading the content.
 

Getting the text from a MessageBox

Expand Messages
  • erngui
    Hi, somebody recently asked me: I would like to know if there is any way to retrieve the text from a msgbox call. I need to trap an error an application
    Message 1 of 1 , Feb 21, 2002
      Hi,

      somebody recently asked me:

      "I would like to know if there is any way to retrieve the text from a
      msgbox call. I need to trap an error an application creates on a
      failed operation. I can get the message box title, but not the actual
      message...."

      My answer was:

      From what I can see, a message box just creates a plain dialog box
      with some buttons. The text is in a static control in the middle of
      the dialog box. This means you can use FindWindowLike and then
      GetWindowText. Knowing the parent window will help you.

      You can use spy--.pl in the eg directory of the distribution to
      investigate further.

      I just created a message box with:

      MessageBox(NULL, "MyText", "MyCaption", MB_OK);

      And running spy--.pl returns (among a lot of other stuff):

      +0x0004050E, 'MyCaption', #32770
      ++0x00040522, 'OK', Button
      ++0x000504DE, 'MyText', Static

      I'm posting this in case somebody finds it useful.

      Ernesto.
      --
      Ernesto Guisado
      mailto:erngui@...
      http://triumvir.org
    Your message has been successfully submitted and would be delivered to recipients shortly.