?? unt_frmmenudesign.pas
字號:
mChecked := 'False';
end;
try
mDefault := Attributes[menuDefault];
except
mDefault := 'False';
end;
try
mEnabled := Attributes[menuEnabled];
except
mEnabled := 'True';
end;
try
mGroupIndex := Attributes[menuGroupIndex];
except
mGroupIndex := '0';
end;
try
mHelpContext := Attributes[menuHelpContext];
except
mHelpContext := '0';
end;
try
mHint := Attributes[menuHint];
except
mHint := '';
end;
try
mImageIndex := Attributes[menuImageIndex];
except
mImageIndex := '-1';
end;
try
mRadioItem := Attributes[menuRadioItem];
except
mRadioItem := 'False';
end;
try
mShortCut := Attributes[menuShortCut];
except
mShortCut := '(None)';
end;
try
mTag := Attributes[menuTag];
except
mTag := '0';
end;
try
mVisible := Attributes[menuVisible];
except
mVisible := 'True';
end;
//wangji 20030901
try
mMenuID := Attributes[menuMenuID];
except
mMenuID := '00';
end;
end;
TempNode := TrvMenu.Items.AddChildObject(CurItem, MenuNode.Attributes[menuCaption], CurP);
if MenuNode.HasChildNodes then
DynamicTreeNode(TempNode, MenuNode);
end;
end;
end;
procedure TFrmMenuDesign.DynamicTreeNode(CurItem: TTreeNode; CurNode: IXMLNode);
var
j: Integer;
TempNode: TTreeNode;//臨時創建的菜單項
MenuNode: IXMLNode; //臨時使用的XML節點
CurP: PMNData;
begin
for j := 0 to CurNode.ChildNodes.Count - 1 do
begin
if CurNode.ChildNodes[j].NodeType = ntElement then
begin
MenuNode := CurNode.ChildNodes[j];
New(CurP);
with CurP^, MenuNode do
begin
try
mAutoCheck := Attributes[menuAutoCheck];
except
mAutoCheck := 'False';
end;
try
mAutoHotkeys := Attributes[menuAutoHotkeys];
except
mAutoHotkeys := 'maParent';
end;
try
mAutoLineReduction:= Attributes[menuAutoLineReduction];
except
mAutoLineReduction := 'maParent';
end;
try
mBreak := Attributes[menuBreak];
except
mBreak := 'mbNone';
end;
try
mCaption := Attributes[menuCaption];
except
mCaption := '新菜單項';
end;
try
mChecked := Attributes[menuChecked];
except
mChecked := 'False';
end;
try
mDefault := Attributes[menuDefault];
except
mDefault := 'False';
end;
try
mEnabled := Attributes[menuEnabled];
except
mEnabled := 'True';
end;
try
mGroupIndex := Attributes[menuGroupIndex];
except
mGroupIndex := '0';
end;
try
mHelpContext := Attributes[menuHelpContext];
except
mHelpContext := '0';
end;
try
mHint := Attributes[menuHint];
except
mHint := '';
end;
try
mImageIndex := Attributes[menuImageIndex];
except
mImageIndex := '-1';
end;
try
mRadioItem := Attributes[menuRadioItem];
except
mRadioItem := 'False';
end;
try
mShortCut := Attributes[menuShortCut];
except
mShortCut := '(None)';
end;
try
mTag := Attributes[menuTag];
except
mTag := '0';
end;
try
mVisible := Attributes[menuVisible];
except
mVisible := 'True';
end;
//wangji 20030901
try
mMenuID := Attributes[menuMenuID];
except
mMenuID := '00';
end;
end;
TempNode := TrvMenu.Items.AddChildObject(CurItem, MenuNode.Attributes[menuCaption], CurP);
if MenuNode.HasChildNodes then
DynamicTreeNode(TempNode, MenuNode);
end;
end;
end;
procedure TFrmMenuDesign.InitImageList;
var
i: Integer;
TempItmEx: TComboExItem;
begin
CmbImageIndex.Clear;
for i := 0 to ImageList1.Count - 1 do
begin
TempItmEx := CmbImageIndex.ItemsEx.Add;
with TempItmEx do
begin
Caption := IntToStr(i);
ImageIndex := i;
end;
end;
end;
procedure TFrmMenuDesign.OpenXMLMenuFile(pXMLFile: string);
var
TempNode: TTreeNode;
begin
with TempXMLDoc do
begin
Active := False;
LoadFromFile(pXMLFile);
Active := True;
end;
FreePMNData;
TempNode := InitXMLMenu(pXMLFile);
try
XML2Tree(TempNode, TempXMLDoc);
except
MessageDlg(PChar('菜單文件'+pXMLFile+'格式無效!'), mtConfirmation, [mbOK], 0);
end;
TempNode.Expanded := True;
isModifed := False;
end;
//----------------------------------------------------------------
procedure TFrmMenuDesign.FormCreate(Sender: TObject);
begin
with StrGrdInspector do
begin
Width := 302;
Height := 325;
DefaultRowHeight := 18;
ColWidths[0] := 110;
ColWidths[1] := 190;
Cells[0, 0] := 'AutoCheck ';
Cells[0, 1] := 'AutoHotkeys ';
Cells[0, 2] := 'AutoLineReduction';
Cells[0, 3] := 'Break ';
Cells[0, 4] := 'Caption ';
Cells[0, 5] := 'Checked ';
Cells[0, 6] := 'Default ';
Cells[0, 7] := 'Enabled ';
Cells[0, 8] := 'GroupIndex ';
Cells[0, 9] := 'HelpContext ';
Cells[0, 10]:= 'Hint ';
Cells[0, 11]:= 'ImageIndex ';
Cells[0, 12]:= 'RadioItem ';
Cells[0, 13]:= 'ShortCut ';
Cells[0, 14]:= 'Tag ';
Cells[0, 15]:= 'Visible ';
//wangji 20030901:
Cells[0, 16]:= 'MenuID ';
CmbAutoCheck.Width := ColWidths[1];
CmbAutoHotkeys.Width := ColWidths[1];
CmbBreak.Width := ColWidths[1];
CmbImageIndex.Width := ColWidths[1];
CmbShortCut.Width := ColWidths[1];
CmbEvntParam.Width := ColWidths[1];
end;
isModifed := False;
end;
procedure TFrmMenuDesign.StrGrdInspectorSelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var
TempStr, TempTag: string;
Rect: TRect;
begin
with StrGrdInspector do
begin
if ACol = 1 then
begin
TempStr := StrGrdInspector.Cells[ACol, ARow];
TempTag := StrGrdInspector.Cells[1, 14];
if ARow <> 14 then
begin
TempTag := Trim(TempTag);
try
StrToInt(TempTag);
except
TempTag := '-1';
end;
StrGrdInspector.Cells[1, 14] := TempTag;
end;
Rect := StrGrdInspector.CellRect(ACol, ARow);
case ARow of
4,8,9,10,16:
begin
Options := Options + [goEditing];
end;
0, 5, 6, 7, 12, 15:
begin
CmbAutoCheck.Left := StrGrdInspector.Left + Rect.Left;
CmbAutoCheck.Top := StrGrdInspector.Top + Rect.Top;
CmbAutoCheck.Text := TempStr;
CmbAutoCheck.Visible := True;
CmbAutoCheck.SetFocus;
Options := Options - [goEditing];
end;
1, 2:
begin
CmbAutoHotkeys.Left := StrGrdInspector.Left + Rect.Left;
CmbAutoHotkeys.Top := StrGrdInspector.Top + Rect.Top;
CmbAutoHotkeys.Text := TempStr;
CmbAutoHotkeys.Visible := True;
CmbAutoHotkeys.SetFocus;
Options := Options - [goEditing];
end;
3:
begin
CmbBreak.Left := StrGrdInspector.Left + Rect.Left;
CmbBreak.Top := StrGrdInspector.Top + Rect.Top;
CmbBreak.Text := TempStr;
CmbBreak.Visible := True;
CmbBreak.SetFocus;
Options := Options - [goEditing];
end;
11:
begin
if ImageList1.Count > 0 then
begin
CmbImageIndex.Left := StrGrdInspector.Left + Rect.Left;
CmbImageIndex.Top := StrGrdInspector.Top + Rect.Top;
CmbImageIndex.Text := TempStr;
CmbImageIndex.Visible := True;
CmbImageIndex.SetFocus;
end;
Options := Options - [goEditing];
end;
13:
begin
CmbShortCut.Left := StrGrdInspector.Left + Rect.Left;
CmbShortCut.Top := StrGrdInspector.Top + Rect.Top;
CmbShortCut.Text := TempStr;
CmbShortCut.Visible := True;
CmbShortCut.SetFocus;
Options := Options - [goEditing];
end;
14:
begin
if CmbEvntParam.Items.Count > 0 then
begin
CmbEvntParam.Left := StrGrdInspector.Left + Rect.Left;
CmbEvntParam.Top := StrGrdInspector.Top + Rect.Top;
try
CmbEvntParam.ItemIndex := StrToInt(TempStr);
except
CmbEvntParam.ItemIndex := -1;
end;
CmbEvntParam.Visible := True;
CmbEvntParam.SetFocus;
Options := Options - [goEditing];
end else
Options := Options + [goEditing];
end;
else
InitView;
Options := Options - [goEditing];
end;
end else
Options := Options - [goEditing];
end;
end;
procedure TFrmMenuDesign.CmbAutoCheckExit(Sender: TObject);
begin
if TComboBox(Sender).Text <> '' then
begin
if TComboBox(Sender).Items.IndexOf(TComboBox(Sender).Text) < 0 then
TComboBox(Sender).Text := TComboBox(Sender).Items.Strings[0];
StrGrdInspector.Cells[1, StrGrdInspector.Row] := TComboBox(Sender).Text;
end;
TComboBox(Sender).Visible := False;
end;
procedure TFrmMenuDesign.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
FreePMNData;
end;
procedure TFrmMenuDesign.TrvMenuChange(Sender: TObject; Node: TTreeNode);
procedure TreMenuView(isZero: Boolean);
begin
StrGrdInspector.Enabled := isZero;
SbtnSaveMod.Enabled := isZero;
SbtnSub.Enabled := isZero;
SbtnDelete.Enabled := isZero;
SbtnInsert.Enabled := isZero;
I1.Enabled := isZero;
Sub1.Enabled := isZero;
Delete1.Enabled := isZero;
end;
begin
if TrvMenu.Selected = nil then Exit;
TrvMenu.SetFocus;
PMNData2View(PMNData(TrvMenu.Selected.Data));
TreMenuView(not TrvMenu.Items[0].Selected);
end;
procedure TFrmMenuDesign.TrvMenuMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
APoint: TPoint;
ASelNode: TTreeNode;
procedure TreMenuEnable(isLeaf: Boolean);
begin
SbtnSub.Enabled := isLeaf;
Sub1.Enabled := isLeaf;
end;
begin
ASelNode := TrvMenu.GetNodeAt(X, Y);
if ASelNode = nil then Exit;
if Button = mbRight then
begin
TrvMenu.Selected := ASelNode;
APoint := TrvMenu.ClientToScreen(Point(x, y));
PopupMenu1.Popup(APoint.x, APoint.y);
end;
end;
procedure TFrmMenuDesign.N1Click(Sender: TObject);
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -