Win32窗口
Posted GIS开发
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Win32窗口相关的知识,希望对你有一定的参考价值。
#include <Windows.h> #include <CommCtrl.h> #pragma comment(lib, "comctl32.lib") LRESULT CALLBACK MyProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static HWND hStatus; switch(msg) { case WM_CREATE: { hStatus = CreateStatusWindow(WS_CHILD | WS_VISIBLE, L"Hello", hWnd, 1); HMENU hMenu = CreateMenu(); AppendMenu(hMenu, MF_STRING, 100, L"退出"); SetMenu(hWnd, hMenu); } break; case WM_COMMAND: { switch (LOWORD(wParam)) { case 100: MessageBox(NULL, L"C", L"C", MB_OK); break; default: break; } } break; case WM_CLOSE: PostQuitMessage(0); break; case WM_SIZE: { int x = LOWORD(lParam); int y = HIWORD(lParam); MoveWindow(hStatus, 0, 0, x, y, true); } break; default: break; } return DefWindowProc(hWnd, msg, wParam, lParam); } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine ,int nCmdShow) { WNDCLASSEX wcex; memset(&wcex, 0, sizeof(WNDCLASSEX)); wcex.cbSize = sizeof(WNDCLASSEX); wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hbrBackground = (HBRUSH)GetStockObject(DKGRAY_BRUSH); wcex.hCursor = LoadCursor(NULL, IDC_HAND); wcex.hIcon = LoadIcon(NULL, IDI_ERROR); wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wcex.hInstance = hInstance; wcex.lpfnWndProc = MyProc; wcex.lpszClassName = L"CC"; wcex.lpszMenuName = NULL; wcex.style = CS_HREDRAW | CS_VREDRAW; RegisterClassEx(&wcex); HWND hWnd = CreateWindowEx(0, L"CC", L"My", WS_OVERLAPPEDWINDOW, 0, 0, 1024, 800, NULL, NULL, hInstance, NULL); MSG msg; ShowWindow(hWnd, SW_SHOW); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } }
以上是关于Win32窗口的主要内容,如果未能解决你的问题,请参考以下文章