WM_TIMER in subclassing BUTTON
I make Subclassing button class.
.. example, Mybutton m_button;
File Name are Mybutton.cpp and Mybutton.h
, include CMybutton Class.
and In ClassWizard, I make event, WM_TIMER.
but the event not occur WM_TIMER in subclassing
button class.
Why not???
?? plz help me...
^^
Re: WM_TIMER in subclassing BUTTON
You mean that the class wizard does not add the right code to your source files, or that the WM_TIMER event is not received in your CMyButton OnTimer() function?
Re: WM_TIMER in subclassing BUTTON
dear..
Of course, i write..
1. WM_TIMER envet function : On_Timer..
MessageBox("Test Message");
2. WM_CREATE envet function : On_Create;
SetTime(1, 500, NULL );
in subclassing class files.... ( in classWiazrd )
but it's not display messagebox
In Subclassing class, WM_TIMER event ?? occur or not occur.... ??
ps : i'm poor at english sorry...
^^
Re: WM_TIMER in subclassing BUTTON
Can you please publish the relevant pieces of your source code.
1) class definition
2) Message map
3) OnCreate function
4) OnTimer function
please
Sally
Re: WM_TIMER in subclassing BUTTON
Please do not reply to this email. This is an automated response
Can you please publish the relevant pieces of your source code.
1) class definition
CMyButton class
2) Message map
By ClassWizard..
3) OnCreate function
CMyButton::OnCreate()
{
SetTimer(1, 500 , NULL );
.....
}
4) OnTimer function
CMyButton::OnTimer()
{
MessageBox("Test MessageBox");
......
}
in Subclassing Fils..
^^
Re: WM_TIMER in subclassing BUTTON
Your code should look look similar to the following:
//...
// MyButton.h
//...
// CMyButton window
class CMyButton : public CButton
{
// Construction
public:
CMyButton();
// Attributes
public:
// Operations
public:
void StartTimer();
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyButton)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CMyButton();
// Generated message map functions
protected:
//{{AFX_MSG(CMyButton)
afx_msg void OnTimer(UINT nIDEvent);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
// Mybutton.cpp
//...
#define TIMER_MYTIMER 101
//...
BEGIN_MESSAGE_MAP(CMyButton, CButton)
//{{AFX_MSG_MAP(CMyButton)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyButton message handlers
void CMyButton::StartTimer()
{
SetTimer(TIMER_MYTIMER, 1000, NULL);
}
void CMyButton::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
if (nIDEvent == TIMER_MYTIMER)
{
KillTimer(TIMER_MYTIMER);
TRACE("Timer message received in CMyButton\n");
}
else
CButton::OnTimer(nIDEvent);
}
Pay close attention to the message map sections.
Re: WM_TIMER in subclassing BUTTON
Thanks!! Your Source Code.. ^^
Very Very Thanks..
^^
Re: WM_TIMER in subclassing BUTTON
i would like to know where nukbaby was going wrong?