Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS // чтобы компайлер не ругался насчет небезопасности сишного strcat
- #include "KWnd.h"
- #include <Windows.h>
- KWnd::KWnd(LPCSTR windowName, HINSTANCE hInstance, int cmdShow,
- LRESULT(WINAPI *WndProc)(HWND, UINT, WPARAM, LPARAM),
- LPCSTR menuName, int x, int y, int width, int height,
- UINT classStyle, DWORD windowStyle, HWND hParent)
- {
- char szClassName[] = "Class Name";
- wc.cbSize = sizeof(wc);
- wc.style = classStyle;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadIcon(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
- wc.lpszMenuName = menuName;
- wc.lpszClassName = szClassName;
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- if (!RegisterClassEx(&wc)) {
- char msg[100] = "Cannot register class: ";
- strcat(msg, szClassName);
- MessageBox(NULL, msg, "Error", MB_OK);
- return;
- }
- hWnd = CreateWindow(szClassName, windowName, windowStyle,
- x, y, width, height, hParent, (HMENU)NULL, hInstance, NULL);
- if (!hWnd) {
- char msg[100] = "Cannot create window: ";
- strcat(msg, windowName);
- MessageBox(NULL, msg, "Error", MB_OK);
- return;
- }
- ShowWindow(hWnd, cmdShow);
- }
Add Comment
Please, Sign In to add comment