我想在程序中生成一个对话框,并设定一个定时器,然后在文本栏(IDC_STATIC1)显示现在时间(通过按show按钮),可是程序运行时文本栏并无显示,为何呢?
本人是vc菜鸟,请大家指点
#include <windows.h>
#include "resource.h"INT_PTR CALLBACK DialogProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
DialogBox( hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) DialogProc);
return 0;
}INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
if (LOWORD(wParam) == IDB_SHOW)
{
SetTimer(hwndDlg,ID_TIMER,100,NULL); //定时
}
if (LOWORD(wParam) == IDCANCEL) EndDialog( hwndDlg, 0 );
break;
case WM_TIMER:
SYSTEMTIME st;
char time[50];
GetLocalTime(&st); GetTimeFormat(NULL,TIME_FORCE24HOURFORMAT, &st,"HH':'mm':'ss",
time+wsprintf(time," %d-%d-%d ",st.wYear,st.wMonth,st.wDay),50); SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC1),time); break; }
return 0;
}
本人是vc菜鸟,请大家指点
#include <windows.h>
#include "resource.h"INT_PTR CALLBACK DialogProc(HWND,UINT,WPARAM,LPARAM);int WINAPI WinMain(
HINSTANCE hInstance, // handle to current instance
HINSTANCE hPrevInstance, // handle to previous instance
LPSTR lpCmdLine, // command line
int nCmdShow // show state
)
{
DialogBox( hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC) DialogProc);
return 0;
}INT_PTR CALLBACK DialogProc(HWND hwndDlg,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch (uMsg)
{
case WM_COMMAND:
if (LOWORD(wParam) == IDB_SHOW)
{
SetTimer(hwndDlg,ID_TIMER,100,NULL); //定时
}
if (LOWORD(wParam) == IDCANCEL) EndDialog( hwndDlg, 0 );
break;
case WM_TIMER:
SYSTEMTIME st;
char time[50];
GetLocalTime(&st); GetTimeFormat(NULL,TIME_FORCE24HOURFORMAT, &st,"HH':'mm':'ss",
time+wsprintf(time," %d-%d-%d ",st.wYear,st.wMonth,st.wDay),50); SetWindowText(GetDlgItem(hwndDlg,IDC_STATIC1),time); break; }
return 0;
}
我:win2k server + vs.net你的E-mail 是什么?我发给你看看?
我的配置是2k+vc6.0