VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Display/wddm/dbg/tstMvWnd.cpp@ 33929

Last change on this file since 33929 was 32175, checked in by vboxsync, 15 years ago

3D: fps logging, wddm/3d/aero: simple perf test app

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette