Scope
ExperimentSettingsSheet.cpp
1 #include "StdAfx.h"
2 #include "ExperimentSettingsSheet.h"
3 
4 namespace scope {
5  namespace gui {
6 
7 HWND CExperimentSettingsSheet::Create(const HWND hWndParent, const int nStartPage, const CRect & rc) {
8  ATLASSERT(m_hWnd == NULL);
9 
10  // Add pages to the property sheet
11  AddPage(pageScanModesSettings);
12  AddPage(pageStackSettings);
13  AddPage(pageTimeSeriesSettings);
14  AddPage(pageBehaviorSettings);
15 
16  // and do some magic to make it work
17  m_psh.dwFlags = PSH_NOAPPLYNOW | PSH_MODELESS | PSH_USECALLBACK;
18  m_psh.hwndParent = hWndParent;
19  m_psh.phpage = (HPROPSHEETPAGE*)m_arrPages.GetData();
20  m_psh.nPages = m_arrPages.GetSize();
21  m_psh.pfnCallback = CExperimentSettingsSheet::PropSheetCallback;
22 
23  _Module.AddCreateWndData(&m_thunk.cd, this);
24 
25  HWND hWnd = (HWND)::PropertySheet(&m_psh);
26  _CleanUpPages(); // ensure clean-up, required if call failed
27 
28  ATLASSERT(m_hWnd == hWnd);
29 
30  if ( hWnd ) {
31  int nAdjX = GetSystemMetrics(SM_CXDLGFRAME) * 2;
32  int nAdjY = GetSystemMetrics(SM_CYDLGFRAME) * 2;
33  SetWindowPos(NULL, rc.left - nAdjX, rc.top - nAdjY, rc.Width(), rc.Height(),
34  SWP_NOZORDER|SWP_NOACTIVATE);
35  }
36 
37  SetActivePage(nStartPage);
38  return hWnd;
39 }
40 
41 int CALLBACK CExperimentSettingsSheet::PropSheetCallback(HWND hWnd, UINT uMsg, LPARAM lParam) {
42  int nRetVal = 0;
43 
44  if (uMsg == PSCB_INITIALIZED) {
45  ATLASSERT(hWnd != NULL);
46  CExperimentSettingsSheet* pT = (CExperimentSettingsSheet*)_Module.ExtractCreateWndData();
47  pT->SubclassWindow(hWnd); // subclass the sheet window
48  pT->_CleanUpPages(); // remove page handles array
49  }
50  else if (uMsg == PSCB_PRECREATE) {
51  LPDLGTEMPLATE pTemplate = (LPDLGTEMPLATE)lParam;
52  ATLASSERT(pTemplate);
53 
54  DWORD dwRemove = WS_POPUP|WS_SYSMENU|WS_CAPTION|DS_MODALFRAME;
55  DWORD dwAdd = WS_CHILD|WS_VISIBLE|WS_TABSTOP|DS_CONTEXTHELP|DS_3DLOOK|DS_CONTROL;
56 
57  pTemplate->style = (pTemplate->style & ~dwRemove) | dwAdd;
58  pTemplate->dwExtendedStyle |= WS_EX_CONTROLPARENT;
59  nRetVal = 1;
60  }
61 
62  return nRetVal;
63 }
64 
65 LRESULT CExperimentSettingsSheet::OnSelChange(WPARAM wParam, LPNMHDR pnmHdr, BOOL & bHandled) {
66  return DefWindowProc(WM_NOTIFY, wParam, (LPARAM)pnmHdr);
67 }
68 
69 }}
CTimeSeriesSettingsPage pageTimeSeriesSettings
Page for timeseries stuff.
CStackSettingsPage pageStackSettings
Page for stack stuff.
CScanModesSettingsPage pageScanModesSettings
Page for selecting different scan modes.
This is the include file for standard system include files, or project specific include files that ar...
HWND Create(const HWND hWndParent, const int nStartPage, const CRect &rc)
Adds the pages and do some magic.
Settings sheet for the various property sheets dealing with different experiment types.
CAppModule _Module
The ATL application module.
Definition: scope.cpp:10
CBehaviorSettingsPage pageBehaviorSettings
Page for behavior triggered acquisition stuff.