当您使用右键单击mainmenu或Form1时出现问题,它可以工作并打开具有Forest,Sea,Clouds的特定子菜单,并忽略图片,退出菜单。 在这里你可以看到MainMenu:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
Menus;
type
{ TForm1 }
TForm1 = class(TForm)
Image1: TImage;
MainMenu1: TMainMenu;
MenuItem1: TMenuItem;
MenuItem2: TMenuItem;
MenuItem3: TMenuItem;
MenuItem4: TMenuItem;
MenuItem5: TMenuItem;
MenuItem6: TMenuItem;
MenuItem7: TMenuItem;
OpenDialog1: TOpenDialog;
Panel1: TPanel;
procedure FormCreate(Sender: TObject);
procedure Image1Click(Sender: TObject);
procedure MenuItem1Click(Sender: TObject);
procedure MenuItem2Click(Sender: TObject);
procedure MenuItem4Click(Sender: TObject);
procedure MenuItem5Click(Sender: TObject);
procedure MenuItem6Click(Sender: TObject);
procedure MenuItem7Click(Sender: TObject);
procedure Panel1Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
end;
procedure TForm1.Image1Click(Sender: TObject);
begin
end;
procedure TForm1.MenuItem1Click(Sender: TObject);
begin
end;
procedure TForm1.MenuItem2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.MenuItem4Click(Sender: TObject);
begin
close;
end;
procedure TForm1.MenuItem5Click(Sender: TObject);
begin
Image1.Picture.LoadFromFile('jura.jpg');
end;
procedure TForm1.MenuItem6Click(Sender: TObject);
begin
Image1.Picture.LoadFromFile('forest.jpg');
end;
procedure TForm1.MenuItem7Click(Sender: TObject);
begin
Image1.Picture.LoadFromFile('clouds.jpg');
end;
procedure TForm1.Panel1Click(Sender: TObject);
begin
end;
end.
答案 0 :(得分:0)
通过添加popupmenu解决了我的问题,现在一切正常。