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.8 2005/04/13 17:43:39 shersche
27 <rdar://problem/4081448> Change "PrinterWizard.dll" to "PrinterWizardResources.dll"
29 Revision 1.7 2005/02/15 07:50:09 shersche
30 <rdar://problem/4007151> Update name
32 Revision 1.6 2005/02/10 22:35:10 cheshire
33 <rdar://problem/3727944> Update name
35 Revision 1.5 2005/01/25 18:30:02 shersche
36 Fix call to PathForResource() by passing in NULL as first parameter.
38 Revision 1.4 2005/01/25 08:54:41 shersche
39 <rdar://problem/3911084> Load resource DLLs at startup.
42 Revision 1.3 2004/07/13 21:24:23 rpantos
43 Fix for <rdar://problem/3701120>.
45 Revision 1.2 2004/06/24 20:12:08 shersche
47 Submitted by: herscher
49 Revision 1.1 2004/06/18 04:36:57 rpantos
56 #include "PrinterSetupWizardApp.h"
57 #include "PrinterSetupWizardSheet.h"
58 #include "DebugServices.h"
59 #include "loclibrary.h"
65 // Stash away pointers to our resource DLLs
67 static HINSTANCE g_nonLocalizedResources
= NULL
;
68 static HINSTANCE g_localizedResources
= NULL
;
72 GetNonLocalizedResources()
74 return g_nonLocalizedResources
;
79 GetLocalizedResources()
81 return g_localizedResources
;
85 // CPrinterSetupWizardApp
87 BEGIN_MESSAGE_MAP(CPrinterSetupWizardApp
, CWinApp
)
88 ON_COMMAND(ID_HELP
, CWinApp::OnHelp
)
92 // CPrinterSetupWizardApp construction
94 CPrinterSetupWizardApp::CPrinterSetupWizardApp()
96 // TODO: add construction code here,
97 // Place all significant initialization in InitInstance
101 // The one and only CPrinterSetupWizardApp object
103 CPrinterSetupWizardApp theApp
;
106 // CPrinterSetupWizardApp initialization
108 BOOL
CPrinterSetupWizardApp::InitInstance()
110 CString errorMessage
;
111 CString errorCaption
;
112 wchar_t resource
[MAX_PATH
];
114 OSStatus err
= kNoErr
;
117 // initialize the debugging framework
119 debug_initialize( kDebugOutputTypeWindowsDebugger
, "PrinterSetupWizard", NULL
);
120 debug_set_property( kDebugPropertyTagPrintLevel
, kDebugLevelTrace
);
122 // Before we load the resources, let's load the error string
124 errorMessage
.LoadString( IDS_REINSTALL
);
125 errorCaption
.LoadString( IDS_REINSTALL_CAPTION
);
129 res
= PathForResource( NULL
, L
"PrinterWizardResources.dll", resource
, MAX_PATH
);
130 err
= translate_errno( res
!= 0, kUnknownErr
, kUnknownErr
);
131 require_noerr( err
, exit
);
133 g_nonLocalizedResources
= LoadLibrary( resource
);
134 translate_errno( g_nonLocalizedResources
, GetLastError(), kUnknownErr
);
135 require_noerr( err
, exit
);
137 res
= PathForResource( NULL
, L
"PrinterWizardLocalized.dll", resource
, MAX_PATH
);
138 err
= translate_errno( res
!= 0, kUnknownErr
, kUnknownErr
);
139 require_noerr( err
, exit
);
141 g_localizedResources
= LoadLibrary( resource
);
142 translate_errno( g_localizedResources
, GetLastError(), kUnknownErr
);
143 require_noerr( err
, exit
);
145 AfxSetResourceHandle( g_localizedResources
);
147 // InitCommonControls() is required on Windows XP if an application
148 // manifest specifies use of ComCtl32.dll version 6 or later to enable
149 // visual styles. Otherwise, any window creation will fail.
150 InitCommonControls();
152 CWinApp::InitInstance();
154 AfxEnableControlContainer();
157 CPrinterSetupWizardSheet
dlg(IDS_CAPTION
);
163 INT_PTR nResponse
= dlg
.DoModal();
165 if (nResponse
== IDOK
)
167 // TODO: Place code here to handle when the dialog is
170 else if (nResponse
== IDCANCEL
)
172 // TODO: Place code here to handle when the dialog is
173 // dismissed with Cancel
176 catch (CPrinterSetupWizardSheet::WizardException
& exc
)
178 MessageBox(NULL
, exc
.text
, exc
.caption
, MB_OK
|MB_ICONEXCLAMATION
);
186 MessageBox( NULL
, errorMessage
, errorCaption
, MB_ICONERROR
| MB_OK
);
189 if ( g_nonLocalizedResources
)
191 FreeLibrary( g_nonLocalizedResources
);
194 if ( g_localizedResources
)
196 FreeLibrary( g_localizedResources
);
199 // Since the dialog has been closed, return FALSE so that we exit the
200 // application, rather than start the application's message pump.