📄 menu.pas
字号:
unit Menu;
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
MainImage: TImage;
BackImage: TImage;
procedure MainImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure MainImageClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
M_x,M_y:integer;//保存当前鼠标位置
implementation
{$R *.DFM}
//处理鼠标在MainImage上的移动事件
procedure TForm1.MainImageMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
M_x:=X;
M_y:=Y;
if((x>224) and (x<313) and (y>208) and (y<249)) then//在“进入”项的区域内
begin
MainImage.Canvas.CopyRect(Rect(224,208,313,249),BackImage.canvas,Rect(224,208,313,249));
end
else
if((x>224) and (x<313) and (y>264) and (y<297)) then //在“返回”项的区域内
begin
MainImage.Canvas.CopyRect(Rect(224,264,313,297),BackImage.canvas,Rect(224,264,313,297));
end
else //其他的范围,则调用主图恢复原状。
begin
MainImage.Picture.LoadFromFile('main.bmp');
end;
end;
//处理鼠标在MainImage上的单击事件
procedure TForm1.MainImageClick(Sender: TObject);
begin
if((M_x>224) and (M_x<313) and (M_y>208) and (M_y<249)) then
ShowMessage('进入');//在进入项的区域内,执行“进入”项功能
if((M_x>224) and (M_x<313) and (M_y>264) and (M_y<297)) then
begin
ShowMessage('返回');//在"返回"项的区域内,执行“返回”项功能
close;
end;
end;
//窗体创建时,装载图形文件
procedure TForm1.FormCreate(Sender: TObject);
begin
MainImage.Picture.LoadFromFile('main.bmp');//主菜单图
BackImage.Picture.LoadFromFile('bmain.bmp');//主菜单背景图
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -