MCPcopy Create free account
hub / github.com/NVIDIA-RTX/RTXPT / ShowProgressWindow

Function ShowProgressWindow

Rtxpt/SampleCommon/SampleCommon.cpp:225–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

223#endif
224
225void ShowProgressWindow(int slotIndex)
226{
227#ifdef _WIN32
228 ProgressBarGlobals & slot = g_ProgressSlots[slotIndex];
229
230 const char* wClassName = "ProgressWindowClass";
231 HINSTANCE hInstance = GetModuleHandle(NULL);
232 static std::mutex registerClassMtx;
233 static bool registerClassFlag = false;
234 {
235 std::lock_guard<std::mutex> lock(registerClassMtx);
236 if (!registerClassFlag)
237 {
238 INITCOMMONCONTROLSEX icex = { sizeof(INITCOMMONCONTROLSEX), ICC_PROGRESS_CLASS };
239 InitCommonControlsEx(&icex);
240 WNDCLASS wc = {};
241 wc.lpfnWndProc = ProgressWndProc;
242 wc.hInstance = hInstance;
243 wc.lpszClassName = wClassName;
244 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
245
246 if (!RegisterClass(&wc))
247 ShowLastError();
248 registerClassFlag = true;
249 }
250 }
251
252 int width = 600;
253 int height = 100;
254
255 // Default position if no parent
256 int x = CW_USEDEFAULT;
257 int y = CW_USEDEFAULT;
258
259 HWND hParent = g_hActiveParentWindow.load();
260 HWND hwnd = NULL;
261 {
262 std::lock_guard guard(slot.Mutex);
263 if (!slot.Active) // already finished? don't even open the window
264 return;
265
266 if (hParent)
267 {
268 RECT parentRect;
269 GetWindowRect(hParent, &parentRect);
270
271 x = parentRect.left + (parentRect.right - parentRect.left - width) / 2;
272 y = parentRect.top + (parentRect.bottom - parentRect.top - height*3) / 2;
273 y += height * slotIndex;
274 }
275
276 slot.hMainWindow = CreateWindowEx( WS_EX_TOOLWINDOW, wClassName, slot.Title.c_str(),
277 WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, x, y, width, height,
278 NULL/*hParent*/, NULL, hInstance, reinterpret_cast<LPVOID>(&slot));
279 // can't use hParent as a parent because that ties our child window to using the main thread's message loop - not sure what the proper solution is here
280
281 if (slot.hMainWindow == NULL)
282 {

Callers

nothing calls this directly

Calls 1

ShowLastErrorFunction · 0.85

Tested by

no test coverage detected