1 /* |
|
2 * Copyright 1999-2003 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Sun in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 * CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 * have any questions. |
|
24 */ |
|
25 |
|
26 #ifndef AWT_DLLS_H |
|
27 #define AWT_DLLS_H |
|
28 |
|
29 #include <commdlg.h> |
|
30 #include <shellapi.h> |
|
31 #include <shlobj.h> |
|
32 #include "awt_FileDialog.h" |
|
33 #include "awt_PrintDialog.h" |
|
34 |
|
35 /* |
|
36 * To reduce memory footprint we don't statically link to COMDLG32.DLL |
|
37 * and SHELL32. Instead we programatically load them only when they are |
|
38 * needed. |
|
39 */ |
|
40 |
|
41 //--------------------------------------------------------------------------- |
|
42 |
|
43 typedef BOOL (APIENTRY *PrintDlgType)(LPPRINTDLGW); |
|
44 typedef BOOL (APIENTRY *PageSetupDlgType)(LPPAGESETUPDLGW); |
|
45 typedef BOOL (APIENTRY *GetOpenFileNameType)(LPOPENFILENAMEW); |
|
46 typedef BOOL (APIENTRY *GetSaveFileNameType)(LPOPENFILENAMEW); |
|
47 typedef DWORD (APIENTRY *GetExtendedErrorType)(VOID); |
|
48 |
|
49 class AwtCommDialog { |
|
50 public: |
|
51 static DWORD CommDlgExtendedError(VOID); |
|
52 |
|
53 static BOOL PrintDlg(LPPRINTDLG data); |
|
54 |
|
55 static BOOL PageSetupDlg(LPPAGESETUPDLG data); |
|
56 |
|
57 private: |
|
58 static void load_comdlg_procs(); |
|
59 |
|
60 // Use wrapper functions with default calling convention. If the |
|
61 // default isn't __stdcall, accessing the Win32 functions directly |
|
62 // will cause stack corruption if we cast away __stdcall. |
|
63 static BOOL PrintDlgWrapper(LPPRINTDLG data) { |
|
64 return (*do_print_dlg)(data); |
|
65 } |
|
66 static BOOL PageSetupDlgWrapper(LPPAGESETUPDLG data) { |
|
67 return (*do_page_setup_dlg)(data); |
|
68 } |
|
69 static BOOL GetOpenFileNameWrapper(LPOPENFILENAME data) { |
|
70 return (*get_open_file_name)(data); |
|
71 } |
|
72 static BOOL GetSaveFileNameWrapper(LPOPENFILENAME data) { |
|
73 return (*get_save_file_name)(data); |
|
74 } |
|
75 static DWORD GetExtendedErrorWrapper(VOID) { |
|
76 return (*get_dlg_extended_error)(); |
|
77 } |
|
78 |
|
79 friend BOOL AwtFileDialog::GetOpenFileName(LPAWTOPENFILENAME); |
|
80 friend BOOL AwtFileDialog::GetSaveFileName(LPAWTOPENFILENAME); |
|
81 friend BOOL AwtPrintDialog::PrintDlg(LPPRINTDLG); |
|
82 |
|
83 static PrintDlgType do_print_dlg; |
|
84 static PageSetupDlgType do_page_setup_dlg; |
|
85 static GetOpenFileNameType get_open_file_name; |
|
86 static GetSaveFileNameType get_save_file_name; |
|
87 static GetExtendedErrorType get_dlg_extended_error; |
|
88 }; |
|
89 |
|
90 //--------------------------------------------------------------------------- |
|
91 |
|
92 // Dynamically load in SHELL32.DLL and define the procedure pointers listed below. |
|
93 extern void load_shell_procs(); |
|
94 |
|
95 // Procedure pointers obtained from SHELL32.DLL |
|
96 // You must call load_shell_procs() before using any of these. |
|
97 typedef UINT (APIENTRY *DragQueryFileType)(HDROP,UINT,LPTSTR,UINT); |
|
98 typedef BOOL (APIENTRY *GetPathFromIDListType)(LPCITEMIDLIST,LPTSTR); |
|
99 extern DragQueryFileType do_drag_query_file; |
|
100 extern GetPathFromIDListType get_path_from_idlist; |
|
101 |
|
102 //--------------------------------------------------------------------------- |
|
103 |
|
104 // Dynamically load in USER32.DLL and define the procedure pointers listed below. |
|
105 extern void load_user_procs(); |
|
106 |
|
107 // Procedure pointers obtained from USER32.DLL |
|
108 // You must call load_user_procs() before using any of these. |
|
109 typedef BOOL (WINAPI *AnimateWindowType)(HWND,DWORD,DWORD); |
|
110 typedef LONG (WINAPI *ChangeDisplaySettingsExType)(LPCTSTR,LPDEVMODE,HWND,DWORD,LPVOID lParam); |
|
111 extern AnimateWindowType fn_animate_window; |
|
112 extern ChangeDisplaySettingsExType fn_change_display_settings_ex; |
|
113 |
|
114 //--------------------------------------------------------------------------- |
|
115 |
|
116 // Dynamically load in VERSION.DLL and define the procedure pointers listed below. |
|
117 extern void load_version_procs(); |
|
118 |
|
119 // Procedure pointers obtained from VERSION.DLL |
|
120 // You must call load_version_procs() before using any of these. |
|
121 typedef DWORD (APIENTRY *GetFileVersionInfoSizeType)(LPTSTR,LPDWORD); |
|
122 typedef BOOL (APIENTRY *GetFileVersionInfoType)(LPTSTR,DWORD,DWORD,LPVOID); |
|
123 typedef BOOL (APIENTRY *VerQueryValueType)(const LPVOID,LPTSTR,LPVOID*,PUINT); |
|
124 extern GetFileVersionInfoSizeType get_file_version_info_size; |
|
125 extern GetFileVersionInfoType get_file_version_info; |
|
126 extern VerQueryValueType do_ver_query_value; |
|
127 |
|
128 //--------------------------------------------------------------------------- |
|
129 |
|
130 // Dynamically load in RSRC32.DLL and define the procedure pointers listed below. |
|
131 extern void load_rsrc32_procs(); |
|
132 |
|
133 // Procedure pointers obtained from RSRC32.DLL |
|
134 // You must call load_rsrc32_procs() before using this procedure. |
|
135 |
|
136 /* |
|
137 * NOTE: even after load_rsrc32_procs() you must check that |
|
138 * the function pointer is valid before use. |
|
139 * It will be NULL in three cases: |
|
140 * 1.RSRC32.DLL not found. This means that Resource Meter |
|
141 * isn't installed. |
|
142 * 2.RSRC32.DLL can't be loaded. This happens on WinNT. |
|
143 * 3.Unknown version of RSRC32.DLL. This is undocumented |
|
144 * procedure, so the safest will be to use it only for |
|
145 * a finite set of known versions. |
|
146 */ |
|
147 typedef UINT (APIENTRY *GetFreeSystemResourcesType)(UINT); |
|
148 |
|
149 extern GetFreeSystemResourcesType get_free_system_resources; |
|
150 |
|
151 extern void load_rich_edit_library(); |
|
152 |
|
153 //--------------------------------------------------------------------------- |
|
154 |
|
155 /* |
|
156 * Loading WINMM.DLL (the Windows MultiMedia library) is extremely |
|
157 * expensive. The AWT only uses it to play certain Windows sounds |
|
158 * (which are off by default) so we dynamically load it upon demand |
|
159 * instead of statically linking to it. |
|
160 */ |
|
161 |
|
162 class AwtWinMM { |
|
163 public: |
|
164 static BOOL PlaySoundWrapper(LPCTSTR pszSound, HMODULE hmod, DWORD fdwSound); |
|
165 |
|
166 private: |
|
167 static void load_winmm_procs(); |
|
168 static bool initialized; |
|
169 typedef BOOL WINAPI PlaySoundWFunc(LPCTSTR pszSound, HMODULE hmod, DWORD fdwSound); |
|
170 static PlaySoundWFunc* playSoundFunc; |
|
171 }; |
|
172 |
|
173 #endif /* AWT_DLLS_H */ |
|