Solved

Detecting A Pop-Up Error Message

Posted on 2003-11-23
4
372 Views
Last Modified: 2013-11-28
I don't think what I want to do is possible, but I'll ask anyway.

If your Delphi program ShellExecutes another exe file and the ShellExecuted file generates a messagebox with an error in it, (something it only does if there is an error), is there any way *your* program can detect this happening and access the message text in the messagebox.

The messagebox window that appears has the title 'Error', a short text message and a single OK button on it.

Thanks...

TDK_Man
0
Comment
Question by:tdk_man
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 1

Author Comment

by:tdk_man
ID: 9807030
I have now managed to detect the error pop-up box and have the handle of that window.

Is there any way now for me to be able to access the message text in the window currently on screen?

TDK_Man
0
 
LVL 1

Accepted Solution

by:
hacibumbala earned 300 total points
ID: 9807133
Below is not a very reliable solution but it may help:

function GetMsgText: String;
var
  hwndParent, hwndChild: HWND;
  nSize: Integer;
begin
  hwndParent := FindWindow(nil, 'Error');
  if hwndParent = 0 then Exit;
  hwndChild := FindWindowEx(hwndParent, 0, nil, nil); // OK Button
  hwndChild := FindWindowEx(hwndParent, hwndChild, nil, nil); // Label we want.
  nSize := GetWindowTextLength(hwndChild);
  SetLength(Result, nSize);
  GetWindowText(hwndChild, PChar(Result), nSize + 1);
end;
0
 
LVL 1

Author Comment

by:tdk_man
ID: 9807380
Thank you so much - that seems to work beautifully. :)

I'd managed to get as far getting the OK from the OK button, but the rest would have taken me forever!

Have some points...

TDK_Man
0
 
LVL 1

Expert Comment

by:hacibumbala
ID: 9807532
No problem! Thank you for the points.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Read about why website design really matters in today's demanding market.
Read about the 3 stages of the buyer's journey: awareness, consideration, and decision.
An overview of how to create reports in Adobe Analytics (formerly Omniture Site Catalyst) using pageNames, events, eVars and props. This video will show you how to install the Omniture Debugger tool so can see (and test) what is being passed int…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…

705 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