UINT SetTimer(
  HWND hWnd,              // handle of window for timer messages
  UINT nIDEvent,          // timer identifier
  UINT uElapse,           // time-out value
  TIMERPROC lpTimerFunc   // address of timer procedure
)其中,lpTimerFunc如何通过回调函数
VOID CALLBACK TimerProc(
  HWND hwnd,     // handle of window for timer messages
  UINT uMsg,     // WM_TIMER message
  UINT idEvent,  // timer identifier
  DWORD dwTime   // current system time
)
来取得???
现在我的这个参数不能为NULL,我不想让应用程序来接收这个WM_TIMER消息。
谢谢!!

解决方案 »

  1.   

    这是说要你自己写一个回调函数,然后把这个函数的地址告诉SETTIMER,然后TIMER到了,你的回调函数就会被调用. 回调函数的格式必须是
    VOID CALLBACK TimerProc(
      HWND hwnd,     // handle of window for timer messages
      UINT uMsg,     // WM_TIMER message
      UINT idEvent,  // timer identifier
      DWORD dwTime   // current system time
    )
    这样.
      

  2.   

    对话框工程
    HWND hwnd;
    void CALLBACK TimerFunc(HWND hwnd, UINT uMsg, UINT idEvent,  DWORD dwTime)
    {
    CString str;
    str.Format("%d", dwTime);
    SetWindowText(hwnd, str);
    }void CDialogProjDlg::OnBnClickedButton1()
    {
    hwnd = m_hWnd;
    ::SetTimer(m_hWnd, 1, 500, (TIMERPROC)TimerFunc);
    }void CDialogProjDlg::OnBnClickedButton2()
    {
    ::KillTimer(m_hWnd, 1);
    }