Operator Console
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions | Variables
foo.cpp File Reference

Functions

void Resize ()
 
BOOL CALLBACK OffsetChildPos (HWND hwnd, LPARAM lParam)
 
void GetImageWindowDelta ()
 
void GetWindowCenter (CWnd *wnd, CPoint *center)
 
void GetWindowSize (CWnd *wnd, int *width, int *height, CRect *bnds)
 
void OffsetWindowPos (CWnd *wnd, int dx, int dy)
 
void Resize (CWnd *dialog, CWnd *window, int width, int height)
 
void GetImageWindowDelta (int width, int height)
 
void OffsetWindowSize (CWnd *wnd, int dx, int dy)
 
void OffsetWindowPos (CWnd *parent, CWnd *wnd, int dx, int dy)
 

Variables

CSize m_delta
 
CWnd * m_dialog
 
CWnd * m_window
 

Function Documentation

void GetImageWindowDelta ( )

Referenced by Resize().

Here is the caller graph for this function:

void GetImageWindowDelta ( int  width,
int  height 
)

References GetWindowSize(), and m_delta.

57 {
58  int itemWidth, itemHeight;
59 
60 
61  //
62  // Get the current width and height of the image dialog item
63  //
64  GetWindowSize(&c_image, &itemWidth, &itemHeight);
65 
66  //
67  // Get the difference in the width and height.
68  // This is how much the sizes of the image item and dialog need to be increased.
69  // This is also how much we need to move the other dialog items to accomodate the new image size.
70  //
71  m_delta.cx = width - itemWidth;
72  m_delta.cy = height - itemHeight;
73 }
void GetWindowSize(CWnd *wnd, int *width, int *height, CRect *bnds)
Definition: foo.cpp:134
CSize m_delta
Definition: foo.cpp:8
width
Definition: calculation_checks.m:1
height
Definition: calculation_checks.m:2

Here is the call graph for this function:

void GetWindowCenter ( CWnd *  wnd,
CPoint *  center 
)
124 {
125  if (wnd != NULL && center != NULL)
126  {
127  CRect rect;
128  wnd->GetWindowRect(rect);
129  *center = rect.CenterPoint();
130  }
131 }
void GetWindowSize ( CWnd *  wnd,
int *  width,
int *  height,
CRect *  bnds 
)

Referenced by GetImageWindowDelta(), and OffsetWindowSize().

135 {
136  if (wnd != NULL)
137  {
138  CRect rect;
139 
140  CRect *r = (bnds == NULL) ? &rect : bnds;
141 
142  wnd->GetWindowRect(r);
143 
144  if (width != NULL)
145  {
146  *width = r->Width();
147  }
148 
149  if (height != NULL)
150  {
151  *height = r->Height();
152  }
153  }
154 }
width
Definition: calculation_checks.m:1
height
Definition: calculation_checks.m:2

Here is the caller graph for this function:

BOOL CALLBACK OffsetChildPos ( HWND  hwnd,
LPARAM  lParam 
)

References MoveData::delta, MoveData::dialog, height, MoveData::skip, and width.

Referenced by Resize().

99 {
100  MoveData *data = (MoveData *)lParam;
101  RECT rect;
102  int width, height;
103  POINT ul;
104 
105  if (hwnd != data->skip)
106  {
107  ::GetWindowRect(hwnd, &rect); // rect is in screen coords
108 
109  ul.x = rect.left;
110  ul.y = rect.top;
111  ::ScreenToClient(data->dialog, &ul); // make ul coords relative to dialog
112 
113  width = rect.right - rect.left;
114  height = rect.bottom - rect.top;
115 
116  ::MoveWindow(hwnd, ul.x + data->delta->cx, ul.y + data->delta->cy, width, height, TRUE);
117  }
118 
119  return TRUE;
120 }
CSize * delta
points to a CSize that details how much to shift the window horizontally and vertically ...
Definition: ResizeDlg.cpp:27
A struct for containing data relevant for moving a window.
Definition: ResizeDlg.cpp:25
HWND dialog
pointer to the dialog that needs to be moved
Definition: ResizeDlg.cpp:29
width
Definition: calculation_checks.m:1
height
Definition: calculation_checks.m:2
HWND skip
pointer to the window that should not be moved i.e. the main window during a resize event ...
Definition: ResizeDlg.cpp:28

