求指点,我新手!

a63461612 a63461612 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我新手,刚学,代码编译有点简单,大家别笑我想弄个定时关机,下面是代码,可是当时间到的时候没反映,怎么回事
#include "stdafx.h"
#include "time.h"
#include <windows.h>
#include <windowsx.h>
#include "resource.h"
#include "MainDlg.h"


BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);
HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);
HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);
}

return FALSE;
}
void CALLBACK TimerProc (HWND hwnd, UINT message, UINT iTimerID, DWORD dwTime)
{
SYSTEMTIME stLocal;
GetLocalTime(&stLocal);
TCHAR str1[256];
wsprintf(str1,TEXT("%u"),stLocal.wHour);
SetDlgItemText(hwnd,IDC_EDIT1,str1);
TCHAR str2[256];
wsprintf(str2,TEXT("%u"),stLocal.wMinute);
SetDlgItemText(hwnd,IDC_EDIT2,str2);
TCHAR str3[256];
wsprintf(str3,TEXT("%u"),stLocal.wSecond);
SetDlgItemText(hwnd,IDC_EDIT3,str3);

}

BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
SetTimer(hwnd,0,1000,TimerProc);

return TRUE;
}

void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDC_OK:
{
SYSTEMTIME stLocal;
GetLocalTime(&stLocal);
TCHAR str1[256];
wsprintf(str1,TEXT("%u"),stLocal.wHour);
TCHAR str2[256];
wsprintf(str2,TEXT("%u"),stLocal.wMinute);
TCHAR str3[256];
wsprintf(str3,TEXT("%u"),stLocal.wSecond);
TCHAR str6[256];
GetDlgItemText(hwnd,IDC_EDIT6,str6,sizeof(str1));
TCHAR str7[256];
GetDlgItemText(hwnd,IDC_EDIT6,str7,sizeof(str7));
TCHAR str8[256];
GetDlgItemText(hwnd,IDC_EDIT8,str8,sizeof(str8));
if(str6==str1,str7==str2,str3==str8)
ExitWindowsEx(EWX_SHUTDOWN,4);






}
break;
default:
break;
}
}

void Main_OnClose(HWND hwnd)
{
EndDialog(hwnd, 0);
}
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
a63461612
C++ Builder 13,871 成员 102,696 内容