Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
- #include <Windows.h>
- #include <Uxtheme.h>
- #include <vsstyle.h>
- #include <CommCtrl.h>
- #include <sstream>
- LRESULT CALLBACK WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- break;
- }
- case WM_PAINT:
- {
- PAINTSTRUCT ps;
- HDC hdc = BeginPaint(hwnd, &ps);
- HTHEME theme = OpenThemeData(hwnd, L"TREEVIEW");
- RECT rect;
- rect.left = 100;
- rect.top = 100;
- rect.right = 200;
- rect.bottom = 200;
- RECT glyphRect;
- glyphRect.left = 84;
- glyphRect.top = 142;
- glyphRect.right = 84 + 16;
- glyphRect.bottom = 142 + 16;
- DrawThemeBackground(theme,
- hdc,
- TVP_GLYPH,
- GLPS_CLOSED,
- &glyphRect,
- &glyphRect);
- DrawThemeBackground(theme,
- hdc,
- TVP_TREEITEM,
- TREIS_SELECTED,
- &rect,
- &rect);
- DrawThemeText(theme,
- hdc,
- TVP_TREEITEM,
- TREIS_SELECTED,
- L"Ala ma kota",
- 11,
- DT_VCENTER | DT_CENTER | DT_SINGLELINE,
- 0,
- &rect);
- CloseThemeData(theme);
- EndPaint(hwnd, &ps);
- return 0L;
- }
- default:
- {
- return DefWindowProc(hwnd, message, wParam, lParam);
- }
- }
- }
- int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- INITCOMMONCONTROLSEX ctrl;
- ctrl.dwSize = sizeof(ctrl);
- ctrl.dwICC = ICC_TREEVIEW_CLASSES;
- InitCommonControlsEx(&ctrl);
- // Rejestracja klasy okna
- WNDCLASSEX winClass;
- winClass.cbClsExtra = 0;
- winClass.cbSize = sizeof(WNDCLASSEX);
- winClass.cbWndExtra = 0;
- winClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
- winClass.hCursor = LoadCursor(NULL, IDC_ARROW);
- winClass.hIcon = LoadIcon(NULL, IDI_WINLOGO);
- winClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
- winClass.hInstance = hInstance;
- winClass.lpfnWndProc = WindowProc;
- winClass.lpszClassName = L"MainWindowClass";
- winClass.lpszMenuName = NULL;
- winClass.style = CS_HREDRAW | CS_VREDRAW;
- if (!RegisterClassEx(&winClass))
- return -1;
- // Tworzenie okna
- HWND mainWinHWND = CreateWindowEx(WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE,
- L"MainWindowClass",
- L"WinAPI window",
- WS_OVERLAPPEDWINDOW,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- 640,
- 480,
- NULL,
- NULL,
- hInstance,
- NULL);
- if (!mainWinHWND)
- return -1;
- SetWindowTheme(mainWinHWND, L"explorer", nullptr);
- ShowWindow(mainWinHWND, SW_SHOW);
- // Obsługa kolejki komunikatów
- MSG message;
- BOOL getMsgResult;
- while ((getMsgResult = GetMessage(&message, NULL, 0, 0)) != 0 && getMsgResult != -1)
- {
- TranslateMessage(&message);
- DispatchMessage(&message);
- }
- return message.lParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement