MCPcopy Create free account
hub / github.com/davisking/dlib / make_window

Function make_window

dlib/gui_core/gui_core_kernel_1.cpp:1474–1545  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1472 // ----------------------------------------------------------------------------------------
1473
1474 HWND make_window (
1475 DWORD dwStyle_
1476 )
1477 /*!
1478 ensures
1479 - creates a window by calling CreateWindow and passes on the
1480 dwStyle argument.
1481 - returns the HWND that is returned by CreateWindow
1482 - ensures that CreateWindow is called from the event handler thread
1483 - if (it was unable to create a window) then
1484 - returns NULL or helper_window
1485 !*/
1486 {
1487 using namespace gui_core_kernel_1_globals;
1488 auto globals = global_data();
1489 // if we are running in the event handling thread then just call
1490 // CreateWindow directly
1491 if (get_thread_id() == globals->event_thread_id)
1492 {
1493 // if this is stupposed to be a popup window then do the popup window thing
1494 if (dwStyle_ == WS_CHILD)
1495 {
1496 TCHAR nothing[] = TEXT("");
1497 HWND tmp = CreateWindowEx (WS_EX_TOOLWINDOW|WS_EX_TOPMOST, globals->window_class_name, nothing,
1498 dwStyle_,
1499 CW_USEDEFAULT, CW_USEDEFAULT,
1500 CW_USEDEFAULT, CW_USEDEFAULT,
1501 globals->helper_window, NULL, globals->hInstance, NULL);
1502 SetParent(tmp,NULL);
1503 return tmp;
1504 }
1505 else
1506 {
1507 TCHAR nothing[] = TEXT("");
1508 return CreateWindow (globals->window_class_name, nothing,
1509 dwStyle_,
1510 CW_USEDEFAULT, CW_USEDEFAULT,
1511 CW_USEDEFAULT, CW_USEDEFAULT,
1512 NULL, NULL, globals->hInstance, NULL);
1513 }
1514 }
1515 else
1516 {
1517 auto_mutex M(globals->window_table.get_mutex());
1518 // wait for our chance to make a new window request
1519 while (globals->request_new_window)
1520 globals->et_signaler.wait();
1521
1522
1523 globals->dwStyle = dwStyle_;
1524 if (PostMessage(globals->helper_window,WM_USER+CREATE_WINDOW,0,0)==0)
1525 {
1526 throw gui_error("Unable to schedule function for execution in event handling thread.");
1527 }
1528
1529 // wait for our request to be serviced
1530 while (globals->new_window == NULL)
1531 globals->et_signaler.wait();

Callers 1

base_windowMethod · 0.85

Calls 5

global_dataClass · 0.85
gui_errorClass · 0.85
get_thread_idFunction · 0.50
waitMethod · 0.45
broadcastMethod · 0.45

Tested by

no test coverage detected