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

@ -40,7 +40,8 @@ uses
exportgrid in '..\..\source\exportgrid.pas' {frmExportGrid},
syncdb in '..\..\source\syncdb.pas' {frmSyncDB},
gnugettext in '..\..\source\gnugettext.pas',
JumpList in '..\..\source\JumpList.pas';
JumpList in '..\..\source\JumpList.pas',
extra_controls in '..\..\source\extra_controls.pas';
{$R ..\..\res\icon.RES}
{$R ..\..\res\version.RES}

View File

@ -1,4 +1,4 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{32493ED6-4F48-45D7-9D50-E4FA13F59063}</ProjectGuid>
<MainSource>heidisql.dpr</MainSource>
@ -184,6 +184,7 @@
</DCCReference>
<DCCReference Include="..\..\source\gnugettext.pas"/>
<DCCReference Include="..\..\source\JumpList.pas"/>
<DCCReference Include="..\..\source\extra_controls.pas"/>
<BuildConfiguration Include="Debug">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>

View File

@ -4,12 +4,12 @@ interface
uses
Windows, Classes, Graphics, Forms, Controls, StdCtrls, VirtualTrees,
ComCtrls, ToolWin, Dialogs, SysUtils, gnugettext;
ComCtrls, ToolWin, Dialogs, SysUtils, gnugettext, extra_controls;
{$I const.inc}
type
TfrmBinEditor = class(TForm)
TfrmBinEditor = class(TFormWithSizeGrip)
memoText: TMemo;
tlbStandard: TToolBar;
btnWrap: TToolButton;
@ -101,7 +101,6 @@ begin
btnWrap.Click;
// Fix label position:
lblTextLength.Top := tlbStandard.Top + (tlbStandard.Height-lblTextLength.Height) div 2;
SetWindowSizeGrip(Handle, True);
memoText.SelectAll;
memoText.SetFocus;
memoTextChange(Sender);

View File

@ -4,10 +4,10 @@ interface
uses
Windows, Classes, Controls, Forms, StdCtrls, CheckLst, ExtCtrls,
helpers, gnugettext;
helpers, gnugettext, extra_controls;
type
TColumnSelectionForm = class(TForm)
TColumnSelectionForm = class(TFormWithSizeGrip)
btnCancel: TButton;
btnOK: TButton;
chkSelectAll: TCheckBox;
@ -45,7 +45,6 @@ procedure TColumnSelectionForm.FormCreate(Sender: TObject);
begin
InheritFont(Font);
TranslateComponent(Self);
SetWindowSizeGrip(Self.Handle, True);
Width := AppSettings.ReadInt(asColumnSelectorWidth);
Height := AppSettings.ReadInt(asColumnSelectorHeight);
end;

View File

@ -10,11 +10,11 @@ interface
uses
Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
VirtualTrees, Menus, Graphics, Generics.Collections, ActiveX,
VirtualTrees, Menus, Graphics, Generics.Collections, ActiveX, extra_controls,
dbconnection, gnugettext;
type
Tconnform = class(TForm)
Tconnform = class(TFormWithSizeGrip)
btnCancel: TButton;
btnOpen: TButton;
btnSave: TButton;
@ -178,7 +178,6 @@ begin
// Fix GUI stuff
TranslateComponent(Self);
InheritFont(Font);
SetWindowSizeGrip(Handle, True);
Width := AppSettings.ReadInt(asSessionManagerWindowWidth);
Height := AppSettings.ReadInt(asSessionManagerWindowHeight);
ListSessions.Width := AppSettings.ReadInt(asSessionManagerListWidth);

View File

@ -4,11 +4,11 @@ unit copytable;
interface
uses
Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls,
Windows, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, extra_controls,
dbconnection, VirtualTrees, SynEdit, SynMemo, Menus, gnugettext;
type
TCopyTableForm = class(TForm)
TCopyTableForm = class(TFormWithSizeGrip)
editNewTablename: TEdit;
lblNewTablename: TLabel;
btnCancel: TButton;
@ -71,7 +71,6 @@ begin
InheritFont(Font);
Width := AppSettings.ReadInt(asCopyTableWindowWidth);
Height := AppSettings.ReadInt(asCopyTableWindowHeight);
SetWindowSizeGrip(Handle, True);
MainForm.SetupSynEditors;
FixVT(TreeElements);
FColumns := TTableColumnList.Create;

View File

@ -4,13 +4,13 @@ interface
uses
Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
dbconnection, mysql_structures, ComCtrls, gnugettext, SynRegExpr;
dbconnection, mysql_structures, ComCtrls, gnugettext, SynRegExpr, extra_controls;
type
TVarType = (vtString, vtNumeric, vtBoolean, vtEnum);
EVariableError = class(Exception);
TfrmEditVariable = class(TForm)
TfrmEditVariable = class(TFormWithSizeGrip)
btnOK: TButton;
btnCancel: TButton;
grpScope: TGroupBox;
@ -57,7 +57,6 @@ procedure TfrmEditVariable.FormCreate(Sender: TObject);
begin
InheritFont(Font);
TranslateComponent(Self);
SetWindowSizeGrip(Handle, True);
Width := AppSettings.ReadInt(asEditVarWindowWidth);
Height := AppSettings.ReadInt(asEditVarWindowHeight);
end;

61
source/extra_controls.pas Normal file
View File

@ -0,0 +1,61 @@
unit extra_controls;
interface
uses
Classes, SysUtils, Forms, Windows, Messages;
type
// Form with a sizegrip in the lower right corner, without the need for a statusbar
TFormWithSizeGrip = class(TForm)
private
FSizeGripRect: TRect;
FSizeGripWidth: Integer;
FSizeGripHeight: Integer;
procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
public
constructor Create(AOwner: TComponent); override;
procedure Paint; override;
procedure Resize; override;
end;
implementation
{ TFormWithSizeGrip }
constructor TFormWithSizeGrip.Create(AOwner: TComponent);
begin
inherited;
FSizeGripWidth := GetSystemMetrics(SM_CXVSCROLL);
FSizeGripHeight := GetSystemMetrics(SM_CYHSCROLL);
end;
procedure TFormWithSizeGrip.WMNCHitTest(var Msg: TWMNCHitTest);
begin
inherited;
if PtInRect(FSizeGripRect, ScreenToClient(SmallPointToPoint(Msg.Pos))) then
Msg.Result := HTBOTTOMRIGHT;
end;
procedure TFormWithSizeGrip.Paint;
begin
inherited;
DrawFrameControl(Canvas.Handle, FSizeGripRect, DFC_SCROLL, DFCS_SCROLLSIZEGRIP);
end;
procedure TFormWithSizeGrip.Resize;
begin
inherited;
FSizeGripRect := ClientRect;
FSizeGripRect.Left := FSizeGripRect.Right - FSizeGripWidth;
FSizeGripRect.Top := FSizeGripRect.Bottom - FSizeGripHeight;
Refresh;
end;
end.

View File

@ -915,9 +915,7 @@ begin
FPanel.Hide;
FPanel.Parent := FParentForm;
FPanel.ParentBackground := False;
FPanel.Width := AppSettings.ReadInt(asSetEditorWidth);
FPanel.Height := AppSettings.ReadInt(asSetEditorHeight);
SetWindowSizeGrip(FPanel.Handle, True);
FPanel.Height := 150;
FPanel.OnResize := PanelResize;
FPanel.OnExit := DoEndEdit;
@ -1002,6 +1000,7 @@ begin
R := GetCellRect(False);
FPanel.Top := R.Top;
FPanel.Left := R.Left;
FPanel.Width := R.Width;
FBtnOk.Width := (FPanel.Width - 3*margin) div 2;
FBtnOk.Left := margin;

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);

View File

@ -4,7 +4,7 @@ interface
uses
Windows, Messages, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls,
ShellApi, Math, Graphics, ComCtrls, ToolWin,
ShellApi, Math, Graphics, ComCtrls, ToolWin, extra_controls,
dbconnection, mysql_structures, VirtualTrees, grideditlinks, SynRegExpr, gnugettext, helpers;
type
@ -25,7 +25,7 @@ type
end;
PFileInfo = ^TFileInfo;
TfrmInsertFiles = class(TForm)
TfrmInsertFiles = class(TFormWithSizeGrip)
btnInsert: TButton;
btnCancel: TButton;
OpenDialog: TOpenDialog;
@ -119,7 +119,6 @@ begin
TranslateComponent(Self);
ListFiles.Images := GetSystemImageList;
DragAcceptFiles(Handle, True);
SetWindowSizeGrip(Self.Handle, True);
InheritFont(Font);
MainForm.RestoreListSetup(ListColumns);
MainForm.RestoreListSetup(ListFiles);

View File

@ -10,11 +10,11 @@ interface
uses
Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ComCtrls, CheckLst,
SynRegExpr, Buttons, ExtCtrls, ToolWin, ExtDlgs, Math,
SynRegExpr, Buttons, ExtCtrls, ToolWin, ExtDlgs, Math, extra_controls,
dbconnection, mysql_structures, gnugettext;
type
Tloaddataform = class(TForm)
Tloaddataform = class(TFormWithSizeGrip)
btnImport: TButton;
btnCancel: TButton;
lblDatabase: TLabel;
@ -94,7 +94,6 @@ procedure Tloaddataform.FormCreate(Sender: TObject);
begin
TranslateComponent(Self);
InheritFont(Font);
SetWindowSizeGrip(Handle, True);
// Restore settings
Width := AppSettings.ReadInt(asCSVImportWindowWidth);
Height := AppSettings.ReadInt(asCSVImportWindowHeight);

View File

@ -3,11 +3,11 @@ unit selectdbobject;
interface
uses
Windows, Classes, Controls, Forms, StdCtrls, VirtualTrees, Graphics,
Windows, Classes, Controls, Forms, StdCtrls, VirtualTrees, Graphics, extra_controls,
dbconnection, gnugettext;
type
TfrmSelectDBObject = class(TForm)
TfrmSelectDBObject = class(TFormWithSizeGrip)
TreeDBO: TVirtualStringTree;
btnOK: TButton;
btnCancel: TButton;
@ -65,7 +65,6 @@ begin
TranslateComponent(Self);
Width := AppSettings.ReadInt(asSelectDBOWindowWidth);
Height := AppSettings.ReadInt(asSelectDBOWindowHeight);
SetWindowSizeGrip( Self.Handle, True );
InheritFont(Font);
TreeDBO.TreeOptions := MainForm.DBtree.TreeOptions;
FixVT(TreeDBO);

View File

@ -4,12 +4,12 @@ interface
uses
Windows, SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ComCtrls, ExtCtrls,
Buttons, SynMemo, SynEditHighlighter, SynHighlighterURI,
Buttons, SynMemo, SynEditHighlighter, SynHighlighterURI, extra_controls,
SynURIOpener, SynEdit, VirtualTrees, Graphics,
dbconnection, gnugettext;
type
TfrmSQLhelp = class(TForm)
TfrmSQLhelp = class(TFormWithSizeGrip)
URIOpenerDescription: TSynURIOpener;
URIHighlighter: TSynURISyn;
URIOpenerExample: TSynURIOpener;
@ -81,7 +81,6 @@ procedure TfrmSQLhelp.FormCreate(Sender: TObject);
begin
// Set window-layout
InheritFont(Font);
SetWindowSizeGrip(Handle, True);
Top := AppSettings.ReadInt(asSQLHelpWindowTop);
Left := AppSettings.ReadInt(asSQLHelpWindowLeft);
Width := AppSettings.ReadInt(asSQLHelpWindowWidth);

