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