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.5 2005/01/25 18:30:02 shersche
27 Fix call to PathForResource() by passing in NULL as first parameter.
29 Revision 1.4 2005/01/25 08:54:41 shersche
30 <rdar://problem/3911084> Load resource DLLs at startup.
33 Revision 1.3 2004/07/13 21:24:23 rpantos
34 Fix for <rdar://problem/3701120>.
36 Revision 1.2 2004/06/24 20:12:08 shersche
38 Submitted by: herscher
40 Revision 1.1 2004/06/18 04:36:57 rpantos
47 #include "PrinterSetupWizardApp.h"
48 #include "PrinterSetupWizardSheet.h"
49 #include "DebugServices.h"
50 #include "loclibrary.h"
56 // Stash away pointers to our resource DLLs
58 static HINSTANCE g_nonLocalizedResources
= NULL
;
59 static HINSTANCE g_localizedResources
= NULL
;
63 GetNonLocalizedResources()
65 return g_nonLocalizedResources
;
70 GetLocalizedResources()
72 return g_localizedResources
;
76 // CPrinterSetupWizardApp
78 BEGIN_MESSAGE_MAP(CPrinterSetupWizardApp
, CWinApp
)
79 ON_COMMAND(ID_HELP
, CWinApp::OnHelp
)
83 // CPrinterSetupWizardApp construction
85 CPrinterSetupWizardApp::CPrinterSetupWizardApp()
87 // TODO: add construction code here,
88 // Place all significant initialization in InitInstance
92 // The one and only CPrinterSetupWizardApp object
94 CPrinterSetupWizardApp theApp
;
97 // CPrinterSetupWizardApp initialization
99 BOOL
CPrinterSetupWizardApp::InitInstance()
101 CString errorMessage
;
102 CString errorCaption
;
103 wchar_t resource
[MAX_PATH
];
105 OSStatus err
= kNoErr
;
108 // initialize the debugging framework
110 debug_initialize( kDebugOutputTypeWindowsDebugger
, "PrinterSetupWizard", NULL
);
111 debug_set_property( kDebugPropertyTagPrintLevel
, kDebugLevelTrace
);
113 // Before we load the resources, let's load the error string
115 errorMessage
.LoadString( IDS_REINSTALL
);
116 errorCaption
.LoadString( IDS_REINSTALL_CAPTION
);
120 res
= PathForResource( NULL
, L
"RendezvousPrinterWizard.dll", resource
, MAX_PATH
);
121 err
= translate_errno( res
!= 0, kUnknownErr
, kUnknownErr
);
122 require_noerr( err
, exit
);
124 g_nonLocalizedResources
= LoadLibrary( resource
);
125 translate_errno( g_nonLocalizedResources
, GetLastError(), kUnknownErr
);
126 require_noerr( err
, exit
);
128 res
= PathForResource( NULL
, L
"RendezvousPrinterWizardLocalized.dll", resource
, MAX_PATH
);
129 err
= translate_errno( res
!= 0, kUnknownErr
, kUnknownErr
);
130 require_noerr( err
, exit
);
132 g_localizedResources
= LoadLibrary( resource
);
133 translate_errno( g_localizedResources
, GetLastError(), kUnknownErr
);
134 require_noerr( err
, exit
);
136 AfxSetResourceHandle( g_localizedResources
);
138 // InitCommonControls() is required on Windows XP if an application
139 // manifest specifies use of ComCtl32.dll version 6 or later to enable
140 // visual styles. Otherwise, any window creation will fail.
141 InitCommonControls();
143 CWinApp::InitInstance();
145 AfxEnableControlContainer();
148 CPrinterSetupWizardSheet
dlg(IDS_CAPTION
);
154 INT_PTR nResponse
= dlg
.DoModal();
156 if (nResponse
== IDOK
)
158 // TODO: Place code here to handle when the dialog is
161 else if (nResponse
== IDCANCEL
)
163 // TODO: Place code here to handle when the dialog is
164 // dismissed with Cancel
167 catch (CPrinterSetupWizardSheet::WizardException
& exc
)
169 MessageBox(NULL
, exc
.text
, exc
.caption
, MB_OK
|MB_ICONEXCLAMATION
);
177 MessageBox( NULL
, errorMessage
, errorCaption
, MB_ICONERROR
| MB_OK
);
180 if ( g_nonLocalizedResources
)
182 FreeLibrary( g_nonLocalizedResources
);
185 if ( g_localizedResources
)
187 FreeLibrary( g_localizedResources
);
190 // Since the dialog has been closed, return FALSE so that we exit the
191 // application, rather than start the application's message pump.