📄 versionresourceform.pas
字号:
fVersion : TULargeInteger;
pVersion : TULargeInteger;
flags : TVersionFileFlags;
k : TVersionStringValue;
i : Integer;
begin
inherited;
fInitializing := True;
with ResourceDetails as TVersionInfoResourceDetails do
try
fVersion := FileVersion;
pVersion := ProductVersion;
flags := FileFlags;
// Initialize the form
PropertyListBox1.Properties [prFileVersion].PropertyValue := VersionToString (fVersion);
PropertyListBox1.Properties [prProductVersion].PropertyValue := VersionToString (pVersion);
PropertyListBox1.Properties [prDebug].PropertyValue := ffDebug in flags;
PropertyListBox1.Properties [prInferred].PropertyValue := ffInfoInferred in flags;
PropertyListBox1.Properties [prPatched].PropertyValue := ffPatched in flags;
PropertyListBox1.Properties [prPreRelease].PropertyValue := ffPreRelease in flags;
PropertyListBox1.Properties [prPrivateBuild].PropertyValue := ffPrivateBuild in flags;
PropertyListBox1.Properties [prSpecialBuild].PropertyValue := ffSpecialBuild in flags;
lvVersionStrings.Items.BeginUpdate;
with lvVersionStrings.Items do
try
Clear;
for i := 0 to KeyCount - 1 do
with Add do
begin
k := Key [i];
Caption := k.KeyName;
SubItems.Add (k.Value);
end
finally
EndUpdate
end
finally
fInitializing := False
end
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.actStringDeleteStringExecute |
| |
| Delete the selected version string |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.actStringDeleteStringExecute(Sender: TObject);
var
n : Integer;
begin
if Assigned (lvVersionStrings.Selected) then
begin
AddUndoEntry (rstDeleteString);
n := lvVersionStrings.Selected.Index;
// Delete the string from the resouce
TVersionInfoResourceDetails (ResourceDetails).DeleteKey (n);
// Delete the string from the list view
lvVersionStrings.Selected.Delete;
// Select the next entry in the list after deleting
if n >= lvVersionStrings.Items.Count then
n := lvVersionStrings.Items.Count - 1;
if n >= 0 then
lvVersionStrings.Items.Item [n].Selected := True
end
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.actStringModifyStringExecute |
| |
| Start modifying the version string. Reposition and reveal the |
| hidden memo. |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.actStringModifyStringExecute(Sender: TObject);
begin
if Assigned (lvVersionStrings.Selected) then
begin
fSelectedItem := lvVersionStrings.Selected;
mmoMessage.Top := lvVersionStrings.Selected.DisplayRect (drLabel).Bottom;
mmoMessage.Text := lvVersionStrings.Selected.SubItems [0];
mmoMessage.Visible := True;
mmoMessage.SetFocus
end
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.mmoMessageExit |
| |
| They'v existed the memo. Re-coneal it, and change the modified |
| string valur |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.mmoMessageExit(Sender: TObject);
begin
mmoMessage.Visible := False;
if mmoMessage.CanUndo or fAdding then
begin
if fAdding then
AddUndoEntry (rstAddString)
else
AddUndoEntry (rstChangeString);
// Update the resource
TVersionInfoResourceDetails (ResourceDetails).SetKeyValue (fSelectedItem.Caption, mmoMessage.Text);
// Update the list view
fSelectedItem.SubItems [0] := mmoMessage.Text
end;
fAdding := False;
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.lvVersionStringsEdited |
| |
| They've finished editing the key name. Update the resource |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.lvVersionStringsEdited(Sender: TObject;
Item: TListItem; var S: String);
begin
if s <> Item.Caption then
begin
AddUndoEntry (rstChangeStringName);
TVersionInfoResourceDetails (ResourceDetails).ChangeKey (Item.Caption, s)
end
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.actStringModifyStringNameExecute |
| |
| Start modifying the key name |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.actStringModifyStringNameExecute(
Sender: TObject);
begin
if Assigned (lvVersionStrings.Selected) then
lvVersionStrings.Selected.EditCaption
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.lvVersionStringsDblClick |
| |
| Check where abouts on the list view is being clicked. |
| |
| If a selected item is clicked in the 'Key Name' column, start |
| editing the key name. |
| |
| If a selected item is clicked in the 'String' column, start editing |
| the string value. |
| |
| If no item was selcted, add a new string. |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.lvVersionStringsDblClick(Sender: TObject);
var
p : TPoint;
begin
if Assigned (lvVersionStrings.Selected) then
begin
p := Mouse.CursorPos;
MapWindowPoints (HWND_DESKTOP, lvVersionStrings.Handle, p, 1);
if p.x > lvVersionStrings.Columns [0].Width then
actStringModifyString.Execute
else
actStringModifyStringName.Execute
end
else
actStringAddString.Execute
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.UpdateActions |
| |
| Enable or disable the 'Strings' menu items appropriately |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.UpdateActions;
var
sel : Boolean;
begin
sel := Assigned (lvVersionStrings.Selected) and lvVersionStrings.Focused;
actStringDeleteString.Enabled := sel;
actStringModifyString.Enabled := sel;
actStringModifyStringName.Enabled := sel
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.actStringAddStringExecute |
| |
| Add a new string. Simply add it to the list view, then call Modify |
*----------------------------------------------------------------------*)
procedure TfmVersionResource.actStringAddStringExecute(Sender: TObject);
var
keyName : string;
begin
keyName := GetNewStringName;
with lvVersionStrings.Items.Add do
begin
Caption := keyName;
SubItems.Add ('');
Selected := True;
fAdding := True;
actStringModifyString.Enabled := True;
actStringModifyString.Execute
end
end;
(*----------------------------------------------------------------------*
| TfmVersionResource.GetNewStringName |
| |
| Calculate the default name for new string values. |
*----------------------------------------------------------------------*)
function TfmVersionResource.GetNewStringName: string;
var
m : Integer;
begin
m := 1;
repeat
Result := Format (rstNewString, [m]);
if lvVersionStrings.FindCaption (0, Result, False, True, False) = nil then
break;
Inc (m)
until m = 0
end;
procedure TfmVersionResource.PropertyListBox1PropertyChanged(
Sender: TObject);
begin
SaveFlags
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -