tagging release
[dasher.git] / trunk / Src / Win32 / Widgets / PrefsPageBase.cpp
blob73de4bee1fd0c4e23c9519bb8ddab7b49c6ebf72
1 // PrefsPageBase.cpp
2 //
3 /////////////////////////////////////////////////////////////////////////////
4 //
5 // Copyright (c) 2002 Iain Murray, Inference Group, Cavendish, Cambridge.
6 //
7 /////////////////////////////////////////////////////////////////////////////
9 #include "WinCommon.h"
11 #include "PrefsPageBase.h"
12 //#include "../resource.h"
14 //#include <utility> // for std::pair
16 using namespace Dasher;
17 using namespace std;
19 // Track memory leaks on Windows to the line that new'd the memory
20 #ifdef _WIN32
21 #ifdef _DEBUG
22 #define DEBUG_NEW new( _NORMAL_BLOCK, THIS_FILE, __LINE__ )
23 #define new DEBUG_NEW
24 #undef THIS_FILE
25 static char THIS_FILE[] = __FILE__;
26 #endif
27 #endif
29 CPrefsPageBase::CPrefsPageBase(HWND Parent, CDasherInterfaceBase *DI, CAppSettings *pAppSettings)
30 :m_pDasherInterface(DI), m_pAppSettings(pAppSettings) {
31 m_hwnd = 0;
32 m_hPropertySheet = 0;
35 LRESULT CPrefsPageBase::WndProc(HWND Window, UINT message, WPARAM wParam, LPARAM lParam) {
37 NMHDR *pNMHDR;
38 switch (message) {
39 case WM_INITDIALOG:
40 if(!m_hwnd) { // If this is the initial dialog for the first time
41 m_hwnd = Window;
42 PopulateList();
44 return TRUE;
45 break;
46 case WM_COMMAND:
47 switch (HIWORD(wParam)) {
48 case BN_CLICKED:
49 case EN_CHANGE:
50 //case CBN_SELCHANGE: // value is same as LBN_SELCHANGE
51 case LBN_SELCHANGE:
52 if(m_hPropertySheet != 0 && m_hwnd != 0) {
53 PropSheet_Changed(m_hPropertySheet, m_hwnd); // enables the 'Apply' button
54 return TRUE;
56 break;
58 break;
59 case WM_NOTIFY:
60 pNMHDR = (NMHDR*)lParam;
61 if(m_hPropertySheet==0) {
62 m_hPropertySheet = pNMHDR->hwndFrom;
64 switch (pNMHDR->code) {
65 //case PSN_SETACTIVE:
66 // if(!m_hwnd) { // If this is the initial dialog for the first time
67 // m_hwnd = Window;
68 // PopulateList();
69 // }
70 // return TRUE;
71 // break;
72 case PSN_KILLACTIVE: // About to lose focus
73 SetWindowLong( Window, DWL_MSGRESULT, !Validate());
74 return TRUE;
75 break;
76 case PSN_APPLY: // User clicked OK/Apply - apply the changes
77 if(Apply())
78 SetWindowLong( Window, DWL_MSGRESULT, PSNRET_NOERROR);
79 else
80 SetWindowLong( Window, DWL_MSGRESULT, PSNRET_INVALID);
81 return TRUE;
82 break;
84 break;
86 return FALSE;