需要一个简单的mfc程序的帮助 [英] need help for a simple mfc program

查看:187
本文介绍了需要一个简单的mfc程序的帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


这是vc ++中的一个简单基本问题,我想将鼠标单击控件添加到视图类中的图标.我在资源中添加了一个图标,并成功显示该图标.现在我想单击该图标,它会打开一个文件.所以我不知道如何向该图标添加对象.请帮帮我.

/Edit M-消息中的交叉发布板 [

Hi,
this is a simple basic question in vc++ ,I want to add mouse click control to an icon in view class. i added an icon in resource and succeeded to display the icon. now i want to click on that icon and it opens a file. so i dont know how to add object to that icon. Please help me.

/Edit M - Cross posting in Message board[^]

推荐答案

为什么不将用户绘制的按钮与按钮上的图标设计一起使用?那应该可以让您访问所有正常的按钮交互.
Why not use a user drawn button with the icon design on the button? That should give you access to all normal button interaction.


这意味着没有解决方案可以将鼠标单击控件赋予在视图类中绘制的矩形或图标.对话为主.因此,在OnDraw()中,我先绘制一个位图,然后在该位图上绘制一个矩形.然后我在该矩形上附加了一个图标.现在我想要的是,只要有人单击该图标(矩形区域),就应该打开一个文件.
that means no solution to give mouse click control to a rectangle or an icon drawn in a view class.. I am not supposed to use dialogue based. So in OnDraw() i draw a bitmap then a rectangle over bitmap. then i attached an Icon to that rectangle. Now what i want is when ever some one clicks on the icon(rectangle area), a file should be opened..


您可以处理WM_LBUTTONDOWN.
它会为您提供最后一次左键单击的坐标.
只需检查它们是否在矩形中即可.
You can handle WM_LBUTTONDOWN.
it gives you the coordinate of the last left-button click.
Just check if they are into the rectangle.


这篇关于需要一个简单的mfc程序的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