C++ SetTimer问题

来源:百度知道 编辑:UC知道 时间:2024/05/16 12:58:24
#include<iostream>
#include<String.h>
#include<afx.h>
using namespace std;
VOID CALLBACK my_timer();
void main(){
SetTimer(NULL,0,1000,my_timer);
}

VOID CALLBACK my_timer(){
cout<<"timer"<<endl;

}

运行之后出现以下错误:error C2664: 'SetTimer' : cannot convert parameter 4 from 'void (void)' to 'void (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,unsigned long)'

应该怎么改?谢谢!

我不知道~~有正确答案的记得告诉我哦~~~
没人回答就把分给我吧~~嘎嘎~

你SetTimer的时候最后一个参数也就是回调函数my_timer()需要显示的转换一下,SetTimer(NULL,0,1000,(TIMEPROC)my_timer);这样应该就没问题了。