【谁能给个带定时器的dialog程序啊 谢谢了 】 在网上查到的教程都是 单文档的 不知道在dialog应该怎么样 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 #include<windows.h>#include "Resource.h"#define TIMER1 1#define TIMER2 2INT_PTR CALLBACK DialogProc( HWND hwndDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter);VOID CALLBACK TimerProc( HWND hwnd, // handle to window UINT uMsg, // WM_TIMER message UINT_PTR idEvent, // timer identifier DWORD dwTime // current system time);HINSTANCE g_hInstance;TCHAR szClassName[]=TEXT("DLGCLASS");TCHAR szStartCaption[]=TEXT("启动下面的计时器");TCHAR szEndCaption[]=TEXT("停止下面的计时器");static INT count;BOOL flag=TRUE;BOOL ShowApple=TRUE;int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // command line int nCmdShow // show state){ g_hInstance=hInstance; DialogBox(g_hInstance,szClassName,NULL,(DLGPROC)DialogProc); return 0;}INT_PTR CALLBACK DialogProc( HWND hwndDlg, // handle to dialog box UINT uMsg, // message WPARAM wParam, // first message parameter LPARAM lParam // second message parameter){ static HWND hApple,hBanana; switch(uMsg) { case WM_INITDIALOG: hApple=GetDlgItem(hwndDlg,IDC_APPLE); hBanana=GetDlgItem(hwndDlg,IDC_BANANA); SetTimer(hwndDlg,TIMER2,1000,NULL); return FALSE; case WM_TIMER: if(ShowApple) { ShowWindow(hApple,SW_SHOW); ShowWindow(hBanana,SW_HIDE); } else { ShowWindow(hBanana,SW_SHOW); ShowWindow(hApple,SW_HIDE); } ShowApple=!ShowApple; break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_START: if(flag==TRUE) { SetWindowText(GetDlgItem(hwndDlg,IDC_START),szEndCaption); flag=FALSE; SetTimer(GetDlgItem(hwndDlg,IDC_COUNT),TIMER1,1000,(TIMERPROC )TimerProc); } else { SetWindowText(GetDlgItem(hwndDlg,IDC_START),szStartCaption); flag=TRUE; KillTimer(GetDlgItem(hwndDlg,IDC_COUNT),TIMER1); } break; case IDCANCEL: KillTimer(hwndDlg,TIMER2); if(flag) KillTimer(GetDlgItem(hwndDlg,IDC_COUNT),TIMER1); EndDialog(hwndDlg,TRUE); return 0; } } return 0;}VOID CALLBACK TimerProc( HWND hwnd, // handle to window UINT uMsg, // WM_TIMER message UINT_PTR idEvent, // timer identifier DWORD dwTime // current system time){ ++count; SetDlgItemInt(GetParent(hwnd),IDC_COUNT,count,FALSE);} SetTimer(nIDEvent, 1000毫秒, 0);添加WM_TIMER消息处理函数afx_msg void OnTimer( UINT_PTR nIDEvent ); 我晕啊,直接添加不就好了么?SetTimer() 二三楼的 我初学 不知道该添加在什么地方能不能给我个全一些的 是dialog的 不是单文档的一楼的太长 我明天仔细看 我csdn有个。双色球号码获取器,vc++6.0对话框,用 定时器 实现随机获取 自动获取 号码编译通过。希望对你有用地址:http://download.csdn.net/source/3210119 添加处理WM_TIMER消息OnInitDialog中SetTimer();启动定时器 我是要实现按下这个按钮 有个程序隔10秒一运行的你的直接加到OnInitDialog是不是程序启动就开始计时了? 在对话框上实现定时器其实不难: 前几天刚帮同学做了个关于对话框的定时器功能。总结步骤如下: 步骤三步:1.在resource.h中定义这个定时器的ID: #define IDTIMER 1;2.在对话框类中 OnInitDialog() 中添加定时器的属性定义: SetTimer(IDTIMER,3000,NULL);SetTimer函数在哪,表示定时器从那开始启动 。如果在按钮响应函数中,则表示点击按钮后定时工作,如果在OnInitDialog() 中,表示对话框一运行,就定时工作。3.给对话框添加WM_TIMER消息映射函数OnTimer(),在这里面实现自己在每个隔一定时间后想做的工作。就这三步,很容易的,我总结好的,希望对你有帮助.... 补充一下: 上文的SetTimer()里面的3000指的是定时时间是3000ms.你可以自己该时间 确实可以用大概明白了那在哪里kill呢? 当按下 滚动 按钮时timer=SetTimer(1,10,FALSE); 启动定时器 10ms调用onok()对数据进行一次随机操作 VC MFC 如何修改选项卡标签的颜色(字体和背景) 超简单文本输出问题 请教一个低级keyboard hook问题 webservicese调用问题 求VC++写的即时通讯程序源码 请大哥们看看调试warning C4651/warning LNK4089 怎么知道程序中启动的进程的状态 讨论:如何知道一个程序已经关闭? 高分---那里有下载<VC++技术内幕>第四版的电子版, 有没有用VC6.0编写组件的资料 控件大小的问题 请问怎么在DLL中发送消息给进程
#include "Resource.h"#define TIMER1 1
#define TIMER2 2
INT_PTR CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
);VOID CALLBACK TimerProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_TIMER message
UINT_PTR idEvent, // timer identifier
DWORD dwTime // current system time
);HINSTANCE g_hInstance;
TCHAR szClassName[]=TEXT("DLGCLASS");
TCHAR szStartCaption[]=TEXT("启动下面的计时器");
TCHAR szEndCaption[]=TEXT("停止下面的计时器");
static INT count;
BOOL flag=TRUE;
BOOL ShowApple=TRUE;int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
){
g_hInstance=hInstance;
DialogBox(g_hInstance,szClassName,NULL,(DLGPROC)DialogProc);
return 0;
}
INT_PTR CALLBACK DialogProc(
HWND hwndDlg, // handle to dialog box
UINT uMsg, // message
WPARAM wParam, // first message parameter
LPARAM lParam // second message parameter
)
{
static HWND hApple,hBanana;
switch(uMsg)
{
case WM_INITDIALOG:
hApple=GetDlgItem(hwndDlg,IDC_APPLE);
hBanana=GetDlgItem(hwndDlg,IDC_BANANA);
SetTimer(hwndDlg,TIMER2,1000,NULL);
return FALSE;
case WM_TIMER:
if(ShowApple)
{
ShowWindow(hApple,SW_SHOW);
ShowWindow(hBanana,SW_HIDE);
}
else
{
ShowWindow(hBanana,SW_SHOW);
ShowWindow(hApple,SW_HIDE);
}
ShowApple=!ShowApple;
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{ case IDC_START:
if(flag==TRUE)
{
SetWindowText(GetDlgItem(hwndDlg,IDC_START),szEndCaption);
flag=FALSE;
SetTimer(GetDlgItem(hwndDlg,IDC_COUNT),TIMER1,1000,(TIMERPROC )TimerProc);
}
else
{
SetWindowText(GetDlgItem(hwndDlg,IDC_START),szStartCaption);
flag=TRUE;
KillTimer(GetDlgItem(hwndDlg,IDC_COUNT),TIMER1); }
break; case IDCANCEL:
KillTimer(hwndDlg,TIMER2);
if(flag)
KillTimer(GetDlgItem(hwndDlg,IDC_COUNT),TIMER1);
EndDialog(hwndDlg,TRUE);
return 0;
}
}
return 0;
}VOID CALLBACK TimerProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_TIMER message
UINT_PTR idEvent, // timer identifier
DWORD dwTime // current system time
)
{
++count;
SetDlgItemInt(GetParent(hwnd),IDC_COUNT,count,FALSE);
}
afx_msg void OnTimer(
UINT_PTR nIDEvent
);
SetTimer()
地址:
http://download.csdn.net/source/3210119
OnInitDialog中SetTimer();启动定时器
我是要实现按下这个按钮 有个程序隔10秒一运行的你的直接加到OnInitDialog是不是程序启动就开始计时了?
前几天刚帮同学做了个关于对话框的定时器功能。总结步骤如下:
步骤三步:
1.在resource.h中定义这个定时器的ID: #define IDTIMER 1;2.在对话框类中 OnInitDialog() 中添加定时器的属性定义:
SetTimer(IDTIMER,3000,NULL);
SetTimer函数在哪,表示定时器从那开始启动 。如果在按钮响应函数中,则表示点击按钮后定时工作,如果在OnInitDialog() 中,表示对话框一运行,就定时工作。3.给对话框添加WM_TIMER消息映射函数OnTimer(),在这里面实现自己在每个隔一定时间后想做的工作。就这三步,很容易的,我总结好的,希望对你有帮助....
上文的SetTimer()里面的3000指的是定时时间是3000ms.你可以自己该时间
确实可以用大概明白了那在哪里kill呢?
对数据进行一次随机操作