|
#pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") |
|
|
|
#include <windows.h> |
|
#include <windowsx.h> |
|
#include <tchar.h> |
|
|
|
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
|
{ |
|
if ( message == WM_DESTROY ) |
|
{ |
|
PostQuitMessage(0); |
|
return 0; |
|
} |
|
|
|
return DefWindowProc(hWnd, message, wParam, lParam); |
|
} |
|
|
|
|
|
const int ID_TOGGLEBTN_1 = 1001; |
|
const int ID_TOGGLEBTN_2 = 1002; |
|
const int ID_TOGGLEBTN_3 = 1003; |
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int nCmdShow) |
|
{ |
|
// Create frame |
|
WNDCLASS wc = { }; |
|
|
|
wc.lpfnWndProc = WndProc; |
|
wc.hInstance = hInstance; |
|
wc.lpszClassName = _T("SampleFrame"); |
|
RegisterClass(&wc); |
|
|
|
HWND hFrame = CreateWindow(wc.lpszClassName, _T("Toggle Button Test"), |
|
WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 400, 400, |
|
nullptr, nullptr, hInstance, nullptr); |
|
|
|
// Create buttons |
|
HWND hButton = nullptr; |
|
|
|
// Enabled push button |
|
hButton = CreateWindowEx(0, _T("BUTTON"), _T("Enabled"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_PUSHLIKE, |
|
20, 20, 150, 60, hFrame, (HMENU)(ID_TOGGLEBTN_1), hInstance, nullptr); |
|
|
|
// Disabled push button, pushed |
|
hButton = CreateWindowEx(0, _T("BUTTON"), _T("Disabled ON"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_PUSHLIKE, |
|
20, 150, 150, 60, hFrame, (HMENU)(ID_TOGGLEBTN_2), hInstance, nullptr); |
|
Button_SetCheck(hButton, BST_CHECKED); |
|
EnableWindow(hButton, FALSE); |
|
|
|
// Disabled push button, unpushed |
|
hButton = CreateWindowEx(0, _T("BUTTON"), _T("Disabled OFF"), WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_PUSHLIKE, |
|
20, 270, 150, 60, hFrame, (HMENU)(ID_TOGGLEBTN_3), hInstance, nullptr); |
|
Button_SetCheck(hButton, BST_UNCHECKED); |
|
EnableWindow(hButton, FALSE); |
|
|
|
ShowWindow(hFrame, nCmdShow); |
|
//UpdateWindow(hFrame); |
|
|
|
// Handle messages |
|
MSG msg; |
|
|
|
while ( GetMessage(&msg, NULL, 0, 0) ) |
|
{ |
|
TranslateMessage(&msg); |
|
DispatchMessage(&msg); |
|
} |
|
|
|
return (int)msg.wParam; |
|
} |