RT.
自己写了个按钮类.
class CMyButton : public CBitmapButton然后在void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)中
我想通知父窗口该按钮已被按下,该如何做?默认的CMyButton::OnLButtonDown(UINT nFlags, CPoint point)会调用CBitmapButton::OnLButtonDown(nFlags, point).
但有时有反应,有时没反映.能否通过发送WM_COMMAND通知父窗口?这样的话WM_COMMAND的wParam和lParam该怎么获得?比如下面的Control identifier.
wParam (high word) | wParam (low word) | lParam
Control-defined notification code | Control identifier | Handle to the control window
自己写了个按钮类.
class CMyButton : public CBitmapButton然后在void CMyButton::OnLButtonDown(UINT nFlags, CPoint point)中
我想通知父窗口该按钮已被按下,该如何做?默认的CMyButton::OnLButtonDown(UINT nFlags, CPoint point)会调用CBitmapButton::OnLButtonDown(nFlags, point).
但有时有反应,有时没反映.能否通过发送WM_COMMAND通知父窗口?这样的话WM_COMMAND的wParam和lParam该怎么获得?比如下面的Control identifier.
wParam (high word) | wParam (low word) | lParam
Control-defined notification code | Control identifier | Handle to the control window
解决方案 »
- 注册的DATACOMBO 控件的GetBoundText()和GetBoundColumn()这两个函数各返回什么类型的值,他们有什么区别?
- 如何用命令参数启动MFC程序,同时获取命令参数,根据参数执行不同程序
- 显示位图后出现内存不足问题
- 请教打印问题,如何让打印机不走纸。
- 100分请教一个WINSOCKET的问题,请各位进来看看。
- 電腦總是自動重起?
- 阿拉伯数字转换为中文的问题?
- {请教} 从Insert菜单插入的general类怎么在 ClassWizard中看不到?
- InstallShield出现的问题,各路神仙帮忙看看
- 请教TCP/IP通信的入门问题
- 请问VC中如何对WORD文档按页读取?
- VC 按钮激活
HWND hwnd, // handle to window
WM_COMMAND, // the message to send
WPARAM wParam, // notification code and identifier
LPARAM lParam // handle to control (HWND)
);wParam 是按钮的ID
lParam 是按钮的句柄。
但有时有反应,有时没反映. 如果是这种情况的话,发送消息也是一样,最好就是看看为什么会发生这种情况
不需要你在向父窗口发送什么消息。
.h文件class CMyBitmapBtn : public CBitmapButton
{
// Construction
public:
CMyBitmapBtn();// Attributes
public:// Operations
public:// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyBitmapBtn)
//}}AFX_VIRTUAL// Implementation
public:
virtual ~CMyBitmapBtn(); // Generated message map functions
protected:
//{{AFX_MSG(CMyBitmapBtn)
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
//}}AFX_MSG DECLARE_MESSAGE_MAP()
};.cpp
[code=c/c++]
CMyBitmapBtn::CMyBitmapBtn()
{
}CMyBitmapBtn::~CMyBitmapBtn()
{
}
BEGIN_MESSAGE_MAP(CMyBitmapBtn, CButton)
//{{AFX_MSG_MAP(CMyBitmapBtn)
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
// CMyBitmapBtn message handlersvoid CMyBitmapBtn::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox("ButtonDown");
CButton::OnLButtonDown(nFlags, point);
}
[code]对话框的按钮 关联一个 CMyBitmapBtn 类型类型的 变量就行了,
不知道楼主要干啥不用在 CMyBitmapBtn里加 lbuttonDown消息吧???
TO :tttyd (雪影) 天天看你回帖不用上班呀??
void CMyBitmapBtn::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
MessageBox("ButtonDown");
CButton::OnLButtonDown(nFlags, point);
}[/Quote]这里吧,俺的是CBitmapButton::OnLButtonDown(nFlags, point);应该就是这个函数帮俺通知的父窗口吧?
假如想把CBitmapButton::OnLButtonDown(nFlags, point);注释掉,自己发消息给父窗口呢?应该是别的什么地方出问题了.俺再试试.CBitmapButton::OnLButtonDown(nFlags, point);里面应该是发送一个WM_COMMAND消息给父窗口吧,不知怎么实现的..to 1楼:
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
WM_COMMAND, // the message to send
WPARAM wParam, // notification code and identifier
LPARAM lParam // handle to control (HWND)
); wParam 是按钮的ID
lParam 是按钮的句柄。俺就是不懂怎么得到当前自定义按钮类所关联的资源的ID,以为这个类关联了很多IDC_BTN_XXX之类.
就是有时点下去没反应.
有人遇到过么?