Scope
MovementSettingsSheet.cpp
1 #include "StdAfx.h"
2 #include "MovementSettingsSheet.h"
3 
4 namespace scope {
5  namespace gui {
6 
8  uint32_t area = 0;
9  std::generate(std::begin(fpupages), std::end(fpupages), [&]() {
10  return std::unique_ptr<CFPUControlPage>(new CFPUControlPage(area++)); } );
11 }
12 
13 HWND CMovementSettingsSheet::Create(const HWND hWndParent, const int nStartPage, const CRect & rc) {
14  ATLASSERT(m_hWnd == NULL);
15 
16  AddPage(xyzcontrolpage);
17  for ( auto& fpucp : fpupages )
18  AddPage(*fpucp);
19 
20  m_psh.dwFlags = PSH_NOAPPLYNOW | PSH_MODELESS | PSH_USECALLBACK;
21  m_psh.hwndParent = hWndParent;
22  m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData();
23  m_psh.nPages = m_arrPages.GetSize();
25 
26  _Module.AddCreateWndData(&m_thunk.cd, this);
27 
28  HWND hWnd = (HWND)::PropertySheet(&m_psh);
29  _CleanUpPages(); // ensure clean-up, required if call failed
30  ATLASSERT(m_hWnd == hWnd);
31 
32  if ( hWnd ) {
33  int nAdjX = GetSystemMetrics(SM_CXDLGFRAME) * 2;
34  int nAdjY = GetSystemMetrics(SM_CYDLGFRAME) * 2;
35  SetWindowPos(NULL, rc.left - nAdjX, rc.top - nAdjY, rc.Width(), rc.Height(),
36  SWP_NOZORDER|SWP_NOACTIVATE);
37  }
38 
39  SetActivePage(nStartPage);
40  return hWnd;
41 }
42 
43 int CALLBACK CMovementSettingsSheet::PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam) {
44  int nRetVal = 0;
45 
46  if (uMsg == PSCB_INITIALIZED) {
47  ATLASSERT(hWnd != NULL);
48  CMovementSettingsSheet* pT = (CMovementSettingsSheet*)_Module.ExtractCreateWndData();
49  pT->SubclassWindow(hWnd); // subclass the sheet window
50  pT->_CleanUpPages(); // remove page handles array
51  }
52  else if (uMsg == PSCB_PRECREATE) {
53  LPDLGTEMPLATE pTemplate = (LPDLGTEMPLATE)lParam;
54  ATLASSERT(pTemplate);
55 
56  DWORD dwRemove = WS_POPUP|WS_SYSMENU|WS_CAPTION|DS_MODALFRAME;
57  DWORD dwAdd = WS_CHILD|WS_VISIBLE|WS_TABSTOP|DS_CONTEXTHELP|DS_3DLOOK|DS_CONTROL;
58 
59  pTemplate->style = (pTemplate->style & ~dwRemove) | dwAdd;
60  pTemplate->dwExtendedStyle |= WS_EX_CONTROLPARENT;
61  nRetVal = 1;
62  }
63 
64  return nRetVal;
65 }
66 
67 LRESULT CMovementSettingsSheet::OnSelChange(WPARAM wParam, LPNMHDR pnmHdr, BOOL & bHandled) {
68  return DefWindowProc(WM_NOTIFY, wParam, (LPARAM)pnmHdr);
69 }
70 
71 }}
Settings sheet that has settings pages for all movement/stages related stuff, resided inside the CMov...
HWND Create(const HWND hWndParent, const int nStartPage, const CRect &rc)
Adds all the settingspages.
CMovementSettingsSheet(void)
Creates the CFPUControlPages (they do not have a default constructor, so we need pointers and constru...
This is the include file for standard system include files, or project specific include files that ar...
Property page for FPU stage settings.
static int CALLBACK PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam)
We need this for whatever (see some WTL dialog tutorial)...
CXYZControlPage xyzcontrolpage
a settings page for XYZ stage
CAppModule _Module
The ATL application module.
Definition: scope.cpp:10
std::array< std::unique_ptr< CFPUControlPage >, SCOPE_NAREAS > fpupages
settings pages for each FPU