CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    May 1999
    Posts
    10

    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...




    ^^

  2. #2
    Join Date
    May 1999
    Posts
    6

    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?


  3. #3
    Join Date
    May 1999
    Posts
    10

    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...


    ^^

  4. #4
    Join Date
    May 1999
    Location
    Sydney, Australia
    Posts
    420

    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


  5. #5
    Join Date
    May 1999
    Posts
    10

    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..


    ^^

  6. #6
    Join Date
    May 1999
    Posts
    6

    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.


  7. #7
    Join Date
    May 1999
    Posts
    10

    Re: WM_TIMER in subclassing BUTTON


    Thanks!! Your Source Code.. ^^

    Very Very Thanks..


    ^^

  8. #8
    Join Date
    May 1999
    Posts
    78

    Re: WM_TIMER in subclassing BUTTON

    i would like to know where nukbaby was going wrong?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured