foobar2000 SDK  2015-08-03
Data Structures | Functions
WindowPositionUtils.h File Reference

Go to the source code of this file.

Data Structures

class  cfgDialogPosition
 
class  cfgDialogPositionData
 
struct  cfgDialogPositionData::DeOverlapState
 
class  cfgDialogPositionTracker
 
class  cfgDialogSizeTracker
 
class  cfgWindowSize
 
class  cfgWindowSizeTracker
 

Functions

static void AdjustRectToScreenArea (CRect &rc, CRect rcParent)
 
static BOOL AdjustWindowRectHelper (CWindow wnd, CRect &rc)
 
static BOOL CenterWindowAbove (CWindow wnd, CWindow wndParent)
 
static BOOL CenterWindowGetRect (CWindow wnd, CWindow wndParent, CRect &out)
 
 FB2K_STREAM_READER_OVERLOAD (cfgDialogPositionData)
 
 FB2K_STREAM_WRITER_OVERLOAD (cfgDialogPositionData)
 
static BOOL GetClientRectAsSC (CWindow wnd, CRect &rc)
 
static BOOL ShowWindowCentered (CWindow wnd, CWindow wndParent)
 

Data Structure Documentation

struct cfgDialogPositionData::DeOverlapState

Definition at line 170 of file WindowPositionUtils.h.

Data Fields
bool m_match
CWindow m_thisWnd
CPoint m_topLeft

Function Documentation

static void AdjustRectToScreenArea ( CRect &  rc,
CRect  rcParent 
)
static

Definition at line 6 of file WindowPositionUtils.h.

6  {
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);
15  }
16 }
static BOOL AdjustWindowRectHelper ( CWindow  wnd,
CRect &  rc 
)
static

Definition at line 1 of file WindowPositionUtils.h.

1  {
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);
4 }
static BOOL CenterWindowAbove ( CWindow  wnd,
CWindow  wndParent 
)
static

Definition at line 41 of file WindowPositionUtils.h.

41  {
42  CRect rc;
43  if (!CenterWindowGetRect(wnd, wndParent, rc)) return FALSE;
44  return wnd.SetWindowPos(NULL,rc,SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
45 }
static BOOL CenterWindowGetRect(CWindow wnd, CWindow wndParent, CRect &out)
static BOOL CenterWindowGetRect ( CWindow  wnd,
CWindow  wndParent,
CRect &  out 
)
static

Definition at line 28 of file WindowPositionUtils.h.

28  {
29  CRect parent, child;
30  if (!wndParent.GetWindowRect(&parent) || !wnd.GetWindowRect(&child)) return FALSE;
31  {
32  CPoint origin = parent.CenterPoint();
33  origin.Offset( - child.Width() / 2, - child.Height() / 2);
34  child.OffsetRect( origin - child.TopLeft() );
35  }
36  AdjustRectToScreenArea(child, parent);
37  out = child;
38  return TRUE;
39 }
static void AdjustRectToScreenArea(CRect &rc, CRect rcParent)
FB2K_STREAM_READER_OVERLOAD ( cfgDialogPositionData  )

Definition at line 272 of file WindowPositionUtils.h.

272  {
273  stream >> value.m_width >> value.m_height;
274  try {
275  stream >> value.m_posX >> value.m_posY >> value.m_dpiX >> value.m_dpiY;
276  } catch(exception_io_data) {
277  value.m_posX = value.m_posY = cfgDialogPositionData::posInvalid;
278  value.m_dpiX = value.m_dpiY = cfgDialogPositionData::dpiInvalid;
279  }
280  return stream;
281 }
FB2K_STREAM_WRITER_OVERLOAD ( cfgDialogPositionData  )

Definition at line 282 of file WindowPositionUtils.h.

282  {
283  return stream << value.m_width << value.m_height << value.m_posX << value.m_posY << value.m_dpiX << value.m_dpiY;
284 }
static BOOL GetClientRectAsSC ( CWindow  wnd,
CRect &  rc 
)
static

Definition at line 18 of file WindowPositionUtils.h.

18  {
19  CRect temp;
20  if (!wnd.GetClientRect(temp)) return FALSE;
21  if (temp.IsRectNull()) return FALSE;
22  if (!wnd.ClientToScreen(temp)) return FALSE;
23  rc = temp;
24  return TRUE;
25 }
static BOOL ShowWindowCentered ( CWindow  wnd,
CWindow  wndParent 
)
static

Definition at line 47 of file WindowPositionUtils.h.

47  {
48  CRect rc;
49  if (!CenterWindowGetRect(wnd, wndParent, rc)) return FALSE;
50  return wnd.SetWindowPos(HWND_TOP,rc,SWP_NOSIZE | SWP_SHOWWINDOW);
51 }
static BOOL CenterWindowGetRect(CWindow wnd, CWindow wndParent, CRect &out)