📄 peresview.pas
字号:
RowHeights[I + 1] := Min(Max(MinGraphRowHeight, MaxRowHeight + 4), MaxGraphRowHeight);
TotalMaxRowHeight := Max(TotalMaxRowHeight, MaxRowHeight);
end;
finally
SendMessage(Handle, WM_SETREDRAW, 1, 0);
Invalidate;
end;
end;
end;
procedure TPeResViewChild.GraphDrawGridDrawCell(Sender: TObject; ACol,
ARow: Integer; Rect: TRect; State: TGridDrawState);
var
Text: string;
Item: TPeResItem;
I, W: Integer;
DrawRect: TRect;
begin
with GraphDrawGrid do
begin
if ARow = 0 then
with Canvas do
begin
case ACol of
0: Text := 'Name';
1: Text := 'Graphic';
end;
Brush.Color := clBtnFace;
Font.Color := clBtnText;
Dec(Rect.Bottom, 2);
Dec(Rect.Right);
FillRect(Rect);
TextRect(Rect, Rect.Left + 6, Rect.Top + 2, Text);
DrawEdge(Handle, Rect, EDGE_ETCHED, BF_BOTTOMRIGHT or BF_FLAT);
Pen.Color := Color;
Polyline([Point(Rect.Right, Rect.Top), Point(Rect.Right, Rect.Bottom),
Point(Rect.Left, Rect.Bottom)]);
Inc(Rect.Bottom);
MoveTo(Rect.Left, Rect.Bottom);
LineTo(Rect.Right, Rect.Bottom);
Pen.Color := clBtnFace;
Inc(Rect.Bottom);
MoveTo(Rect.Left, Rect.Bottom);
LineTo(Rect.Right, Rect.Bottom);
end else
begin
if (gdSelected in State) and Focused then
begin
Canvas.Brush.Color := clHighlight;
Canvas.Font.Color := clHighlightText;
Canvas.FillRect(Rect);
DrawFocusRect(Canvas.Handle, Rect);
end else
begin
Canvas.Brush.Color := Color;
Canvas.Font.Color := Font.Color;
Canvas.FillRect(Rect);
end;
InflateRect(Rect, -1, -1);
Item := FCurrentDir[ARow - 1];
case ACol of
0:Canvas.TextRect(Rect, Rect.Left + 2, Rect.Top + 2, Item.ResName);
1:begin
W := 0;
if not Item.IsList then
begin
FTempGraphic.Assign(Item);
with FTempGraphic do
SetRect(DrawRect, Rect.Left, Rect.Top, Rect.Left + Width, Rect.Top + Height);
if not RectIncludesRect(DrawRect, Rect) then
begin
DrawRect.Right := Min(DrawRect.Right, Rect.Right);
DrawRect.Bottom := Min(DrawRect.Bottom, Rect.Bottom);
Canvas.StretchDraw(DrawRect, FTempGraphic.Graphic);
end
else
Canvas.Draw(Rect.Left + 2, Rect.Top + 2, FTempGraphic.Graphic);
end else
for I := 0 to Item.ItemCount - 1 do
begin
FTempGraphic.Assign(Item[I]);
Canvas.Draw(Rect.Left + 2 + W, Rect.Top + 2, FTempGraphic.Graphic);
Inc(W, FTempGraphic.Width + 5);
end;
end;
end;
end;
end;
end;
procedure TPeResViewChild.AviPlay1Execute(Sender: TObject);
begin
with Animate1 do
Play(1, FrameCount, 1);
AviStop1.Enabled := True;
AviPlay1.Enabled := False;
end;
procedure TPeResViewChild.AviStop1Execute(Sender: TObject);
begin
Animate1.Stop;
AviStop1.Enabled := False;
end;
procedure TPeResViewChild.Animate1Stop(Sender: TObject);
begin
AviPlay1.Enabled := True;
AviStop1.Enabled := False;
end;
procedure TPeResViewChild.StringsListViewSelectItem(Sender: TObject;
Item: TListItem; Selected: Boolean);
begin
if Selected then DetailedStringMemo.Text := Item.SubItems[0];
end;
procedure TPeResViewChild.Animate1Open(Sender: TObject);
begin
with Animate1 do
AviStatusBar.Panels[0].Text := Format(RsAviStatus, [FrameWidth, FrameHeight,
FrameCount]);
end;
procedure TPeResViewChild.Animate1Close(Sender: TObject);
begin
AviStatusBar.Panels[0].Text := '';
end;
procedure TPeResViewChild.AviBkColor1Execute(Sender: TObject);
begin
with ColorDialog1 do
begin
CustomColors.Values['ColorA'] := Format('%.6x', [ColorToRGB(clBtnFace)]);
Color := Animate1.Color;
if Execute then Animate1.Color := Color;
end;
end;
procedure TPeResViewChild.UpdateSelected;
function SpecialDirectoryView: Boolean;
begin
Result := True;
case FCurrentDir.Kind of
rkBitmap, rkCursor, rkIcon:
begin
CreateGraphicList(FCurrentDir);
PageControl1.ActivePage := GraphDirTab;
end;
rkString:
begin
CreateStringsList(TPeResString(FCurrentDir));
PageControl1.ActivePage := StringsTab;
end;
else
Result := False;
end;
end;
procedure DefaultDirectoryView;
begin
DirListView.Items.Count := FCurrentDir.ItemCount;
DirListView.Invalidate;
PageControl1.ActivePage := DirTab;
end;
function SpecialDetailView: Boolean;
begin
Result := True;
case FSelectedItem.Kind of
rkAccelerator:
begin
TextRichEdit.Lines.Assign(TPeResAccelerator(FSelectedItem));
PageControl1.ActivePage := TextTab;
end;
rkAvi:
begin
Animate1.Assign(FSelectedItem);
PageControl1.ActivePage := AviTab;
end;
rkBitmap, rkIcon, rkCursor:
begin
GraphImage.Picture.Assign(FSelectedItem);
if GraphImage.Picture.Graphic is TBitmap then
GraphImage.Picture.Bitmap.Transparent := True;
with TPeResUnkGraphic(FSelectedItem).GraphicProperties do
GraphStatusBar.Panels[0].Text := Format(RsGraphicStatus, [Width, Height, BitsPerPixel]);
PageControl1.ActivePage := GraphTab;
end;
rkString:
begin
CreateStringsList(TPeResString(FSelectedItem));
PageControl1.ActivePage := StringsTab;
end;
rkHTML:
begin
WebBrowser1.Navigate(TPeResHTML(FSelectedItem).ResPath);
PageControl1.ActivePage := HTMLTab;
end;
rkData:
if TPeResRCData(FSelectedItem).DataKind <> dkUnknown then
begin
TextRichEdit.Lines.Assign(TPeResRCData(FSelectedItem));
PageControl1.ActivePage := TextTab;
end else
Result := False;
{ rkDialog:
begin
DialogTestBtn.Enabled := TPeResDialog(FSelectedItem).CanShowDialog;
PageControl1.ActivePage := DialogTab;
end;} { TODO : Check for dialog templates }
rkMessageTable:
begin
CreateStringsList(TPeResUnkStrings(FSelectedItem));
PageControl1.ActivePage := StringsTab;
end;
rkVersion:
begin
TextRichEdit.Lines.Assign(TPeResVersion(FSelectedItem));
PageControl1.ActivePage := TextTab;
end;
else
Result := False;
end;
end;
procedure DefaultDetailView;
begin
HexDumpListView.Items.Count := (FSelectedItem.Size - 1) div 16 + 1;
HexDumpListView.Invalidate;
PageControl1.ActivePage := HexDumpTab;
end;
begin
FSelectedItem := TPeResItem(FSelectedNode.Data);
FCurrentDir := FSelectedItem;
if FSelectedNode.Level = 0 then
begin
// FCurrentDir := FSelectedItem;
if (not FShowSpecialDirView) or (not SpecialDirectoryView) then
DefaultDirectoryView;
end else
begin
if FSelectedItem.IsList then
begin
// FCurrentDir := FSelectedItem;
DefaultDirectoryView;
end else
begin
if FShowAsHexView or (not SpecialDetailView) then
DefaultDetailView;
end;
end;
end;
function TPeResViewChild.CanSaveResource: Boolean;
begin
Result := Assigned(FSelectedItem) and not FSelectedItem.IsList and
ResourceTreeView.Focused;
end;
procedure TPeResViewChild.ResourceTreeViewExpanding(Sender: TObject;
Node: TTreeNode; var AllowExpansion: Boolean);
var
N, L: Integer;
ListNode, ItemNode: TTreeNode;
Item, RootItem: TPeResItem;
begin
if Node.GetFirstChild = nil then with ResourceTreeView do
begin
Items.BeginUpdate;
try
RootItem := TPeResItem(Node.Data);
for N := 0 to RootItem.ItemCount - 1 do
begin
Item := RootItem[N];
ListNode := Items.AddChildObject(Node, Item.ResName, Item);
if Item.IsList then
begin
ListNode.ImageIndex := icoFolderShut;
ListNode.SelectedIndex := icoFolderOpen;
for L := 0 to Item.ItemCount - 1 do
begin
ItemNode := Items.AddChildObject(ListNode, Item[L].ResName, Item[L]);
ItemNode.ImageIndex := icoResItem;
ItemNode.SelectedIndex := icoResItem;
end;
end else
begin
ListNode.ImageIndex := icoResItem;
ListNode.SelectedIndex := icoResItem;
end;
end;
finally
Items.EndUpdate;
end;
end;
end;
procedure TPeResViewChild.SaveResource;
var
FileStream: TFileStream;
begin
with SaveDialog1, (FSelectedItem as TPeResUnknown) do
begin
Filter := Format('*.%s files|*.%s', [FileExt, FileExt]);
FileName := ResName + '.' + FileExt;
if Execute then
begin
FileStream := TFileStream.Create(FileName, fmCreate);
try
SaveToStream(FileStream);
finally
FileStream.Free;
end;
end;
end;
end;
procedure TPeResViewChild.DialogTestBtnClick(Sender: TObject);
var
Res: Integer;
begin
with ResourceTreeView do
while True do
begin
with TPeResDialog(FSelectedItem) do
if CanShowDialog then
Res := ShowDialog(Application.Handle)
else
Res := 1;
if (Res = 1) and (Selected.GetNextSibling <> nil) then
begin
Selected := Selected.GetNextSibling;
Selected.MakeVisible;
ResourceTreeView.Update;
end else
Break;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -