refactor: Hide implementation details of StrConsts

This commit is contained in:
Nikolaos Georgiou 2022-09-05 22:06:21 +02:00
parent 196462f11c
commit 810bf694b3
7 changed files with 140 additions and 82 deletions

View File

@ -4,7 +4,7 @@ root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120

1
.gitignore vendored
View File

@ -6,3 +6,4 @@
*.compiled
*.bak
*.lps
backup/

View File

@ -1,124 +1,125 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="11" />
<PathDelim Value="\" />
<Version Value="12"/>
<PathDelim Value="\"/>
<General>
<Flags>
<MainUnitHasUsesSectionForAllUnits Value="False" />
<MainUnitHasCreateFormStatements Value="False" />
<MainUnitHasTitleStatement Value="False" />
<MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
<CompatibilityMode Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir" />
<MainUnit Value="0" />
<Title Value="Chameleon" />
<UseAppBundle Value="False" />
<ResourceType Value="res" />
<UseXPManifest Value="True" />
<SessionStorage Value="InProjectDir"/>
<Title Value="Chameleon"/>
<UseAppBundle Value="False"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<XPManifest>
<DpiAware Value="True" />
<DpiAware Value="True"/>
</XPManifest>
</General>
<i18n>
<EnableI18N LFM="False" />
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<UseVersionInfo Value="True" />
<AutoIncrementBuild Value="True" />
<RevisionNr Value="0" />
<BuildNr Value="2" />
<MajorVersionNr Value="0" />
<MinorVersionNr Value="1" />
<UseVersionInfo Value="True"/>
<AutoIncrementBuild Value="True"/>
<MinorVersionNr Value="1"/>
<BuildNr Value="2"/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True" />
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2" />
<Version Value="2"/>
</PublishOptions>
<RunParams>
<FormatVersion Value="2" />
<FormatVersion Value="2"/>
<Modes Count="1">
<Mode0 Name="default" />
<Mode0 Name="default"/>
</Modes>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL" />
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="7">
<Unit0>
<Filename Value="Chameleon.lpr" />
<IsPartOfProject Value="True" />
<Filename Value="Chameleon.lpr"/>
<IsPartOfProject Value="True"/>
</Unit0>
<Unit1>
<Filename Value="frmMain.pas" />
<IsPartOfProject Value="True" />
<ComponentName Value="MainForm" />
<HasResources Value="True" />
<ResourceBaseClass Value="Form" />
<Filename Value="frmMain.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="MainForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit1>
<Unit2>
<Filename Value="frmResults.pas" />
<IsPartOfProject Value="True" />
<ComponentName Value="Results" />
<HasResources Value="True" />
<ResourceBaseClass Value="Form" />
<Filename Value="frmResults.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="Results"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit2>
<Unit3>
<Filename Value="Writers.pas" />
<IsPartOfProject Value="True" />
<Filename Value="Writers.pas"/>
<IsPartOfProject Value="True"/>
</Unit3>
<Unit4>
<Filename Value="DfmEngine.pas" />
<IsPartOfProject Value="True" />
<Filename Value="DfmEngine.pas"/>
<IsPartOfProject Value="True"/>
</Unit4>
<Unit5>
<Filename Value="StrConsts.pas" />
<IsPartOfProject Value="True" />
<Filename Value="StrConsts.pas"/>
<IsPartOfProject Value="True"/>
</Unit5>
<Unit6>
<Filename Value="about1.pas" />
<IsPartOfProject Value="True" />
<ComponentName Value="AboutBox" />
<HasResources Value="True" />
<ResourceBaseClass Value="Form" />
<Filename Value="about1.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="AboutBox"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit6>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11" />
<PathDelim Value="\" />
<Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)" />
<IncludeFiles Value="$(ProjOutDir)"/>
</SearchPaths>
<Parsing>
<SyntaxOptions>
<SyntaxMode Value="Delphi" />
<SyntaxMode Value="Delphi"/>
</SyntaxOptions>
</Parsing>
<Linking>
<Debugging>
<DebugInfoType Value="dsDwarf2Set"/>
</Debugging>
<Options>
<Win32>
<GraphicApplication Value="True" />
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
<Other>
<CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL" />
<CustomOptions Value="-dBorland -dVer150 -dDelphi7 -dCompiler6_Up -dPUREPASCAL"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort" />
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError" />
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError" />
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>

Binary file not shown.

View File

@ -4,6 +4,13 @@ unit StrConsts;
interface
uses Classes;
function GetWindowStyleNames(style: Integer): TStringList;
function GetExtendedWindowStyleNames(style: Integer): TStringList;
implementation
uses Windows;
const
@ -101,6 +108,28 @@ const
'Transparent',
'Raised edge');
implementation
function GetWindowStyleNames(style: Integer): TStringList;
var
list: TStringList;
i: Integer;
begin
list := TStringList.Create();
for i := Low(WindowStyle) to High(WindowStyle) do
if ((style and WindowStyle[i]) = WindowStyle[i]) then
list.Add(WindowStyleName[i]);
Result := list;
end;
function GetExtendedWindowStyleNames(style: Integer): TStringList;
var
list: TStringList;
i: Integer;
begin
list := TStringList.Create();
for i := Low(ExtendedWindowStyle) to High(ExtendedWindowStyle) do
if ((style and ExtendedWindowStyle[i]) = ExtendedWindowStyle[i]) then
list.Add(ExtendedWindowStyleName[i]);
Result := list;
end;
end.

View File

@ -11,14 +11,13 @@ object MainForm: TMainForm
Font.Color = clWindowText
Font.Height = -14
Font.Name = 'Tahoma'
LCLVersion = '2.0.6.0'
LCLVersion = '2.2.0.4'
object lblDelayTime: TLabel
Left = 21
Height = 17
Top = 11
Width = 168
Caption = 'Time until restoring control:'
ParentColor = False
end
object Label1: TLabel
Left = 273
@ -26,14 +25,12 @@ object MainForm: TMainForm
Top = 11
Width = 32
Caption = 'msec'
ParentColor = False
end
object DelayTime: TSpinEdit
Left = 206
Height = 25
Top = 11
Width = 63
MaxValue = 0
TabOrder = 0
Value = 3000
end
@ -60,7 +57,6 @@ object MainForm: TMainForm
Width = 78
Caption = 'HWND value'
Enabled = False
ParentColor = False
end
object Information: TButton
Left = 21
@ -114,7 +110,6 @@ object MainForm: TMainForm
Top = 11
Width = 81
Caption = 'Unit file name'
ParentColor = False
end
object Label4: TLabel
Left = 21
@ -122,7 +117,6 @@ object MainForm: TMainForm
Top = 80
Width = 70
Caption = 'Form name'
ParentColor = False
end
object PasFileName: TEdit
Left = 21
@ -174,7 +168,6 @@ object MainForm: TMainForm
Top = 11
Width = 75
Caption = 'RC file name'
ParentColor = False
end
object RCFileName: TEdit
Left = 21
@ -232,7 +225,7 @@ object MainForm: TMainForm
end
object SaveDialog1: TSaveDialog
Options = [ofOverwritePrompt, ofHideReadOnly]
left = 366
top = 240
Left = 366
Top = 240
end
end

View File

@ -52,6 +52,8 @@ type
PasList: TStrings);
procedure GeneratePasFile(const filename, frmname: string; PasList: TStrings);
procedure GetWinInfo(wnd: HWND; ParentNode: TTreeNode);
procedure GetWinInfoStyle(wnd: HWND; ParentNode: TTreeNode);
procedure GetWinInfoExtendedStyle(wnd: HWND; ParentNode: TTreeNode);
procedure EnableSavePas;
procedure EnableWndInput;
public
@ -76,7 +78,6 @@ var
node1, node2: TTreeNode;
childlist: TList;
EnumParams: TEnumParams;
style, exstyle: integer;
parentWnd: HWND;
itemtext: array [0..300] of char;
begin
@ -92,8 +93,6 @@ begin
GetWindowRect(wnd, R1);
Windows.GetClientRect(wnd, R2);
GetClassName(wnd, class_name, 100);
style := GetWindowLong(wnd, GWL_STYLE);
exstyle := GetWindowLong(wnd, GWL_EXSTYLE);
parentWnd := GetParent(wnd);
EnumParams.List := childlist;
EnumParams.ParentWnd := wnd;
@ -105,17 +104,8 @@ begin
AddChild(ParentNode, 'Caption = ' + Text);
AddChild(ParentNode, 'Class name = ' + class_name);
AddChild(ParentNode, 'Parent Handle = ' + IntToStr(parentWnd));
node1 := AddChild(ParentNode, 'Style');
AddChild(node1, 'Value = ' + IntToStr(style));
for i := Low(WindowStyle) to High(WindowStyle) do
if ((style and WindowStyle[i]) = WindowStyle[i]) then
AddChild(node1, WindowStyleName[i]);
node1 := AddChild(ParentNode, 'Extended Style');
AddChild(node1, 'Value = ' + IntToStr(exstyle));
for i := Low(WindowStyle) to High(WindowStyle) do
if ((style and ExtendedWindowStyle[i]) = ExtendedWindowStyle[i]) then
AddChild(node1, ExtendedWindowStyleName[i]);
GetWinInfoStyle(wnd, ParentNode);
GetWinInfoExtendedStyle(wnd, ParentNode);
node1 := AddChild(ParentNode, 'Placement');
AddChild(node1, 'Left = ' + IntToStr(R1.Left));
AddChild(node1, 'Top = ' + IntToStr(R1.Top));
@ -150,6 +140,50 @@ begin
childlist.Free;
end;
procedure TMainForm.GetWinInfoStyle(wnd: HWND; ParentNode: TTreeNode);
var
style: Integer;
list: TStringList;
node1: TTreeNode;
i: Integer;
begin
style := GetWindowLong(wnd, GWL_STYLE);
list := GetWindowStyleNames(style);
with Results.TreeView1.Items do
begin
node1 := AddChild(ParentNode, 'Style');
AddChild(node1, 'Value = ' + IntToStr(style));
for i := 0 to list.Count - 1 do
AddChild(node1, list[i]);
end;
list.Free();
end;
procedure TMainForm.GetWinInfoExtendedStyle(wnd: HWND; ParentNode: TTreeNode);
var
style: Integer;
list: TStringList;
node1: TTreeNode;
i: Integer;
begin
style := GetWindowLong(wnd, GWL_EXSTYLE);
list := GetExtendedWindowStyleNames(style);
with Results.TreeView1.Items do
begin
node1 := AddChild(ParentNode, 'Extended Style');
AddChild(node1, 'Value = ' + IntToStr(style));
for i := 0 to list.Count - 1 do
AddChild(node1, list[i]);
end;
list.Free();
end;
procedure TMainForm.InformationClick(Sender: TObject);
var
wnd: HWND;