Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Detecting A Pop-Up Error Message

Posted on 2003-11-23
4
Medium Priority
?
376 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 1200 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

Eye-catchers on the conference table

Challenge: The i-unit group was not satisfied with the audio quality during remote meetings. They were looking for a portable solution with excellent audio quality for use in their conference room but also at their client’s offices.

Question has a verified solution.

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

In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
There are many other benefits to creating an inbound marketing strategy. Let’s take a look at five of the biggest and how they'll affect your business.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.
Suggested Courses

596 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