summaryrefslogtreecommitdiff
path: root/src/corelib
diff options
context:
space:
mode:
authorgraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-22 14:16:59 +0000
committergraemeg <graemeg@ae50a9b5-8222-0410-bf8d-8a13f76226bf>2008-07-22 14:16:59 +0000
commit5434f4524e3ac3fc4be33ab4077ae8b2557784bb (patch)
tree00cf3c2f54295e012c5908f671dcd3fddc2740e9 /src/corelib
parent193ddf98399948f1022e484a44a237dd2d11b43a (diff)
downloadfpGUI-5434f4524e3ac3fc4be33ab4077ae8b2557784bb.tar.xz
Applied Valdimir's modalform patch for GDI backend.
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/gdi/gfx_gdi.pas78
1 files changed, 58 insertions, 20 deletions
diff --git a/src/corelib/gdi/gfx_gdi.pas b/src/corelib/gdi/gfx_gdi.pas
index b2873297..afcd8b63 100644
--- a/src/corelib/gdi/gfx_gdi.pas
+++ b/src/corelib/gdi/gfx_gdi.pas
@@ -203,10 +203,12 @@ type
{ To avoid problems, window classes should be accessible
from RegisterClass call till the program is terminated. }
HiddenWndClass: TWndClass;
+ ActivationHook: HHOOK;
function GetHiddenWindow: HWND;
function DoGetFontFaceList: TStringList; override;
public
constructor Create(const AParams: string); override;
+ destructor Destroy; override;
function DoMessagesPending: boolean;
procedure DoWaitWindowMessage(atimeoutms: integer);
procedure DoFlush;
@@ -436,6 +438,32 @@ begin
dy := (2 * by) + bt;
end;
+function fpgCBTProc(nCode: longint; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
+begin
+ if nCode < 0 then
+ begin
+ Result := CallNextHookEx(wapplication.ActivationHook, nCode, wParam, lParam);
+ Exit; //==>
+ end;
+
+ if (nCode = HCBT_ACTIVATE) then
+ begin
+ // write('Hooked HCBT_ACTIVATE at '+IntToStr(wParam)+': ');
+ if (wapplication.TopModalForm <> nil) and
+ (wParam <> TfpgWindowImpl(wapplication.TopModalForm).FWinHandle) then
+ begin
+ // writeln('stopped');
+ SetActiveWindow(TfpgWindowImpl(wapplication.TopModalForm).FWinHandle);
+ Result := 1;
+ end else
+ begin
+ // writeln('passed');
+ Result := 0;
+ end;
+ end else
+ Result := CallNextHookEx(wapplication.ActivationHook, nCode, wParam, lParam);
+end;
+
function fpgWindowProc(hwnd: HWND; uMsg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
w: TfpgWindowImpl;
@@ -837,9 +865,10 @@ begin
WM_NCACTIVATE:
begin
{$IFDEF DEBUG}
- writeln(w.ClassName + ': WM_NCACTIVATE');
+ write(w.ClassName + ': WM_NCACTIVATE ');
+ writeln(wParam);
{$ENDIF}
- if (Lo(wParam) = WA_INACTIVE) then
+ if (wParam = 0) then
fpgSendMessage(nil, w, FPGM_DEACTIVATE)
else
fpgSendMessage(nil, w, FPGM_ACTIVATE);
@@ -853,24 +882,25 @@ begin
if (PopupListFirst.ClassName <> 'TDropDownWindow') then
// if not (PopupListFirst is TfpgPopupWindow) then
blockmsg := True;
- end else
- if (wapplication.TopModalForm <> nil) then
- begin
- if (wParam = 0) and (wapplication.TopModalForm = w) then
- begin
- {$IFDEF DEBUG}
- writeln(' Blockmsg = True (part 2)');
- {$ENDIF}
- blockmsg := True;
- end
- else if (wParam <> 0) and (wapplication.TopModalForm <> w) then
- begin
- {$IFDEF DEBUG}
- writeln(' Blockmsg = True (part 3)');
- {$ENDIF}
- blockmsg := True;
- end;
end;
+ //end else
+ //if (wapplication.TopModalForm <> nil) then
+ //begin
+ //if (wParam = 0) and (wapplication.TopModalForm = w) then
+ //begin
+ //{$IFDEF DEBUG}
+ //writeln(' Blockmsg = True (part 2)');
+ //{$ENDIF}
+ //blockmsg := True;
+ //end
+ //else if (wParam <> 0) and (wapplication.TopModalForm <> w) then
+ //begin
+ //{$IFDEF DEBUG}
+ //writeln(' Blockmsg = True (part 3)');
+ //{$ENDIF}
+ //blockmsg := True;
+ //end;
+ //end;
if not blockmsg then
Result := Windows.DefWindowProc(hwnd, uMsg, wParam, lParam);
@@ -945,7 +975,7 @@ begin
Windows.RegisterClass(@HiddenWndClass);
FHiddenWindow := CreateWindow('FPGHIDDEN', '',
- DWORD(WS_POPUP), 0, 0, 0, 0, 0, 0, MainInstance, nil);
+ DWORD(WS_POPUP), 0, 0, 0, 0, TfpgWindowImpl(MainForm).FWinHandle, 0, MainInstance, nil);
end;
Result := FHiddenWindow;
end;
@@ -997,10 +1027,18 @@ begin
FHiddenWindow := 0;
+ ActivationHook := SetWindowsHookEx(WH_CBT, HOOKPROC(@fpgCBTProc), 0, GetCurrentThreadId);
+
FIsInitialized := True;
wapplication := TfpgApplication(self);
end;
+destructor TfpgApplicationImpl.Destroy;
+begin
+ UnhookWindowsHookEx(ActivationHook);
+ inherited Destroy;
+end;
+
function TfpgApplicationImpl.DoMessagesPending: boolean;
var
Msg: TMsg;