-----------------------------WinNativeWidget
| 58 | |
| 59 | //-----------------------------WinNativeWidget |
| 60 | WinNativeWidget::WinNativeWidget(const int x, const int y, const int width, |
| 61 | const int height, QColor backColor) |
| 62 | { |
| 63 | _childWindow = nullptr; |
| 64 | _childWidget = nullptr; |
| 65 | _hWnd = NULL; |
| 66 | _event_callback = NULL; |
| 67 | _is_lose_foreground = false; |
| 68 | _hCurrentMonitor = NULL; |
| 69 | _shadow = NULL; |
| 70 | _titleBarWidget = NULL; |
| 71 | |
| 72 | _is_native_border = IsWin11OrGreater(); |
| 73 | |
| 74 | _border_color = QColor(0x80,0x80,0x80); |
| 75 | int r = backColor.red(); |
| 76 | int g = backColor.green(); |
| 77 | int b = backColor.blue(); |
| 78 | |
| 79 | HINSTANCE hInstance = GetModuleHandle(nullptr); |
| 80 | WNDCLASSEX wcx; |
| 81 | memset(&wcx, 0, sizeof(WNDCLASSEXW)); |
| 82 | |
| 83 | wcx.cbSize = sizeof(WNDCLASSEX); |
| 84 | wcx.style = CS_HREDRAW | CS_VREDRAW; |
| 85 | wcx.hInstance = hInstance; |
| 86 | wcx.lpfnWndProc = WndProc; |
| 87 | wcx.cbClsExtra = 0; |
| 88 | wcx.cbWndExtra = 0; |
| 89 | wcx.lpszClassName = L"DSViewWindowClass"; |
| 90 | wcx.hCursor = LoadCursor(hInstance, IDC_ARROW); |
| 91 | wcx.hbrBackground = CreateSolidBrush(RGB(r, g, b)); |
| 92 | |
| 93 | RegisterClassEx(&wcx); |
| 94 | if (FAILED(RegisterClassEx(&wcx))) |
| 95 | { |
| 96 | dsv_info("ERROR: can't register window class"); |
| 97 | assert(false); |
| 98 | } |
| 99 | |
| 100 | _hWnd = CreateWindow(L"DSViewWindowClass", L"DSView", |
| 101 | //WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_MAXIMIZEBOX | WS_THICKFRAME | WS_CLIPCHILDREN, |
| 102 | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
| 103 | x, y, width, height, |
| 104 | NULL, NULL, hInstance, NULL); |
| 105 | |
| 106 | if (!_hWnd) |
| 107 | { |
| 108 | dsv_info("ERROR: can't create naitive window"); |
| 109 | assert(false); |
| 110 | } |
| 111 | |
| 112 | SetWindowLongPtr(_hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(this)); |
| 113 | SetWindowPos(_hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE); |
| 114 | |
| 115 | if (!_is_native_border){ |
| 116 | _shadow = new WinShadow(_hWnd, NULL); |
| 117 | _shadow->createWinId(); |
nothing calls this directly
no test coverage detected