Page 1 of 1

Relocate Send Assistant?

Posted: Mon May 27, 2019 8:27 am
by sse
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.46 KiB) Viewed 5390 times
Here are some relevant settings.
RelevantMadExceptSettings1.png
RelevantMadExceptSettings1.png (62.11 KiB) Viewed 5390 times
Many thanks,

sse

Re: Relocate Send Assistant?

Posted: Mon May 27, 2019 3:30 pm
by madshi
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()).

Re: Relocate Send Assistant?

Posted: Mon May 27, 2019 3:32 pm
by madshi
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;

Re: Relocate Send Assistant?

Posted: Tue May 28, 2019 1:46 am
by sse
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.

Re: Relocate Send Assistant?

Posted: Tue May 28, 2019 6:45 am
by madshi
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.

Re: Relocate Send Assistant?

Posted: Tue May 28, 2019 9:56 pm
by sse
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.