关于ModifyMenu的问题!(20分)

  • 主题发起人 主题发起人 haibin_song
  • 开始时间 开始时间
H

haibin_song

Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus;

type
TFormColor = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
R: TMenuItem;
Y: TMenuItem;
B: TMenuItem;
H: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
FormColor: TFormColor;
Bmp1,Bmp2,Bmp3:TBitMap;
i:Integer;
implementation

{$R *.dfm}

procedure TFormColor.FormCreate(Sender: TObject);
begin
Bmp1:=TBitMap.Create;// 创建对象
Bmp2:=TBitMap.Create;
Bmp3:=TBitMap.Create;
Bmp1.LoadFromFile('F:/pic/R.bmp'); // 装入位图文件
Bmp2.LoadFromFile('F:/pic/Y.bmp');
Bmp3.LoadFromFile('F:/pic/B.bmp');
// Bmp4.LoadFromFile('F:/pic/H.bmp');
// 修改菜单的设置
ModifyMenu(FormColor.Handle,R.MenuIndex,MF_BYPOSITION or MF_BITMAP,R.Command,Pointer(Bmp1.Handle));
ModifyMenu(FormColor.Handle,Y.MenuIndex,MF_BYPOSITION or MF_BITMAP,Y.Command,Pointer(Bmp2.Handle));
ModifyMenu(FormColor.Handle,B.MenuIndex,MF_BYPOSITION or MF_BITMAP,B.Command,Pointer(Bmp3.Handle));
ModifyMenu(FormColor.Handle,R.MenuIndex,MF_BYPOSITION or MF_BITMAP,R.Command,Pointer(Bmp1.Handle));
ShowMessage(IntToStr(i));
//ModifyMenu(FormColor.Handle,H.MenuIndex,MF_BYPOSITION or MF_BITMAP,H.Command,Pointer(Bmp4.Handle));
end;

procedure TFormColor.FormDestroy(Sender: TObject);
begin
Bmp1.FreeImage;
Bmp2.FreeImage;
Bmp3.FreeImage;
end;

end.

我想实现用位图做为菜单项,但是为什么实现不了,哪里出了问题?
 
试试API 吧!:)
 
我API还不懂呢,我才开始学,我想知道,上面的代码哪里出了错
 
有啥报错信息发给我!
用 SetMenuItemBitmaps试试!
 
接受答案了.
 
后退
顶部