Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma warning(disable:4996)
- #include <windows.h>
- #include <iostream>
- LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
- INT APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PWSTR cmdLine, INT cmdShow) {
- AllocConsole();
- freopen("CONOUT$", "w", stdout);
- std::cout << "This works" << std::endl;
- HWND hwnd{};
- MSG msg{};
- WNDCLASSEX wnd{ sizeof(WNDCLASSEX) };
- wnd.cbClsExtra = 0;
- wnd.cbWndExtra = 0;
- wnd.hInstance = hInst;
- wnd.lpszClassName = L"mainWindow";
- wnd.hbrBackground = CreateHatchBrush(HS_CROSS, RGB(255, 0, 0));
- wnd.hCursor = LoadCursor(nullptr, IDC_ARROW);
- wnd.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
- wnd.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
- wnd.lpfnWndProc = wndProc;
- wnd.lpszMenuName = nullptr;
- wnd.style = CS_VREDRAW | CS_HREDRAW;
- RegisterClassEx(&wnd);
- hwnd = CreateWindow(
- wnd.lpszClassName,
- L"Steam",
- WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU,
- (GetSystemMetrics(SM_CXSCREEN) - 1400) / 2,
- (GetSystemMetrics(SM_CYSCREEN) - 900) / 2,
- 1400, 900, nullptr, nullptr,
- hInst, nullptr
- );
- ShowWindow(hwnd, cmdShow);
- UpdateWindow(hwnd);
- while (GetMessage(&msg, nullptr, 0, 0)) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return 0;
- }
- LRESULT CALLBACK wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
- enum btnId {
- LIBARY,
- FRIENDS,
- PROFILE
- };
- static LPDRAWITEMSTRUCT drawStruct;
- static PAINTSTRUCT ps{};
- static HDC dc = GetDC(hWnd);
- static HBITMAP hImage = nullptr;
- static HWND hImageView = nullptr;
- static HFONT fnt;
- //static HWND button;
- static HWND libary;
- static HWND friends;
- static HWND profile;
- switch (uMsg) {
- case WM_CREATE:
- fnt = CreateFontW(
- 36, 0, 0, 0, FW_MEDIUM, 0, 0, 0, ANSI_CHARSET,
- OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
- CLEARTYPE_QUALITY, VARIABLE_PITCH, L"Arial"
- );
- libary = CreateWindowW(
- L"static", nullptr, WS_CHILD | WS_VISIBLE | SS_OWNERDRAW,
- 100, 25, 1400, 50, hWnd, reinterpret_cast<HMENU>(LIBARY), 0, 0
- );
- hImage = (HBITMAP)LoadImageW(
- nullptr, L"resources\\logo.bmp", IMAGE_BITMAP,
- 70, 70, LR_LOADFROMFILE
- );
- hImageView = CreateWindowW(
- L"static", NULL,
- SS_BITMAP | WS_VISIBLE | WS_CHILD,
- 22, 8, 70, 70, hWnd, 0, GetModuleHandle(NULL), NULL
- );
- SendMessage(hImageView, STM_SETIMAGE, IMAGE_BITMAP, reinterpret_cast<LPARAM>(hImage));
- break;
- case WM_PAINT:
- std::cout << "WM_PAINT" << std::endl;
- BeginPaint(hWnd, &ps);
- SelectObject(dc, GetStockObject(DC_BRUSH));
- SetDCBrushColor(dc, RGB(24, 26, 32));
- SelectObject(dc, GetStockObject(DC_PEN));
- SetDCPenColor(dc, RGB(24, 26, 32));
- Rectangle(dc, 0, 0, 1409, 90);
- EndPaint(hWnd, &ps);
- break;
- case WM_DRAWITEM:
- std::cout << "WM_DRAWITEM" << std::endl;
- drawStruct = reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);
- if (drawStruct->hwndItem == libary) {
- SelectObject(drawStruct->hDC, fnt);
- SetTextColor(drawStruct->hDC, RGB(200, 207, 220));
- SetBkMode(drawStruct->hDC, TRANSPARENT);
- //SetBkColor(drawStruct->hDC, RGB(0,0,0));
- TextOut(drawStruct->hDC, 0, 0, L"БИБЛИОТЕКА", 11);
- }
- break;
- case WM_DESTROY:
- PostQuitMessage(EXIT_SUCCESS);
- break;
- }
- return DefWindowProc(hWnd, uMsg, wParam, lParam);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement