VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/dbg/tstMvWnd.cpp

Last change on this file was 98141, checked in by vboxsync, 17 months ago

Add/WinNT/Graphics: Converted some optionally compiled 3D related tests and windbg extensions from VBOXR3STATIC to more appropriate templates and made them build again. Guard is now called VBOX_WITH_VBOXVIDEOWINDBG. bugref:10348

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.4 KB
Line 
1/* $Id: tstMvWnd.cpp 98141 2023-01-19 14:25:46Z vboxsync $ */
2/** @file
3 * ???
4 */
5
6/*
7 * Copyright (C) 2017-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#include <iprt/win/windows.h>
29#include <iprt/cdefs.h>
30
31#undef Assert
32#define Assert(_m) do {} while (0)
33#define vboxVDbgPrint(_m) do {} while (0)
34
35static LRESULT CALLBACK WindowProc(HWND hwnd,
36 UINT uMsg,
37 WPARAM wParam,
38 LPARAM lParam
39)
40{
41 if(uMsg == WM_DESTROY)
42 {
43 PostQuitMessage(0);
44 return 0;
45 }
46// switch(uMsg)
47// {
48// case WM_CLOSE:
49// vboxVDbgPrint((__FUNCTION__": got WM_CLOSE for hwnd(0x%x)", hwnd));
50// return 0;
51// case WM_DESTROY:
52// vboxVDbgPrint((__FUNCTION__": got WM_DESTROY for hwnd(0x%x)", hwnd));
53// return 0;
54// case WM_NCHITTEST:
55// vboxVDbgPrint((__FUNCTION__": got WM_NCHITTEST for hwnd(0x%x)\n", hwnd));
56// return HTNOWHERE;
57// }
58
59 return DefWindowProc(hwnd, uMsg, wParam, lParam);
60}
61
62#define VBOXDISPWND_NAME L"tstMvWnd"
63
64HRESULT tstMvWndCreate(DWORD w, DWORD h, HWND *phWnd)
65{
66 HRESULT hr = S_OK;
67 HINSTANCE hInstance = (HINSTANCE)GetModuleHandle(NULL);
68 /* Register the Window Class. */
69 WNDCLASS wc;
70 if (!GetClassInfo(hInstance, VBOXDISPWND_NAME, &wc))
71 {
72 wc.style = CS_OWNDC;
73 wc.lpfnWndProc = WindowProc;
74 wc.cbClsExtra = 0;
75 wc.cbWndExtra = 0;
76 wc.hInstance = hInstance;
77 wc.hIcon = NULL;
78 wc.hCursor = NULL;
79 wc.hbrBackground = NULL;
80 wc.lpszMenuName = NULL;
81 wc.lpszClassName = VBOXDISPWND_NAME;
82 if (!RegisterClass(&wc))
83 {
84 vboxVDbgPrint((__FUNCTION__": RegisterClass failed, winErr(%d)\n", GetLastError()));
85 hr = E_FAIL;
86 }
87 }
88
89 if (hr == S_OK)
90 {
91 HWND hWnd = CreateWindowEx(0 /*WS_EX_CLIENTEDGE*/,
92 VBOXDISPWND_NAME, VBOXDISPWND_NAME,
93 WS_OVERLAPPEDWINDOW,
94 0, 0,
95 w, h,
96 GetDesktopWindow() /* hWndParent */,
97 NULL /* hMenu */,
98 hInstance,
99 NULL /* lpParam */);
100 Assert(hWnd);
101 if (hWnd)
102 {
103 *phWnd = hWnd;
104 }
105 else
106 {
107 vboxVDbgPrint((__FUNCTION__": CreateWindowEx failed, winErr(%d)\n", GetLastError()));
108 hr = E_FAIL;
109 }
110 }
111
112 return hr;
113}
114static int g_Width = 400;
115static int g_Height = 300;
116static DWORD WINAPI tstMvWndThread(void *pvUser) RT_NOEXCEPT
117{
118 HWND hWnd = (HWND)pvUser;
119 RECT Rect;
120 BOOL bRc = GetWindowRect(hWnd, &Rect);
121 Assert(bRc);
122 if (bRc)
123 {
124 bRc = SetWindowPos(hWnd, HWND_TOPMOST,
125 0, /* int X */
126 0, /* int Y */
127 g_Width, //Rect.left - Rect.right,
128 g_Height, //Rect.bottom - Rect.top,
129 SWP_SHOWWINDOW);
130 Assert(bRc);
131 if (bRc)
132 {
133 int dX = 10, dY = 10;
134 int xMin = 5, xMax = 300;
135 int yMin = 5, yMax = 300;
136 int x = dX, y = dY;
137 do
138 {
139 bRc = SetWindowPos(hWnd, HWND_TOPMOST,
140 x, /* int X */
141 y, /* int Y */
142 g_Width, //Rect.left - Rect.right,
143 g_Height, //Rect.bottom - Rect.top,
144 SWP_SHOWWINDOW);
145
146 x += dX;
147 if (x > xMax)
148 x = xMin;
149 y += dY;
150 if (y > yMax)
151 y = yMin;
152
153 Sleep(5);
154 } while(1);
155 }
156 }
157
158 return 0;
159}
160
161int main(int argc, char **argv, char **envp)
162{
163 RT_NOREF(argc, argv, envp);
164 HWND hWnd;
165 HRESULT hr = tstMvWndCreate(200, 200, &hWnd);
166 Assert(hr == S_OK);
167 if (hr == S_OK)
168 {
169 HANDLE hThread = CreateThread(NULL /* LPSECURITY_ATTRIBUTES lpThreadAttributes */,
170 0 /* SIZE_T dwStackSize */,
171 tstMvWndThread,
172 hWnd,
173 0 /* DWORD dwCreationFlags */,
174 NULL /* pThreadId */);
175 Assert(hThread);
176 if (hThread)
177 {
178 MSG msg;
179 while (GetMessage(&msg, NULL, 0, 0))
180 {
181 TranslateMessage(&msg);
182 DispatchMessage(&msg);
183 }
184 }
185
186 DestroyWindow (hWnd);
187 }
188 return 0;
189}
190
191#ifndef IPRT_NO_CRT
192int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
193{
194 RT_NOREF(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
195 return main(__argc, __argv, environ);
196}
197#endif
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use