2 * Copyright (c) 1997-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: PrinterSetupWizardApp.cpp,v $
26 Revision 1.7 2005/02/15 07:50:09 shersche
27 <rdar://problem/4007151> Update name
29 Revision 1.6 2005/02/10 22:35:10 cheshire
30 <rdar://problem/3727944> Update name
32 Revision 1.5 2005/01/25 18:30:02 shersche
33 Fix call to PathForResource() by passing in NULL as first parameter.
35 Revision 1.4 2005/01/25 08:54:41 shersche
36 <rdar://problem/3911084> Load resource DLLs at startup.
39 Revision 1.3 2004/07/13 21:24:23 rpantos
40 Fix for <rdar://problem/3701120>.
42 Revision 1.2 2004/06/24 20:12:08 shersche
44 Submitted by: herscher
46 Revision 1.1 2004/06/18 04:36:57 rpantos
53 #include "PrinterSetupWizardApp.h"
54 #include "PrinterSetupWizardSheet.h"
55 #include "DebugServices.h"
56 #include "loclibrary.h"
62 // Stash away pointers to our resource DLLs
64 static HINSTANCE g_nonLocalizedResources
= NULL
;
65 static HINSTANCE g_localizedResources
= NULL
;
69 GetNonLocalizedResources()
71 return g_nonLocalizedResources
;
76 GetLocalizedResources()
78 return g_localizedResources
;
82 // CPrinterSetupWizardApp
84 BEGIN_MESSAGE_MAP(CPrinterSetupWizardApp
, CWinApp
)
85 ON_COMMAND(ID_HELP
, CWinApp::OnHelp
)
89 // CPrinterSetupWizardApp construction
91 CPrinterSetupWizardApp::CPrinterSetupWizardApp()
93 // TODO: add construction code here,
94 // Place all significant initialization in InitInstance
98 // The one and only CPrinterSetupWizardApp object
100 CPrinterSetupWizardApp theApp
;
103 // CPrinterSetupWizardApp initialization
105 BOOL
CPrinterSetupWizardApp::InitInstance()
107 CString errorMessage
;
108 CString errorCaption
;
109 wchar_t resource
[MAX_PATH
];
111 OSStatus err
= kNoErr
;
114 // initialize the debugging framework
116 debug_initialize( kDebugOutputTypeWindowsDebugger
, "PrinterSetupWizard", NULL
);
117 debug_set_property( kDebugPropertyTagPrintLevel
, kDebugLevelTrace
);
119 // Before we load the resources, let's load the error string
121 errorMessage
.LoadString( IDS_REINSTALL
);
122 errorCaption
.LoadString( IDS_REINSTALL_CAPTION
);
126 res
= PathForResource( NULL
, L
"PrinterWizard.dll", resource
, MAX_PATH
);
127 err
= translate_errno( res
!= 0, kUnknownErr
, kUnknownErr
);
128 require_noerr( err
, exit
);
130 g_nonLocalizedResources
= LoadLibrary( resource
);
131 translate_errno( g_nonLocalizedResources
, GetLastError(), kUnknownErr
);
132 require_noerr( err
, exit
);
134 res
= PathForResource( NULL
, L
"PrinterWizardLocalized.dll", resource
, MAX_PATH
);
135 err
= translate_errno( res
!= 0, kUnknownErr
, kUnknownErr
);
136 require_noerr( err
, exit
);
138 g_localizedResources
= LoadLibrary( resource
);
139 translate_errno( g_localizedResources
, GetLastError(), kUnknownErr
);
140 require_noerr( err
, exit
);
142 AfxSetResourceHandle( g_localizedResources
);
144 // InitCommonControls() is required on Windows XP if an application
145 // manifest specifies use of ComCtl32.dll version 6 or later to enable
146 // visual styles. Otherwise, any window creation will fail.
147 InitCommonControls();
149 CWinApp::InitInstance();
151 AfxEnableControlContainer();
154 CPrinterSetupWizardSheet
dlg(IDS_CAPTION
);
160 INT_PTR nResponse
= dlg
.DoModal();
162 if (nResponse
== IDOK
)
164 // TODO: Place code here to handle when the dialog is
167 else if (nResponse
== IDCANCEL
)
169 // TODO: Place code here to handle when the dialog is
170 // dismissed with Cancel
173 catch (CPrinterSetupWizardSheet::WizardException
& exc
)
175 MessageBox(NULL
, exc
.text
, exc
.caption
, MB_OK
|MB_ICONEXCLAMATION
);
183 MessageBox( NULL
, errorMessage
, errorCaption
, MB_ICONERROR
| MB_OK
);
186 if ( g_nonLocalizedResources
)
188 FreeLibrary( g_nonLocalizedResources
);
191 if ( g_localizedResources
)
193 FreeLibrary( g_localizedResources
);
196 // Since the dialog has been closed, return FALSE so that we exit the
197 // application, rather than start the application's message pump.