Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- HWND editBox1;
- HWND editBox2;
- MSG evnt;
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
- void init(HINSTANCE hInstance, LPSTR className);
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- // Creating window class
- LPSTR className = "Window Class";
- init(hInstance, className);
- // Creating main window
- HWND hwnd;
- hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, className, "Drag n Drop", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, hInstance, NULL);
- // Error checking
- if (hwnd == NULL)
- {
- MessageBox(NULL, "Could not create window", "", MB_ICONEXCLAMATION);
- return 1;
- }
- ShowWindow(hwnd, nCmdShow); // Pokaż okienko...
- UpdateWindow(hwnd);
- editBox1 = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE, 150, 80, 200, 50, hwnd, (HMENU)1, hInstance, NULL);
- editBox2 = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE, 150, 150, 200, 50, hwnd, (HMENU)2, hInstance, NULL);
- while (GetMessage(&evnt, NULL, 0, 0))
- {
- TranslateMessage(&evnt);
- DispatchMessage(&evnt);
- }
- return evnt.wParam;
- }
- LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch (msg)
- {
- case WM_COMMAND:
- switch (wParam)
- {
- case 1:
- // Button 1
- break;
- }
- break;
- case WM_CLOSE:
- DestroyWindow(hwnd);
- break;
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hwnd, msg, wParam, lParam);
- }
- return 0;
- }
- void init(HINSTANCE hInstance, LPSTR className)
- {
- WNDCLASSEX wc;
- wc.cbSize = sizeof(WNDCLASSEX);
- wc.style = 0;
- wc.lpfnWndProc = WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = className;
- wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- // Registering window class
- if (!RegisterClassEx(&wc))
- {
- MessageBox(NULL, "Could not register window!", "", MB_ICONEXCLAMATION | MB_OK);
- return;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement