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

Method set_pos

dlib/gui_core/gui_core_kernel_1.cpp:1888–1944  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1886// ----------------------------------------------------------------------------------------
1887
1888 void base_window::
1889 set_pos (
1890 long x_,
1891 long y_
1892 )
1893 {
1894 using namespace gui_core_kernel_1_globals;
1895 auto_mutex M(wm);
1896 if (has_been_destroyed == true)
1897 return;
1898
1899 if (get_thread_id() == globals->event_thread_id)
1900 {
1901 RECT info;
1902 GetWindowRect(hwnd,&info);
1903 int width = info.right - info.left;
1904 int height = info.bottom - info.top;
1905
1906 MoveWindow(
1907 hwnd,
1908 x_,
1909 y_,
1910 width,
1911 height,
1912 TRUE);
1913
1914 }
1915 else
1916 {
1917 RECT info;
1918 GetWindowRect(hwnd,&info);
1919 int width = info.right - info.left;
1920 int height = info.bottom - info.top;
1921
1922
1923
1924 // call the MoveWindow function with our arguments. We
1925 // have to do this because the MoveWindow() apparently blocks
1926 // until something happens in the event thread so we have to
1927 // do this to avoid possible deadlocks.
1928 globals->move_window_hwnd = hwnd;
1929 globals->move_window_x = x_;
1930 globals->move_window_y = y_;
1931 globals->move_window_width = width;
1932 globals->move_window_height = height;
1933 globals->move_window_done = false;
1934
1935 if (PostMessage(globals->helper_window,WM_USER+CALL_MOVE_WINDOW,0,0)==0)
1936 {
1937 throw gui_error("Unable to schedule MoveWindow function for execution in event handling thread.");
1938 }
1939
1940 // wait for any MoveWindow calls to finish
1941 while (globals->move_window_done == false)
1942 globals->et_signaler.wait();
1943 }
1944 }
1945

Callers

nothing calls this directly

Calls 3

gui_errorClass · 0.85
get_thread_idFunction · 0.50
waitMethod · 0.45

Tested by

no test coverage detected