Relocate Send Assistant?

delphi package - automated exception handling

Relocate Send Assistant?

Postby sse » Mon May 27, 2019 8:27 am

Using MadExcept 4.0.21 with DXE3.

Is it possible to move the Exception Box so it appears in a different spot on the screen, eg, maybe 500 pels higher? The problem is that there is an Outlook Dialog that sometimes pops up, prompting the user to allow automatic sending. Unfortunately, the Exception Box covers this other dialog. I would like to move it.

For example, something like:

MadExceptOverOutlook.png
MadExceptOverOutlook.png (10.5 KiB) Viewed 1020 times


Here are some relevant settings.

RelevantMadExceptSettings1.png
RelevantMadExceptSettings1.png (62.33 KiB) Viewed 1020 times


Many thanks,

sse
sse
 
Posts: 3
Joined: Mon May 27, 2019 6:36 am

Re: Relocate Send Assistant?

Postby madshi » Mon May 27, 2019 3:30 pm

There's no direct API for that. But maybe the following callback exported by madExcept.pas can help you?

Code: Select all
// do you want to be notified when a madExcept exception box was created/destroyed?
var
  OnExceptBoxCreate  : procedure (exceptBox: HWND; simpleMsgBox: boolean) = nil;
  OnExceptBoxDestroy : procedure = nil;

Basically you can register this callback, and then in your "OnExceptBoxCreate" callback you could move the window, or make it non-topmost, using pure win32 APIs (e.g. SetWindowPos()).
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Relocate Send Assistant?

Postby madshi » Mon May 27, 2019 3:32 pm

P.S: Or maybe better: You could call RegisterExceptActionHandler(), and then if your handler is called for "sendBugReport", you can in that moment move the exception box? If you want to use this approach, you can use the following API in your ExceptActionHandler to get the window handle of the exception box:

Code: Select all
// get the handle of the madExcept exception box
// returns 0, if the box is not currently visible
function GetExceptBoxHandle : HWND;
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Relocate Send Assistant?

Postby sse » Tue May 28, 2019 1:46 am

Thank you for the prompt reply. Unfortunately, I don't have any experience with your suggestions below.
I am using MadExcept out of the box. Not using the component or MadExcept.pas.

How (where in code) would I call RegisterExceptActionHandler? I see there is a reference to this at http://help.madshi.net/madExceptUnit.ht ... ionHandler I will do some reading. Are there any examples?

I am unsure of what you mean by:
and then if your handler is called for "sendBugReport",
I don't currently have a handler, and I am unsure of how to go about writing one for this purpose. Could you give me a bit more information on this?

Sorry to be so daft. The more examples the better. I will do the leg work.
sse
 
Posts: 3
Joined: Mon May 27, 2019 6:36 am

Re: Relocate Send Assistant?

Postby madshi » Tue May 28, 2019 6:45 am

Something like this (not tested or even test compiled):

Code: Select all
uses ..., madExcept;

procedure YourExceptActionHandler(action: TExceptAction; const exceptIntf: IMEException; var handled: boolean)
begin
  if action = eaSendBugReport2 then
    // a bug report is about to be sent - assistant already completed
    SetTopmost(GetExceptBoxHandle, false);
end;

initialization
  RegisterExceptActionHandler(YourExceptActionHandler, stDontSync);
end.
madshi
Site Admin
 
Posts: 10098
Joined: Sun Mar 21, 2004 5:25 pm

Re: Relocate Send Assistant?

Postby sse » Tue May 28, 2019 9:56 pm

That's great. This is very powerful stuff. Here is the completed code as per your suggestions, maybe it will help someone else.

Many thanks,

sse

Code: Select all
procedure ShiftExceptionBoxUp(action: TExceptAction; const exceptIntf: IMEException; var handled: boolean);
var
  ExceptBoxHandle: THandle;
  ExeptBoxRect: TRect;
const
  UPWARD_SHIFT = 150;
begin
  if action = eaSendBugReport3 then     //Note: eaSendBugReport2 triggered after eaSendBugReport3, eg, when user clicks 'Send'
  begin
    // a bug report is about to be sent - assistant already completed
    ExceptBoxHandle := GetExceptBoxHandle;
    GetWindowRect(ExceptBoxHandle, ExeptBoxRect);
    MoveWindow(ExceptBoxHandle, ExeptBoxRect.Left, ExeptBoxRect.Top - UPWARD_SHIFT, ExeptBoxRect.Width, ExeptBoxRect.Height, True);
//    SetTopmost(GetExceptBoxHandle, false);
  end;
end;

initialization
  RegisterExceptActionHandler(ShiftExceptionBoxUp, stDontSync);
end.
sse
 
Posts: 3
Joined: Mon May 27, 2019 6:36 am


Return to madExcept

Who is online

Users browsing this forum: Google [Bot] and 12 guests

cron