Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include "resource.h"
- #include <tchar.h>
- #define ID_BUT1 3000
- BOOL CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPervInstance, LPSTR lpCmdLine, int mCmdShow)
- {
- HWND hWnd = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc);
- ShowWindow(hWnd, SW_NORMAL);
- UpdateWindow(hWnd);
- MSG msg;
- while (GetMessage(&msg, NULL, 0, 0))
- {
- TranslateMessage(&msg);//нужно так как будет приниматься сообщение от клавиатуры, для перевода значения
- DispatchMessage(&msg);
- }
- return msg.wParam;
- //return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG), NULL, DlgProc);
- }
- BOOL CALLBACK DlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
- {
- static HWND hStatic1;
- static HWND hBut1;
- static HWND hButOK, hCheckOK;
- switch (uMsg)
- {
- case WM_INITDIALOG:
- hButOK = GetDlgItem(hWnd, IDC_BUTTON2);
- hCheckOK = GetDlgItem(hWnd, IDC_CHECK1);
- hStatic1 = CreateWindowEx(NULL, L"STATIC" /*class*/, _TEXT("My first static"), WS_CHILD | WS_VISIBLE,
- 150, 30, 60, 40, hWnd /*parent*/,
- NULL, GetModuleHandle(NULL), NULL);
- hBut1 = CreateWindowEx(WS_EX_TOPMOST, _TEXT ("BUTTON"), _TEXT("Click") /* Текст на кнопке*/, WS_CHILD | WS_VISIBLE /* Стиль*/,
- 10,150,60, 40, hWnd /* Родитель*/, (HMENU)ID_BUT1 /* ID кнопки*/,
- GetModuleHandle(NULL), NULL);
- return true;
- case WM_COMMAND:
- if (lParam == LPARAM(hCheckOK))
- /*if (LOWORD(wParam) == IDC_BUTTON2)*/
- {
- MessageBox(NULL, L"Button", L"Info", MB_OK);
- if (SendMessage(hCheckOK, BM_GETCHECK, 0, 0) == BST_UNCHECKED)
- {
- SendMessage(hCheckOK, BM_SETCHECK, BST_CHECKED, 0);
- }
- else
- {
- SendMessage(hCheckOK, BM_SETCHECK, BST_UNCHECKED, 0);
- }
- }
- case WM_CLOSE:
- DestroyWindow(hWnd);
- PostQuitMessage(0);
- return true;
- }
- return false;
- /*switch (uMsg)
- {
- case WM_CLOSE:
- EndDialog(hWnd, 0);
- return true;
- }
- return false;*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement