Advertisement
savva234568

Untitled

Sep 25th, 2022
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.27 KB | Source Code | 0 0
  1. #pragma warning(disable:4996)
  2. #include <windows.h>
  3. #include <iostream>
  4.  
  5. LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
  6.  
  7. INT APIENTRY wWinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PWSTR cmdLine, INT cmdShow) {
  8.     AllocConsole();
  9.     freopen("CONOUT$", "w", stdout);
  10.     std::cout << "This works" << std::endl;
  11.     HWND hwnd{};
  12.     MSG msg{};
  13.     WNDCLASSEX wnd{ sizeof(WNDCLASSEX) };
  14.     wnd.cbClsExtra = 0;
  15.     wnd.cbWndExtra = 0;
  16.     wnd.hInstance = hInst;
  17.     wnd.lpszClassName = L"mainWindow";
  18.     wnd.hbrBackground = CreateHatchBrush(HS_CROSS, RGB(255, 0, 0));
  19.     wnd.hCursor = LoadCursor(nullptr, IDC_ARROW);
  20.     wnd.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
  21.     wnd.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
  22.     wnd.lpfnWndProc = wndProc;
  23.     wnd.lpszMenuName = nullptr;
  24.     wnd.style = CS_VREDRAW | CS_HREDRAW;
  25.     RegisterClassEx(&wnd);
  26.     hwnd = CreateWindow(
  27.         wnd.lpszClassName,
  28.         L"Steam",
  29.         WS_OVERLAPPED | WS_MINIMIZEBOX | WS_SYSMENU,
  30.         (GetSystemMetrics(SM_CXSCREEN) - 1400) / 2,
  31.         (GetSystemMetrics(SM_CYSCREEN) - 900) / 2,
  32.         1400, 900, nullptr, nullptr,
  33.         hInst, nullptr
  34.     );
  35.     ShowWindow(hwnd, cmdShow);
  36.     UpdateWindow(hwnd);
  37.     while (GetMessage(&msg, nullptr, 0, 0)) {
  38.         TranslateMessage(&msg);
  39.         DispatchMessage(&msg);
  40.     }
  41.     return 0;
  42. }
  43.  
  44. LRESULT CALLBACK wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  45.     enum btnId {
  46.         LIBARY,
  47.         FRIENDS,
  48.         PROFILE
  49.     };
  50.     static LPDRAWITEMSTRUCT drawStruct;
  51.     static PAINTSTRUCT ps{};
  52.     static HDC dc = GetDC(hWnd);
  53.     static HBITMAP hImage = nullptr;
  54.     static HWND hImageView = nullptr;
  55.     static HFONT fnt;
  56.     //static HWND button;
  57.     static HWND libary;
  58.     static HWND friends;
  59.     static HWND profile;
  60.     switch (uMsg) {
  61.         case WM_CREATE:
  62.             fnt = CreateFontW(
  63.                 36, 0, 0, 0, FW_MEDIUM, 0, 0, 0, ANSI_CHARSET,
  64.                 OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS,
  65.                 CLEARTYPE_QUALITY, VARIABLE_PITCH, L"Arial"
  66.             );
  67.             libary = CreateWindowW(
  68.                 L"static", nullptr, WS_CHILD | WS_VISIBLE | SS_OWNERDRAW,
  69.                 100, 25, 1400, 50, hWnd, reinterpret_cast<HMENU>(LIBARY), 0, 0
  70.             );
  71.             hImage = (HBITMAP)LoadImageW(
  72.                 nullptr, L"resources\\logo.bmp", IMAGE_BITMAP,
  73.                 70, 70, LR_LOADFROMFILE
  74.             );
  75.             hImageView = CreateWindowW(
  76.                 L"static", NULL,
  77.                 SS_BITMAP | WS_VISIBLE | WS_CHILD,
  78.                 22, 8, 70, 70, hWnd, 0, GetModuleHandle(NULL), NULL
  79.             );
  80.             SendMessage(hImageView, STM_SETIMAGE, IMAGE_BITMAP, reinterpret_cast<LPARAM>(hImage));
  81.         break;
  82.         case WM_PAINT:
  83.             std::cout << "WM_PAINT" << std::endl;
  84.             BeginPaint(hWnd, &ps);
  85.             SelectObject(dc, GetStockObject(DC_BRUSH));
  86.             SetDCBrushColor(dc, RGB(24, 26, 32));
  87.             SelectObject(dc, GetStockObject(DC_PEN));
  88.             SetDCPenColor(dc, RGB(24, 26, 32));
  89.             Rectangle(dc, 0, 0, 1409, 90);
  90.             EndPaint(hWnd, &ps);
  91.         break;
  92.         case WM_DRAWITEM:
  93.             std::cout << "WM_DRAWITEM" << std::endl;
  94.             drawStruct = reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);
  95.             if (drawStruct->hwndItem == libary) {
  96.                 SelectObject(drawStruct->hDC, fnt);
  97.                 SetTextColor(drawStruct->hDC, RGB(200, 207, 220));
  98.                 SetBkMode(drawStruct->hDC, TRANSPARENT);
  99.                 //SetBkColor(drawStruct->hDC, RGB(0,0,0));
  100.                 TextOut(drawStruct->hDC, 0, 0, L"БИБЛИОТЕКА", 11);
  101.             }
  102.         break;
  103.         case WM_DESTROY:
  104.             PostQuitMessage(EXIT_SUCCESS);
  105.         break;
  106.     }
  107.     return DefWindowProc(hWnd, uMsg, wParam, lParam);
  108. }
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement