Solved

Detecting A Pop-Up Error Message

Posted on 2003-11-23
4
369 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
  • 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi selector screen 2 78
Need Free contact management program 9 105
LAN or WAN ? 11 90
Delphi and Access based Enumeration 9 59
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
In this blog, I will share you some basic tips for content marketing and to rank your website on Google.
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.

786 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