2 * Copyright (c) 2002-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
23 Change History (most recent first):
25 $Log: ControlPanel.cpp,v $
26 Revision 1.2 2005/03/03 19:55:22 shersche
27 <rdar://problem/4034481> ControlPanel source code isn't saving CVS log info
33 #include "ControlPanel.h"
34 #include "ConfigDialog.h"
35 #include "ConfigPropertySheet.h"
38 #include <DebugServices.h>
44 static char THIS_FILE
[] = __FILE__
;
51 //---------------------------------------------------------------------------------------------------------------------------
53 //---------------------------------------------------------------------------------------------------------------------------
58 CCPApp
* pApp
= (CCPApp
*) AfxGetApp();
61 check( pApp
->IsKindOf( RUNTIME_CLASS( CCPApp
) ) );
67 //---------------------------------------------------------------------------------------------------------------------------
69 //---------------------------------------------------------------------------------------------------------------------------
72 CPlApplet(HWND hWndCPl
, UINT uMsg
, LONG lParam1
, LONG lParam2
)
74 AFX_MANAGE_STATE(AfxGetStaticModuleState());
76 CCPApp
* pApp
= GetControlPanelApp();
78 return ( LONG
) pApp
->OnCplMsg(hWndCPl
, uMsg
, lParam1
, lParam2
);
82 IMPLEMENT_DYNAMIC(CCPApplet
, CCmdTarget
);
85 //---------------------------------------------------------------------------------------------------------------------------
86 // CCPApplet::CCPApplet
87 //---------------------------------------------------------------------------------------------------------------------------
89 CCPApplet::CCPApplet(UINT resourceId
, UINT descId
, CRuntimeClass
* uiClass
)
91 m_resourceId(resourceId
),
97 check( uiClass
->IsDerivedFrom( RUNTIME_CLASS( CDialog
) ) ||
98 uiClass
->IsDerivedFrom( RUNTIME_CLASS( CPropertySheet
) ) );
100 m_name
.LoadString(resourceId
);
104 //---------------------------------------------------------------------------------------------------------------------------
105 // CCPApplet::~CCPApplet
106 //---------------------------------------------------------------------------------------------------------------------------
108 CCPApplet::~CCPApplet()
113 //---------------------------------------------------------------------------------------------------------------------------
114 // CCPApplet::OnStartParms
115 //---------------------------------------------------------------------------------------------------------------------------
118 CCPApplet::OnStartParms(CWnd
* pParentWnd
, LPCTSTR extra
)
120 DEBUG_UNUSED( pParentWnd
);
124 m_pageNumber
= ::_ttoi( extra
) - 1;
131 //---------------------------------------------------------------------------------------------------------------------------
133 //---------------------------------------------------------------------------------------------------------------------------
136 CCPApplet::OnRun(CWnd
* pParentWnd
)
139 CWnd
* pWnd
= (CWnd
*) m_uiClass
->CreateObject();
143 lResult
= ERROR_SUCCESS
;
145 if ( pWnd
->IsKindOf( RUNTIME_CLASS( CPropertySheet
) ) )
147 CPropertySheet
* pSheet
= (CPropertySheet
*) pWnd
;
149 pSheet
->Construct(m_name
, pParentWnd
, m_pageNumber
);
155 check( pWnd
->IsKindOf( RUNTIME_CLASS( CDialog
) ) );
157 CDialog
* pDialog
= (CDialog
*) pWnd
;
169 //---------------------------------------------------------------------------------------------------------------------------
170 // CCPApplet::OnInquire
171 //---------------------------------------------------------------------------------------------------------------------------
174 CCPApplet::OnInquire(CPLINFO
* pInfo
)
176 pInfo
->idIcon
= m_resourceId
;
177 pInfo
->idName
= m_resourceId
;
178 pInfo
->idInfo
= m_descId
;
179 pInfo
->lData
= reinterpret_cast<LONG
>(this);
185 //---------------------------------------------------------------------------------------------------------------------------
186 // CCPApplet::OnNewInquire
187 //---------------------------------------------------------------------------------------------------------------------------
190 CCPApplet::OnNewInquire(NEWCPLINFO
* pInfo
)
192 DEBUG_UNUSED( pInfo
);
198 //---------------------------------------------------------------------------------------------------------------------------
199 // CCPApplet::OnSelect
200 //---------------------------------------------------------------------------------------------------------------------------
203 CCPApplet::OnSelect()
209 //---------------------------------------------------------------------------------------------------------------------------
211 //---------------------------------------------------------------------------------------------------------------------------
220 IMPLEMENT_DYNAMIC(CCPApp
, CWinApp
);
222 //---------------------------------------------------------------------------------------------------------------------------
224 //---------------------------------------------------------------------------------------------------------------------------
228 debug_initialize( kDebugOutputTypeWindowsEventLog
, "DNS-SD Control Panel", GetModuleHandle( NULL
) );
229 debug_set_property( kDebugPropertyTagPrintLevel
, kDebugLevelInfo
);
233 //---------------------------------------------------------------------------------------------------------------------------
235 //---------------------------------------------------------------------------------------------------------------------------
239 while ( !m_applets
.IsEmpty() )
241 delete m_applets
.RemoveHead();
246 //---------------------------------------------------------------------------------------------------------------------------
248 //---------------------------------------------------------------------------------------------------------------------------
251 CCPApp::AddApplet( CCPApplet
* applet
)
255 m_applets
.AddTail( applet
);
259 //---------------------------------------------------------------------------------------------------------------------------
261 //---------------------------------------------------------------------------------------------------------------------------
270 applet
= new CCPApplet( IDR_APPLET
, IDS_APPLET_DESCRIPTION
, RUNTIME_CLASS( CConfigPropertySheet
) );
277 require_action( applet
, exit
, kNoMemoryErr
);
283 return m_applets
.GetCount();
287 //---------------------------------------------------------------------------------------------------------------------------
289 //---------------------------------------------------------------------------------------------------------------------------
298 //---------------------------------------------------------------------------------------------------------------------------
300 //---------------------------------------------------------------------------------------------------------------------------
303 CCPApp::OnCplMsg(HWND hWndCPl
, UINT uMsg
, LONG lParam1
, LONG lParam2
)
323 lResult
= m_applets
.GetCount();
329 POSITION pos
= m_applets
.FindIndex( lParam1
);
332 CCPApplet
* applet
= m_applets
.GetAt( pos
);
339 LPCPLINFO pInfo
= reinterpret_cast<LPCPLINFO
>(lParam2
);
340 lResult
= applet
->OnInquire(pInfo
);
346 LPNEWCPLINFO pInfo
= reinterpret_cast<LPNEWCPLINFO
>(lParam2
);
347 lResult
= applet
->OnNewInquire(pInfo
);
351 case CPL_STARTWPARMS
:
353 CWnd
* pParentWnd
= CWnd::FromHandle(hWndCPl
);
354 LPCTSTR lpszExtra
= reinterpret_cast<LPCTSTR
>(lParam2
);
355 lResult
= applet
->OnStartParms(pParentWnd
, lpszExtra
);
361 CWnd
* pParentWnd
= CWnd::FromHandle(hWndCPl
);
362 lResult
= applet
->OnRun(pParentWnd
);
368 lResult
= applet
->OnSelect();
374 lResult
= applet
->OnStop();
380 // TRACE(_T("Warning, Received an unknown control panel message:%d\n"), uMsg);