2 const DWORD style = wnd.GetWindowLong(GWL_STYLE), exstyle = wnd.GetWindowLong(GWL_EXSTYLE);
3 return AdjustWindowRectEx(&rc,style,(style & WS_POPUP) ? wnd.GetMenu() != NULL : FALSE, exstyle);
7 HMONITOR monitor = MonitorFromRect(rcParent,MONITOR_DEFAULTTONEAREST);
8 MONITORINFO mi = {
sizeof(MONITORINFO)};
9 if (GetMonitorInfo(monitor,&mi)) {
10 const CRect clip = mi.rcWork;
11 if (rc.right > clip.right) rc.OffsetRect(clip.right - rc.right, 0);
12 if (rc.bottom > clip.bottom) rc.OffsetRect(0, clip.bottom - rc.bottom);
13 if (rc.left < clip.left) rc.OffsetRect(clip.left - rc.left, 0);
14 if (rc.top < clip.top) rc.OffsetRect(0, clip.top - rc.top);
20 if (!wnd.GetClientRect(temp))
return FALSE;
21 if (temp.IsRectNull())
return FALSE;
22 if (!wnd.ClientToScreen(temp))
return FALSE;
30 if (!wndParent.GetWindowRect(&parent) || !wnd.GetWindowRect(&child))
return FALSE;
32 CPoint origin = parent.CenterPoint();
33 origin.Offset( - child.Width() / 2, - child.Height() / 2);
34 child.OffsetRect( origin - child.TopLeft() );
44 return wnd.SetWindowPos(NULL,rc,SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
50 return wnd.SetWindowPos(HWND_TOP,rc,SWP_NOSIZE | SWP_SHOWWINDOW);
76 SetWindowPos(p_wnd,NULL,0,0,rect.right-rect.left,rect.bottom-rect.top,SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
102 if (uMsg == WM_INITDIALOG)
Apply(hWnd);
133 CWindow wndParent = wnd.GetParent();
134 UINT flags = SWP_NOACTIVATE | SWP_NOZORDER;
143 if (wndParent != NULL) {
147 rc.MoveToXY( rcParent.TopLeft() + CPoint(
m_posX,
m_posY) );
149 CPoint center = rcParent.CenterPoint();
150 rc.MoveToXY( center.x - rc.Width() / 2, center.y - rc.Height() / 2);
159 CRect rcAdjust(0,0,1,1);
160 if (wndParent != NULL) {
162 if (wndParent.GetWindowRect(temp)) rcAdjust = temp;
168 return wnd.SetWindowPos(NULL, rc, flags);
177 if (wnd != state->
m_thisWnd && IsWindowVisible(wnd) ) {
179 if (GetWindowRect(wnd, rc)) {
181 state->
m_match =
true;
return FALSE;
190 EnumThreadWindows(GetCurrentThreadId(),
MyEnumChildProc, reinterpret_cast<LPARAM>(&state));
194 return pfc::max_t<int>(GetSystemMetrics(SM_CYCAPTION),1);
200 rc.OffsetRect(delta,delta);
210 CWindow parent = wnd.GetParent();
211 if (parent != NULL) {
214 m_posX = rc.left - rcParent.left;
215 m_posY = rc.top - rcParent.top;
228 if (screenDPI.cx == 0 || screenDPI.cy == 0) {
229 PFC_ASSERT(!
"Should not get here - something seriously wrong with the OS");
251 if (!wndParent.IsIconic()) {
252 return wndParent.GetWindowRect(rc);
254 WINDOWPLACEMENT pl = {
sizeof(pl)};
255 if (!wndParent.GetWindowPlacement(&pl))
return FALSE;
256 rc = pl.rcNormalPosition;
273 stream >> value.m_width >> value.m_height;
275 stream >> value.m_posX >> value.m_posY >> value.m_dpiX >> value.m_dpiY;
276 }
catch(exception_io_data) {
283 return stream << value.m_width << value.m_height << value.m_posX << value.m_posY << value.m_dpiX << value.m_dpiY;
299 if (uMsg == WM_CREATE || uMsg == WM_INITDIALOG) {
302 m_var.AddWindow(m_wnd);
303 }
else if (uMsg == WM_DESTROY) {
304 PFC_ASSERT( hWnd == m_wnd );
313 m_var.RemoveWindow(m_wnd);
BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
static void AdjustRectToScreenArea(CRect &rc, CRect rcParent)
pfc::avltree_t< CWindow > m_windows
static BOOL GetParentWndRect(CWindow wndParent, CRect &rc)
static BOOL GetClientRectAsSC(CWindow wnd, CRect &rc)
void AddWindow(CWindow wnd)
BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
BOOL ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT &lResult)
cfgDialogPosition & m_var
static int DeOverlapDelta()
typedef BOOL(WINAPI *pPowerSetRequest_t)(__in HANDLE PowerRequest
static BOOL AdjustWindowRectHelper(CWindow wnd, CRect &rc)
FB2K_STREAM_WRITER_OVERLOAD(cfgDialogPositionData)
void RemoveWindow(CWindow wnd)
static void DeOverlap(CWindow wnd, CRect &rc)
BOOL StoreConfig(CWindow wnd)
void get_data_raw(stream_writer *p_stream, abort_callback &p_abort)
Retrieves state of the variable. Called only from main thread, when writing configuration file...
static BOOL ShowWindowCentered(CWindow wnd, CWindow wndParent)
void set_data_raw(stream_reader *p_stream, t_size p_sizehint, abort_callback &p_abort)
Sets state of the variable. Called only from main thread, when reading configuration file...
const_iterator first() const
cfgDialogPosition(const GUID &id)
void get_data_raw(stream_writer *p_stream, abort_callback &p_abort)
Retrieves state of the variable. Called only from main thread, when writing configuration file...
void set_data_raw(stream_reader *p_stream, t_size p_sizehint, abort_callback &p_abort)
Sets state of the variable. Called only from main thread, when reading configuration file...
static BOOL CALLBACK MyEnumChildProc(HWND wnd, LPARAM param)
static bool DeOverlapTest(CWindow wnd, CPoint topLeft)
void OverrideDefaultSize(t_uint32 width, t_uint32 height)
~cfgDialogPositionTracker()
cfgWindowSize(const GUID &p_guid)
static BOOL CenterWindowAbove(CWindow wnd, CWindow wndParent)
static BOOL CenterWindowGetRect(CWindow wnd, CWindow wndParent, CRect &out)
Base class for configuration variable classes; provides self-registration mechaisms and methods to se...
cfgDialogPositionTracker(cfgDialogPosition &p_var)
FB2K_STREAM_READER_OVERLOAD(cfgDialogPositionData)
cfgWindowSizeTracker(cfgWindowSize &p_var)
BOOL ApplyConfig(CWindow wnd)
bool contains(const t_param &p_item) const
cfgDialogSizeTracker(cfgWindowSize &p_var)