【菜鸟级问题】OnChange打开窗体
第一天研究delphi,还真有点不明白
如
object MENU_HELP_ABOUT: TMenuItem
Caption = '关于(&A)'
OnClick = MENU_HELP_ABOUTClick \\打开的是一个作者信息的窗体
end
end
那么我想打开的是object frmPlayGold: TfrmPlayGold
object frmPlayGold: TfrmPlayGold Left = 381 Top = 186 BorderIcons = [biSystemMenu, biMinimize] BorderStyle = bsSingle Caption = '新窗体' ClientHeight = 384 ClientWidth = 587 Color = clBtnFace Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = '宋体' Font.Style = [] OldCreateOrder = True ShowHint = True PixelsPerInch = 96 TextHeight = 12 object Label52: TLabel Left = 8 Top = 352 Width = 480 Height = 24 Caption = '免责申明:此功能只可用于个人娱乐,如果使用此功能从事违法国家法规的' + '活动而造成的后果'#13#10'和程序作者无关,如果不同意上述申明请立即删除本' + '程序.' Font.Charset = ANSI_CHARSET Font.Color = clRed Font.Height = -12 Font.Name = '宋体' Font.Style = [] ParentFont = True end
Application.CreateForm(TfrmPlayGold, frmPlayGold);tryfrmPlayGold.show;//或是frmPlayGold.ShowModal;finallyfrmPlayGold.freeend;
[解决办法]
//定义如下一个方法//最后修正MENU_HELP_ABOUT.OnClick = ShowAboutDialog //也可以达到目的!procedure ShowAboutDialog(Sender:TObject);var vForm:TfrmPlayGold;begin vForm := TfrmPlayGold.Create(nil); try vForm.ShowModal; finally vForm.Free; end;end;