Here is the caller graph for this function:

void OffsetWindowPos ( CWnd *  wnd,
int  dx,
int  dy 
)
void OffsetWindowPos ( CWnd *  parent,
CWnd *  wnd,
int  dx,
int  dy 
)
86 {
87  if (wnd != NULL)
88  {
89  CRect rect;
90  wnd->GetWindowRect(&rect); // current window location in screen coordinates
91  parent->ScreenToClient(&rect); // current location in client coords (relative to client rect of parent)
92  rect.OffsetRect(dx, dy); // offset the rect by (dx, dy)
93  wnd->MoveWindow(&rect, TRUE); // move the window
94  }
95 }
void OffsetWindowSize ( CWnd *  wnd,
int  dx,
int  dy 
)

References GetWindowSize(), height, and width.

Referenced by Resize().

77 {
78  int width, height;
79 
80  GetWindowSize(wnd, &width, &height);
81  wnd->SetWindowPos(NULL, 0, 0, width + dx, height + dy, SWP_NOMOVE | SWP_NOZORDER);
82 }
void GetWindowSize(CWnd *wnd, int *width, int *height, CRect *bnds)
Definition: foo.cpp:134
width
Definition: calculation_checks.m:1
height
Definition: calculation_checks.m:2

Here is the call graph for this function:

Here is the caller graph for this function:

void Resize ( )
void Resize ( CWnd *  dialog,
CWnd *  window,
int  width,
int  height 
)

References MoveData::delta, MoveData::dialog, GetImageWindowDelta(), m_delta, OffsetChildPos(), OffsetWindowSize(), and MoveData::skip.

14 {
15  MoveData data;
16  int dy;
17 
18  //
19  // Get the difference in size between the window an the desired width and height
20  //
22 
23  //
24  // Resize the window
25  //
26  OffsetWindowSize(window, m_delta.cx, m_delta.cy);
27 
28  if (m_delta.cx != 0 || m_delta.cy != 0)
29  {
30  //
31  // Resize the dialog. It can grow or shrink in x, but
32  // its height may not be less than its original height.
33  //
34  dy = m_delta.cy > 0 ? m_delta.cy : 0;
35  OffsetWindowSize(dialog, m_delta.cx, dy); // resize the dialog
36 
37  //
38  // Move the rest of the items dx pixels to the left or right. We're not
39  // going to change the y coordinates, so we set m_delta.cy to 0.
40  //
41  m_delta.cy = 0;
42 
43  //
44  // Move all of the dialog items to compensate for the new size of 'window'. EnumChildWindows()
45  // will call OffsetChildPos() for each of the Dialog's child windows (i.e. all dialog items).
46  // We want to move every item except for the image item.
47  //
48  data.delta = &m_delta;
49  data.skip = window->m_hWnd; // we don't want to move 'window'
50  data.dialog = dialog->m_hWnd; // handle to the dialog window (we need this for converting coordinates)
51  ::EnumChildWindows(dialog->m_hWnd, OffsetChildPos, (LPARAM)&data);
52  }
53 }
CSize * delta
points to a CSize that details how much to shift the window horizontally and vertically ...
Definition: ResizeDlg.cpp:27
void OffsetWindowSize(CWnd *wnd, int dx, int dy)
Definition: foo.cpp:76
CSize m_delta
Definition: foo.cpp:8
void GetImageWindowDelta()
A struct for containing data relevant for moving a window.
Definition: ResizeDlg.cpp:25
HWND dialog
pointer to the dialog that needs to be moved
Definition: ResizeDlg.cpp:29
BOOL CALLBACK OffsetChildPos(HWND hwnd, LPARAM lParam)
Definition: foo.cpp:98
HWND skip
pointer to the window that should not be moved i.e. the main window during a resize event ...
Definition: ResizeDlg.cpp:28

Here is the call graph for this function:

Variable Documentation

CSize m_delta

Referenced by GetImageWindowDelta(), and Resize().

CWnd* m_dialog
CWnd* m_window