在VC的Cwnd中用SetTimer, KillTimer和OnTimer可以很简单的设置出定时器
但在自己写的全局函数中要设置一个定时器,它的消息机制如何传递呢?
急切知道如何应用!
有原代码更好!
[email protected]
谢谢
但在自己写的全局函数中要设置一个定时器,它的消息机制如何传递呢?
急切知道如何应用!
有原代码更好!
[email protected]
谢谢
解决方案 »
- error C2509: 'GetEventSinkMap' : member function not declared
- 如何将视频数据保存为AVI文件?
- 远程注入的函数 能调用那些api?
- 如何在电脑上生成一个盘符,映射网络硬盘
- 菜问题,控件ID的
- WIN32 API编程中,添加按钮后,就不再相应键盘消息,为什么?
- !!!!!!!!怎么样在VC中不读数据库,直接构造结果集Recordset!!!!!!!(靠!我就不信VB搞定的东西VC会搞不定!)
- 怎样能把位图以16进制形式显示在文本显示区内?
- 关于打印机的边距
- 修改系统菜单的遗憾
- bmp格式与ico的格式是一样的,我怎么将HICON转化为HBITMAP呢?
- 请问DEF文件中DllGetClassObject @1 PRIVATE,PRIVATE是什么意思?
1。m_nTimerId = SetTimer(1, 50, TimerProc);2。void CALLBACK C???Ctrl::TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
{
::PostMessage(hwnd, WM_MYHELLO, 0, 0);
//
}
3。
if(m_nTimerId)
KillTimer(m_nTimerId);4。static UINT m_nTimerId = 0;static void CALLBACK TimerProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime);
这个函数什么基类都没有继承!!!!
完成定时器的功能!
TimerProc到底该怎么写呀!
The TimerProc function is an application-defined callback function that processes WM_TIMER messages. The TIMERPROC type defines a pointer to this callback function. TimerProc is a placeholder for the application-defined function name. VOID CALLBACK TimerProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_TIMER message
UINT_PTR idEvent, // timer identifier
DWORD dwTime // current system time
);
Parameters
hwnd
[in] Handle to the window associated with the timer.
uMsg
[in] Specifies the WM_TIMER message.
idEvent
[in] Specifies the timer's identifier.
dwTime
[in] Specifies the number of milliseconds that have elapsed since the system was started. This is the value returned by the GetTickCount function.
Return Values
This function does not return a value. Requirements
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 98 or later.
Header: Declared in Winuser.h; include Windows.h.See Also
Timers Overview, Timer Functions, GetTickCount, KillTimer, SetTimer, WM_TIMER
m_nTimerId = ::SetTimer( NULL, 1, 50, ( CALLBACK TimerProc(NULL, WM_MYHELLO, 1, NULL) ) );
总是出现:error C2059: syntax error : '__stdcall'
是为什么呀!
如何将WM_MYHELLO的消息传给函数响应呢?
在一般继承MFC类的类中
可以将WM_MYHELLO和关联的函数如OnMyHello在
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_MESSAGE( WN_MYHELLO, OnMyHello )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()但在我这,没有任何的MFC的信息,如何传递信息呢?
或如何重载OnTimer WM_TIMER呢?或有什么简单的方法呢?
在一般继承MFC类的类中
可以将WM_MYHELLO和关联的函数如OnMyHello在
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_MESSAGE( WN_MYHELLO, OnMyHello )
//}}AFX_MSG_MAP
END_MESSAGE_MAP()但在我这,没有任何的MFC的信息,如何传递信息呢?
或如何重载OnTimer WM_TIMER呢?或有什么简单的方法呢?