I'm using IMEException.Show method do display bug report form. It's working properly.
But I'd like to change the form positon, actually on desktop center, to main form center.
How could I do that?
Thanks in advance.
Change bug report form position
Re: Change bug report form position
You can register these callbacks exported by madExcept.pas:
Then in your "OnExceptBoxCreate" handler you can use win32 APIs (e.g. SetWindowPos) to change the form position. You can't use VCL because the madExcept exception box doesn't use VCL, because the VCL is not thread safe.
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;
Re: Change bug report form position
Thank you!!
It's worked:
It's worked:
Code: Select all
implementation
uses
madExcept;
...
procedure DoShowException(exceptBox: HWND; simpleMsgBox: boolean);
var
MbRect: TRect;
x, y, w, h: integer;
begin
GetWindowRect(exceptBox, MBRect);
with MbRect do
begin
w := Right - Left;
h := Bottom - Top;
end;
// center horzontal
x := Application.MainForm.Left + ((Application.MainForm.Width - w) div 2);
// keep on screen
if x < 0 then
x := 0
else if x + w > Screen.Width then x := Screen.Width - w;
//center vertical
y := Application.MainForm.Top + ((Application.MainForm.Height - h) div 2);
// keep on screen
if y < 0 then y := 0
else if y + h > Screen.Height then y := Screen.Height - h;
// set new windows position
SetWindowPos(exceptBox, 0, x, y, 0, 0, SWP_NOACTIVATE or SWP_NOSIZE or SWP_NOZORDER);
end;
...
initialization
OnExceptBoxCreate := DoShowException;