Skip to content

Commit

Permalink
Simplify.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Jun 22, 2024
1 parent 795289f commit 0d6210d
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions Projects/Src/CompForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -3203,15 +3203,15 @@ procedure TCompileForm.InitializeFindText(Dlg: TFindDialog);
Dlg.FindText := FLastFindText;
end;

var
CompWndProcPtrAtom: TAtom = 0;
const
OldFindReplaceWndProcProp = 'OldFindReplaceWndProc';

function FindReplaceWndProc(Wnd: HWND; Msg: Cardinal; WParam: WPARAM; LParam: LPARAM): LRESULT; stdcall;

function CallDefWndProc: LRESULT;
begin
Result := CallWindowProc(Pointer(GetProp(Wnd,
MakeIntAtom(CompWndProcPtrAtom))), Wnd, Msg, WParam, LParam);
Result := CallWindowProc(Pointer(GetProp(Wnd, OldFindReplaceWndProcProp)), Wnd,
Msg, WParam, LParam);
end;

begin
Expand All @@ -3225,7 +3225,7 @@ function FindReplaceWndProc(Wnd: HWND; Msg: Cardinal; WParam: WPARAM; LParam: LP
WM_NCDESTROY:
begin
Result := CallDefWndProc;
RemoveProp(Wnd, MakeIntAtom(CompWndProcPtrAtom));
RemoveProp(Wnd, OldFindReplaceWndProcProp);
Exit;
end;
end;
Expand All @@ -3237,7 +3237,7 @@ procedure ExecuteFindDialogAllowingAltEnter(const FindDialog: TFindDialog);
var DoHook := FindDialog.Handle = 0;
FindDialog.Execute;
if DoHook then begin
SetProp(FindDialog.Handle, MakeIntAtom(CompWndProcPtrAtom), GetWindowLong(FindDialog.Handle, GWL_WNDPROC));
SetProp(FindDialog.Handle, OldFindReplaceWndProcProp, GetWindowLong(FindDialog.Handle, GWL_WNDPROC));
SetWindowLong(FindDialog.Handle, GWL_WNDPROC, IntPtr(@FindReplaceWndProc));
end;
end;
Expand Down Expand Up @@ -6932,19 +6932,13 @@ function TCompileForm.FromCurrentPPI(const XY: Integer): Integer;
Result := MulDiv(XY, 96, CurrentPPI);
end;

var
AtomText: array[0..31] of Char;

initialization
InitThemeLibrary;
InitHtmlHelpLibrary;
{ For ClearType support, try to make the default font Microsoft Sans Serif }
if DefFontData.Name = 'MS Sans Serif' then
DefFontData.Name := AnsiString(GetPreferredUIFont);
CoInitialize(nil);
CompWndProcPtrAtom := GlobalAddAtom(StrFmt(AtomText,
'CompWndProcPtr%.8X%.8X', [HInstance, GetCurrentThreadID]));
finalization
CoUninitialize();
if CompWndProcPtrAtom <> 0 then GlobalDeleteAtom(CompWndProcPtrAtom);
end.

0 comments on commit 0d6210d

Please sign in to comment.