]> git.saurik.com Git - apple/mdnsresponder.git/blob - Clients/PrinterSetupWizard/PrinterSetupWizardApp.cpp
7b6544313604e74af47fcd109d2d7de20ca8349a
[apple/mdnsresponder.git] / Clients / PrinterSetupWizard / PrinterSetupWizardApp.cpp
1 /*
2 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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
11 * file.
12 *
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.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22
23 Change History (most recent first):
24
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"
28
29 Revision 1.7 2005/02/15 07:50:09 shersche
30 <rdar://problem/4007151> Update name
31
32 Revision 1.6 2005/02/10 22:35:10 cheshire
33 <rdar://problem/3727944> Update name
34
35 Revision 1.5 2005/01/25 18:30:02 shersche
36 Fix call to PathForResource() by passing in NULL as first parameter.
37
38 Revision 1.4 2005/01/25 08:54:41 shersche
39 <rdar://problem/3911084> Load resource DLLs at startup.
40 Bug #: 3911084
41
42 Revision 1.3 2004/07/13 21:24:23 rpantos
43 Fix for <rdar://problem/3701120>.
44
45 Revision 1.2 2004/06/24 20:12:08 shersche
46 Clean up source code
47 Submitted by: herscher
48
49 Revision 1.1 2004/06/18 04:36:57 rpantos
50 First checked in
51
52
53 */
54
55 #include "stdafx.h"
56 #include "PrinterSetupWizardApp.h"
57 #include "PrinterSetupWizardSheet.h"
58 #include "DebugServices.h"
59 #include "loclibrary.h"
60
61 #ifdef _DEBUG
62 #define new DEBUG_NEW
63 #endif
64
65 // Stash away pointers to our resource DLLs
66
67 static HINSTANCE g_nonLocalizedResources = NULL;
68 static HINSTANCE g_localizedResources = NULL;
69
70
71 HINSTANCE
72 GetNonLocalizedResources()
73 {
74 return g_nonLocalizedResources;
75 }
76
77
78 HINSTANCE
79 GetLocalizedResources()
80 {
81 return g_localizedResources;
82 }
83
84
85 // CPrinterSetupWizardApp
86
87 BEGIN_MESSAGE_MAP(CPrinterSetupWizardApp, CWinApp)
88 ON_COMMAND(ID_HELP, CWinApp::OnHelp)
89 END_MESSAGE_MAP()
90
91
92 // CPrinterSetupWizardApp construction
93
94 CPrinterSetupWizardApp::CPrinterSetupWizardApp()
95 {
96 // TODO: add construction code here,
97 // Place all significant initialization in InitInstance
98 }
99
100
101 // The one and only CPrinterSetupWizardApp object
102
103 CPrinterSetupWizardApp theApp;
104
105
106 // CPrinterSetupWizardApp initialization
107
108 BOOL CPrinterSetupWizardApp::InitInstance()
109 {
110 CString errorMessage;
111 CString errorCaption;
112 wchar_t resource[MAX_PATH];
113 int res;
114 OSStatus err = kNoErr;
115
116 //
117 // initialize the debugging framework
118 //
119 debug_initialize( kDebugOutputTypeWindowsDebugger, "PrinterSetupWizard", NULL );
120 debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace );
121
122 // Before we load the resources, let's load the error string
123
124 errorMessage.LoadString( IDS_REINSTALL );
125 errorCaption.LoadString( IDS_REINSTALL_CAPTION );
126
127 // Load Resources
128
129 res = PathForResource( NULL, L"PrinterWizardResources.dll", resource, MAX_PATH );
130 err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
131 require_noerr( err, exit );
132
133 g_nonLocalizedResources = LoadLibrary( resource );
134 translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr );
135 require_noerr( err, exit );
136
137 res = PathForResource( NULL, L"PrinterWizardLocalized.dll", resource, MAX_PATH );
138 err = translate_errno( res != 0, kUnknownErr, kUnknownErr );
139 require_noerr( err, exit );
140
141 g_localizedResources = LoadLibrary( resource );
142 translate_errno( g_localizedResources, GetLastError(), kUnknownErr );
143 require_noerr( err, exit );
144
145 AfxSetResourceHandle( g_localizedResources );
146
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();
151
152 CWinApp::InitInstance();
153
154 AfxEnableControlContainer();
155
156 {
157 CPrinterSetupWizardSheet dlg(IDS_CAPTION);
158
159 m_pMainWnd = &dlg;
160
161 try
162 {
163 INT_PTR nResponse = dlg.DoModal();
164
165 if (nResponse == IDOK)
166 {
167 // TODO: Place code here to handle when the dialog is
168 // dismissed with OK
169 }
170 else if (nResponse == IDCANCEL)
171 {
172 // TODO: Place code here to handle when the dialog is
173 // dismissed with Cancel
174 }
175 }
176 catch (CPrinterSetupWizardSheet::WizardException & exc)
177 {
178 MessageBox(NULL, exc.text, exc.caption, MB_OK|MB_ICONEXCLAMATION);
179 }
180 }
181
182 exit:
183
184 if ( err )
185 {
186 MessageBox( NULL, errorMessage, errorCaption, MB_ICONERROR | MB_OK );
187 }
188
189 if ( g_nonLocalizedResources )
190 {
191 FreeLibrary( g_nonLocalizedResources );
192 }
193
194 if ( g_localizedResources )
195 {
196 FreeLibrary( g_localizedResources );
197 }
198
199 // Since the dialog has been closed, return FALSE so that we exit the
200 // application, rather than start the application's message pump.
201 return FALSE;
202 }