Replace out-dated code which does not compile in 64bit mode in helpers.SetWindowSizeGrip. Use a TForm descendant in the new unit "extra_controls". Code parts taken from http://www.delphigroups.info/2/4/326787.html

This commit is contained in:
Ansgar Becker
2013-11-01 14:54:13 +00:00
parent 6d1acb1136
commit 6e608f157e
18 changed files with 94 additions and 192 deletions

View File

@ -43,14 +43,6 @@ type
end;
TDBObjectEditorClass = class of TDBObjectEditor;
TWndProc = function (hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
PGripInfo = ^TGripInfo;
TGripInfo = record
OldWndProc: TWndProc;
Enabled: boolean;
GripRect: TRect;
end;
TSQLBatch = class;
TSQLSentence = class(TObject)
private
@ -168,7 +160,7 @@ type
asConnectCount, asRefusedCount, asSessionCreated, asDoUsageStatistics,
asLastUsageStatisticCall, asDisplayBars, asBarColor, asMySQLBinaries, asCustomSnippetsDirectory, asPromptSaveFileOnTabClose,
asCompletionProposal, asTabsToSpaces, asFilterPanel, asAllowMultipleInstances, asFindDialogSearchHistory,
asFindDialogReplaceHistory, asMaxQueryResults, asSetEditorWidth, asSetEditorHeight, asLogErrors,
asFindDialogReplaceHistory, asMaxQueryResults, asLogErrors,
asLogUserSQL, asLogSQL, asLogInfos, asLogDebug, asFieldColorNumeric,
asFieldColorReal, asFieldColorText, asFieldColorBinary, asFieldColorDatetime, asFieldColorSpatial,
asFieldColorOther, asFieldEditorBinary, asFieldEditorDatetime, asFieldEditorDatetimePrefill, asFieldEditorEnum,
@ -276,7 +268,6 @@ type
function FormatByteNumber( Bytes: String; Decimals: Byte = 1 ): String; Overload;
function FormatTimeNumber(Seconds: Cardinal; DisplaySeconds: Boolean): String;
function GetTempDir: String;
procedure SetWindowSizeGrip(hWnd: HWND; Enable: boolean);
procedure SaveUnicodeFile(Filename: String; Text: String);
procedure OpenTextFile(const Filename: String; out Stream: TFileStream; var Encoding: TEncoding);
function DetectEncoding(Stream: TStream): TEncoding;
@ -1054,142 +1045,6 @@ begin
end;
{
Code taken from SizeGripHWND.pas:
Copyright (C) 2005, 2006 Volker Siebert <flocke@vssd.de>
Alle Rechte vorbehalten.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
}
function SizeGripWndProc(hWnd: HWND; Msg: UINT; wParam: WPARAM; lParam: LPARAM): LRESULT; stdcall;
var
Info: PGripInfo;
dc: HDC;
pt: TPoint;
// Invalidate the current grip rectangle
procedure InvalidateGrip;
begin
with Info^ do
if (GripRect.Right > GripRect.Left) and
(GripRect.Bottom > GripRect.Top) then
InvalidateRect(hWnd, @GripRect, true);
end;
// Update (and invalidate) the current grip rectangle
procedure UpdateGrip;
begin
with Info^ do
begin
GetClientRect(hWnd, GripRect);
GripRect.Left := GripRect.Right - GetSystemMetrics(SM_CXHSCROLL);
GripRect.Top := GripRect.Bottom - GetSystemMetrics(SM_CYVSCROLL);
end;
InvalidateGrip;
end;
function CallOld: LRESULT;
begin
Result := CallWindowProc(@Info^.OldWndProc, hWnd, Msg, wParam, lParam);
end;
begin
Info := PGripInfo(GetProp(hWnd, SizeGripProp));
if Info = nil then
Result := DefWindowProc(hWnd, Msg, wParam, lParam)
else if not Info^.Enabled then
Result := CallOld
else
begin
case Msg of
WM_NCDESTROY: begin
Result := CallOld;
SetWindowLong(hWnd, GWL_WNDPROC, LongInt(@Info^.OldWndProc));
RemoveProp(hWnd, SizeGripProp);
Dispose(Info);
end;
WM_PAINT: begin
Result := CallOld;
if wParam = 0 then
begin
dc := GetDC(hWnd);
DrawFrameControl(dc, Info^.GripRect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
ReleaseDC(hWnd, dc);
end;
end;
WM_NCHITTEST: begin
pt.x := TSmallPoint(lParam).x;
pt.y := TSmallPoint(lParam).y;
ScreenToClient(hWnd, pt);
if PtInRect(Info^.GripRect, pt) then
Result := HTBOTTOMRIGHT
else
Result := CallOld;
end;
WM_SIZE: begin
InvalidateGrip;
Result := CallOld;
UpdateGrip;
end;
else
Result := CallOld;
end;
end;
end;
{ Note that SetWindowSizeGrip(..., false) does not really remove the hook -
it just sets "Enabled" to false. The hook plus all data is removed when
the window is destroyed.
}
procedure SetWindowSizeGrip(hWnd: HWND; Enable: boolean);
var
Info: PGripInfo;
begin
Info := PGripInfo(GetProp(hWnd, SizeGripProp));
if (Info = nil) and Enable then
begin
New(Info);
FillChar(Info^, SizeOf(TGripInfo), 0);
with Info^ do
begin
Info^.OldWndProc := TWndProc(Pointer(GetWindowLong(hWnd, GWL_WNDPROC)));
GetClientRect(hWnd, GripRect);
GripRect.Left := GripRect.Right - GetSystemMetrics(SM_CXHSCROLL);
GripRect.Top := GripRect.Bottom - GetSystemMetrics(SM_CYVSCROLL);
end;
SetProp(hWnd, SizeGripProp, Cardinal(Info));
SetWindowLong(hWnd, GWL_WNDPROC, LongInt(@SizeGripWndProc));
end;
if (Info <> nil) then
if Enable <> Info^.Enabled then
with Info^ do
begin
Enabled := Enable;
if (GripRect.Right > GripRect.Left) and
(GripRect.Bottom > GripRect.Top) then
InvalidateRect(hWnd, @GripRect, true);
end;
end;
{**
Save a textfile with unicode
}
@ -3331,8 +3186,6 @@ begin
InitSetting(asFindDialogSearchHistory, 'FindDialogSearchHistory', 0, False, '');
InitSetting(asFindDialogReplaceHistory, 'FindDialogReplaceHistory', 0, False, '');
InitSetting(asMaxQueryResults, 'MaxQueryResults', 10);
InitSetting(asSetEditorWidth, 'SetEditorWidth', 100);
InitSetting(asSetEditorHeight, 'SetEditorHeight', 130);
InitSetting(asLogErrors, 'LogErrors', 0, True);
InitSetting(asLogUserSQL, 'LogUserSQL', 0, True);
InitSetting(asLogSQL, 'LogSQL', 0, True);