MCPcopy Create free account
hub / github.com/crownengine/crown / run

Method run

src/device/main_windows.cpp:367–488  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

365 }
366
367 int run()
368 {
369 HINSTANCE instance = (HINSTANCE)GetModuleHandle(NULL);
370 WNDCLASSEX wnd;
371 memset(&wnd, 0, sizeof(wnd));
372 wnd.cbSize = sizeof(wnd);
373 wnd.style = CS_HREDRAW | CS_VREDRAW;
374 wnd.lpfnWndProc = window_proc;
375 wnd.hInstance = instance;
376 wnd.hIcon = LoadIcon(NULL, IDI_APPLICATION);
377 wnd.hCursor = LoadCursor(NULL, IDC_ARROW);
378 wnd.lpszClassName = "crown";
379 wnd.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
380 RegisterClassExA(&wnd);
381
382 DWORD style = 0;
383 DWORD exstyle = 0;
384 if (_options->_parent_window == 0) {
385 style |= WS_OVERLAPPEDWINDOW;
386 } else {
387 style |= WS_POPUP;
388 exstyle |= WS_EX_TRANSPARENT | WS_EX_LAYERED | WS_EX_NOACTIVATE;
389 }
390 if (_options->_keep_above)
391 exstyle |= WS_EX_TOPMOST;
392
393 RECT rect;
394 rect.left = 0;
395 rect.top = 0;
396 rect.right = _options->_window_width.value();
397 rect.bottom = _options->_window_height.value();
398 AdjustWindowRect(&rect, style, FALSE);
399
400 _hwnd = CreateWindowExA(exstyle
401 , "crown"
402 , "Crown"
403 , style
404 , _options->_window_x
405 , _options->_window_y
406 , rect.right - rect.left
407 , rect.bottom - rect.top
408 , 0
409 , NULL
410 , instance
411 , NULL
412 );
413 CE_ASSERT(_hwnd != NULL, "CreateWindowA: GetLastError = %d", GetLastError());
414
415 if (_options->_parent_window != 0)
416 SetParent(_hwnd, (HWND)(UINT_PTR)_options->_parent_window);
417
418 RAWINPUTDEVICE rid;
419 rid.usUsagePage = 0x01;
420 rid.usUsage = 0x06;
421 rid.dwFlags = RIDEV_NOLEGACY;
422 rid.hwndTarget = _hwnd;
423 RegisterRawInputDevices(&rid, 1, sizeof(rid));
424

Callers 1

mainFunction · 0.45

Calls 8

memsetFunction · 0.85
main_runtimeFunction · 0.85
exit_codeMethod · 0.80
sleepFunction · 0.50
valueMethod · 0.45
startMethod · 0.45
updateMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected