mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-30 07:30:22 +02:00
win32: Simulate beep+flash when clicking a (modally) disabled form. The OS flashes it only for the modal parent chain.
git-svn-id: trunk@51809 -
This commit is contained in:
parent
cf74370262
commit
385957f10b
@ -817,6 +817,19 @@ begin
|
|||||||
else LMScroll.SmallPos := High(LMScroll.SmallPos);
|
else LMScroll.SmallPos := High(LMScroll.SmallPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// FlashWindowEx is not (yet) in FPC
|
||||||
|
type
|
||||||
|
FLASHWINFO = record
|
||||||
|
cbSize: UINT;
|
||||||
|
hwnd: HWND;
|
||||||
|
dwFlags: DWORD;
|
||||||
|
uCount: UINT;
|
||||||
|
dwTimeout: DWORD;
|
||||||
|
end;
|
||||||
|
PFLASHWINFO = ^FLASHWINFO;
|
||||||
|
|
||||||
|
function FlashWindowEx(pfwi:PFLASHWINFO):WINBOOL; stdcall; external 'user32' name 'FlashWindowEx';
|
||||||
|
|
||||||
procedure TWindowProcHelper.HandleSetCursor;
|
procedure TWindowProcHelper.HandleSetCursor;
|
||||||
var
|
var
|
||||||
lControl: TControl;
|
lControl: TControl;
|
||||||
@ -825,6 +838,7 @@ var
|
|||||||
MouseMessage: Word;
|
MouseMessage: Word;
|
||||||
P: TPoint;
|
P: TPoint;
|
||||||
lWindow: HWND;
|
lWindow: HWND;
|
||||||
|
FlashInfo: FLASHWINFO;
|
||||||
begin
|
begin
|
||||||
if Assigned(lWinControl) then
|
if Assigned(lWinControl) then
|
||||||
begin
|
begin
|
||||||
@ -876,10 +890,30 @@ begin
|
|||||||
lWindow := GetLastActivePopup(Application.MainFormHandle)
|
lWindow := GetLastActivePopup(Application.MainFormHandle)
|
||||||
else
|
else
|
||||||
lWindow := GetLastActivePopup(Win32WidgetSet.AppHandle);
|
lWindow := GetLastActivePopup(Win32WidgetSet.AppHandle);
|
||||||
if (lWindow <> 0) and (lWindow <> GetActiveWindow) then // modal window found and different from active
|
|
||||||
|
if lWindow <> 0 then // modal window found
|
||||||
begin
|
begin
|
||||||
Win32WidgetSet.AppBringToFront; // bring application to front
|
if lWindow <> GetActiveWindow then
|
||||||
LMessage.Result := 1; // by setting 1 we forbid flashing of modal dialog
|
begin
|
||||||
|
// Activate the application in case it is not active without beep+flash
|
||||||
|
Win32WidgetSet.AppBringToFront;
|
||||||
|
LMessage.Result := 1; // disable native beep+flash, we don't want it
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
// Simulate default MS Windows beep+flash
|
||||||
|
// because MS Windows is able to flash only modal windows if
|
||||||
|
// a disabled window from the same parent chain was clicked on.
|
||||||
|
// This code flashes the dialog if whatever disabled form was clicked on.
|
||||||
|
Beep;
|
||||||
|
FillChar(FlashInfo{%H-}, SizeOf(FlashInfo), 0);
|
||||||
|
FlashInfo.cbSize := SizeOf(FlashInfo);
|
||||||
|
FlashInfo.hwnd := lWindow;
|
||||||
|
FlashInfo.dwFlags := 1; // FLASHW_CAPTION
|
||||||
|
FlashInfo.uCount := 6;
|
||||||
|
FlashInfo.dwTimeout := 70;
|
||||||
|
FlashWindowEx(@flashinfo);
|
||||||
|
LMessage.Result := 1; // disable native beep+flash, we already beep+flashed
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user