#define IDC_STATUSBAR 1111
case WM_INITDIALOG:
{
// 初始环境
INITCOMMONCONTROLSEX initComm = { 0 };
initComm.dwSize = sizeof(INITCOMMONCONTROLSEX);
initComm.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&initComm);
// 创建控件
HWND hStatusBar = CreateWindowEx(
NULL,
STATUSCLASSNAME,
NULL,
WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP,
0, 0, 0, 0,
hwnd,
(HMENU)IDC_STATUSBAR,
GetModuleHandle(NULL),
NULL
);
// 设置区间
int nParts[] = { 100, 200, 350, -1 };
SendMessage(hStatusBar, SB_SETPARTS, 4, (LPARAM)nParts);
// 初始控件
SendMessage(hStatusBar, SB_SETTEXT, 0, (LPARAM)L"Ver - 1.0.0");
// 设置定时
SetTimer(hwnd, 1, 1000, NULL);
return TRUE;
}
case WM_TIMER:
{
if (wParam == 1)
{
HWND hStatusBar = GetDlgItem(hwnd, IDC_STATUSBAR);
TCHAR szTime[0xFF] = { 0 };
SYSTEMTIME sysTime = { 0 };
GetLocalTime(&sysTime);
wsprintf(szTime, L"%02d:%02d:%02d", sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
SendMessage(hStatusBar, SB_SETTEXT, 1, (LPARAM)szTime);
break;
}
return TRUE;
}