两个问题

hy1080 2003-11-20 01:08:43
如何让鼠标左右键各弹出一个菜单?
另外是如何把一个图标转成bmp图片.
...全文
31 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
chifengwatch 2003-11-20
  • 打赏
  • 举报
回复
TIcon *pi = new TIcon();
try
{
AnsiString as;
pi->LoadFromFile("c:\\a.ico");
Image1->Width = pi->Width;
Image1->Height = pi->Height;
Image1->Canvas->Draw(0,0,pi);

Image1->Picture->SaveToFile("c:\\a.bmp");
}
__finally
{
delete pi;
}
chifengwatch 2003-11-20
  • 打赏
  • 举报
回复
问题1也可以:
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
Form1->PopupMenu = PopupMenu2 ;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormClick(TObject *Sender)
{
TPoint pt;
GetCursorPos(&pt);
PopupMenu1->Popup( pt.x , pt.y ) ;
}
//---------------------------------------------------------------------------
constantine 2003-11-20
  • 打赏
  • 举报
回复
1 写错了:if(Button==mbLeft)
2.这样你就可以对Bitmap进行保存了
constantine 2003-11-20
  • 打赏
  • 举报
回复
1.判断按下的是鼠标的左键还是右键,用popup控制弹出哪个菜单就可以了。
如:在XXKeyDown事件中
if(Key==ssLeft)
PopupMenu1->Popup(X,Y);

2、例如:
Image1->LoadFromFile("C:\\f4.ico");
Bitmap->Assign(Image1->Picture->Graphic);
或是用Bitmap->Draw(0,0,Image1->Picture->Graphic);
hy1080 2003-11-20
  • 打赏
  • 举报
回复
上面的方法试过了,
但是格式改不了.
在想把抓来的图片放在按钮上
不改格式是不行的
netsys2 2003-11-20
  • 打赏
  • 举报
回复
问题2:

抓一个Image,加载一幅.ico

然后Image1->Picture->SaveToFile("xx.bmp");
netsys2 2003-11-20
  • 打赏
  • 举报
回复
问题1:
先抓两个PopupMenu,各添加一个Item
//在Form的MouseDown事件中
void __fastcall TForm1::FormMouseDown(TObject *Sender, TMouseButton Button,
TShiftState Shift, int X, int Y)
{
if( Button == mbLeft )
PopupMenu1->Popup(X, Y);
if( Button == mbRight )
PopupMenu2->Popup(X, Y);
}

1,221

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