View File

@ -4,11 +4,11 @@ interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Generics.Collections, VirtualTrees,
Dialogs, StdCtrls, Generics.Collections, VirtualTrees, extra_controls,
dbconnection, gnugettext;
type
TfrmSyncDB = class(TForm)
TfrmSyncDB = class(TFormWithSizeGrip)
treeSource: TVirtualStringTree;
lblSource: TLabel;
grpTarget: TGroupBox;
@ -109,7 +109,6 @@ begin
Caption := MainForm.actSynchronizeDatabase.Caption;
TranslateComponent(Self);
InheritFont(Font);
SetWindowSizeGrip(Self.Handle, True);
FixVT(treeSource);
FixVT(treeDifferences);

View File

@ -10,12 +10,12 @@ interface
uses
Windows, SysUtils, Classes, Controls, Forms, StdCtrls, ComCtrls, Buttons, Dialogs, StdActns,
VirtualTrees, ExtCtrls, Graphics, SynRegExpr, Math, Generics.Collections,
VirtualTrees, ExtCtrls, Graphics, SynRegExpr, Math, Generics.Collections, extra_controls,
dbconnection, helpers, Menus, gnugettext, DateUtils, System.Zip, System.UITypes;
type
TToolMode = (tmMaintenance, tmFind, tmSQLExport, tmBulkTableEdit);
TfrmTableTools = class(TForm)
TfrmTableTools = class(TFormWithSizeGrip)
btnCloseOrCancel: TButton;
pnlTop: TPanel;
TreeObjects: TVirtualStringTree;
@ -221,7 +221,6 @@ begin
comboExportOutputTarget.Text := '';
// Various
SetWindowSizeGrip( Self.Handle, True );
FixVT(TreeObjects);
FixVT(ResultGrid);
FResults := TObjectList<TStringList>.Create;

View File

@ -5,12 +5,12 @@ interface
uses
Windows, Classes, Graphics, Forms, Controls, StdCtrls, VirtualTrees,
ComCtrls, ToolWin, Dialogs, SysUtils, Menus, ExtDlgs,
helpers, gnugettext, ActnList, StdActns;
helpers, gnugettext, ActnList, StdActns, extra_controls, System.Actions;
{$I const.inc}
type
TfrmTextEditor = class(TForm)
TfrmTextEditor = class(TFormWithSizeGrip)
memoText: TMemo;
tlbStandard: TToolBar;
btnWrap: TToolButton;
@ -198,7 +198,6 @@ begin
btnWrap.Click;
// Fix label position:
lblTextLength.Top := tlbStandard.Top + (tlbStandard.Height-lblTextLength.Height) div 2;
SetWindowSizeGrip(Handle, True);
memoText.SetFocus;
end;

View File

@ -5,7 +5,7 @@ interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ComCtrls, StdCtrls,
ExtCtrls, ToolWin, ClipBrd, Generics.Collections, Generics.Defaults, SynRegExpr,
ExtCtrls, ToolWin, ClipBrd, Generics.Collections, Generics.Defaults, SynRegExpr, extra_controls,
dbconnection, helpers, VirtualTrees, Menus, gnugettext;
{$I const.inc}
@ -40,7 +40,7 @@ type
EInputError = class(Exception);
TUserManagerForm = class(TForm)
TUserManagerForm = class(TFormWithSizeGrip)
btnCancel: TButton;
btnSave: TButton;
pnlLeft: TPanel;
@ -211,7 +211,6 @@ begin
Width := AppSettings.ReadInt(asUsermanagerWindowWidth);
Height := AppSettings.ReadInt(asUsermanagerWindowHeight);
pnlLeft.Width := AppSettings.ReadInt(asUsermanagerListWidth);
SetWindowSizeGrip( Self.Handle, True );
FixVT(listUsers);
FixVT(treePrivs);
Mainform.RestoreListSetup(listUsers);