1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 Change History (most recent first):
19 $Log: FourthPage.cpp,v $
20 Revision 1.1 2009/07/01 19:20:37 herscher
21 <rdar://problem/6713286> UI changes for configuring sleep proxy settings.
27 #include "FourthPage.h"
30 #include "ConfigPropertySheet.h"
31 #include "SharedSecret.h"
33 #include <WinServices.h>
35 #define MAX_KEY_LENGTH 255
38 IMPLEMENT_DYNCREATE(CFourthPage
, CPropertyPage
)
41 //---------------------------------------------------------------------------------------------------------------------------
42 // CFourthPage::CFourthPage
43 //---------------------------------------------------------------------------------------------------------------------------
45 CFourthPage::CFourthPage()
47 CPropertyPage(CFourthPage::IDD
)
49 //{{AFX_DATA_INIT(CFourthPage)
54 //---------------------------------------------------------------------------------------------------------------------------
55 // CFourthPage::~CFourthPage
56 //---------------------------------------------------------------------------------------------------------------------------
58 CFourthPage::~CFourthPage()
63 //---------------------------------------------------------------------------------------------------------------------------
64 // CFourthPage::DoDataExchange
65 //---------------------------------------------------------------------------------------------------------------------------
67 void CFourthPage::DoDataExchange(CDataExchange
* pDX
)
69 CPropertyPage::DoDataExchange(pDX
);
70 //{{AFX_DATA_MAP(CFourthPage)
72 DDX_Control(pDX
, IDC_POWER_MANAGEMENT
, m_checkBox
);
75 BEGIN_MESSAGE_MAP(CFourthPage
, CPropertyPage
)
76 //{{AFX_MSG_MAP(CFourthPage)
78 ON_BN_CLICKED(IDC_POWER_MANAGEMENT
, &CFourthPage::OnBnClickedPowerManagement
)
82 //---------------------------------------------------------------------------------------------------------------------------
83 // CFourthPage::SetModified
84 //---------------------------------------------------------------------------------------------------------------------------
86 void CFourthPage::SetModified( BOOL bChanged
)
88 m_modified
= bChanged
;
90 CPropertyPage::SetModified( bChanged
);
94 //---------------------------------------------------------------------------------------------------------------------------
95 // CFourthPage::OnSetActive
96 //---------------------------------------------------------------------------------------------------------------------------
99 CFourthPage::OnSetActive()
101 CConfigPropertySheet
* psheet
;
106 BOOL b
= CPropertyPage::OnSetActive();
108 psheet
= reinterpret_cast<CConfigPropertySheet
*>(GetParent());
109 require_quiet( psheet
, exit
);
111 m_checkBox
.SetCheck( 0 );
113 // Now populate the browse domain box
115 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, kServiceParametersNode L
"\\Power Management", &key
);
116 require_noerr( err
, exit
);
118 dwSize
= sizeof( DWORD
);
119 err
= RegQueryValueEx( key
, L
"Enabled", NULL
, NULL
, (LPBYTE
) &enabled
, &dwSize
);
120 require_noerr( err
, exit
);
122 m_checkBox
.SetCheck( enabled
);
135 //---------------------------------------------------------------------------------------------------------------------------
137 //---------------------------------------------------------------------------------------------------------------------------
150 //---------------------------------------------------------------------------------------------------------------------------
151 // CFourthPage::Commit
152 //---------------------------------------------------------------------------------------------------------------------------
155 CFourthPage::Commit()
161 err
= RegCreateKey( HKEY_LOCAL_MACHINE
, kServiceParametersNode L
"\\Power Management", &key
);
162 require_noerr( err
, exit
);
164 enabled
= m_checkBox
.GetCheck();
165 err
= RegSetValueEx( key
, L
"Enabled", NULL
, REG_DWORD
, (LPBYTE
) &enabled
, sizeof( enabled
) );
166 require_noerr( err
, exit
);
177 //---------------------------------------------------------------------------------------------------------------------------
178 // CFourthPage::OnBnClickedRemoveBrowseDomain
179 //---------------------------------------------------------------------------------------------------------------------------
182 void CFourthPage::OnBnClickedPowerManagement()
186 sprintf( buf
, "check box: %d", m_checkBox
.GetCheck() );
187 OutputDebugStringA( buf
);
188 // TODO: Add your control notification handler code here