ReactOS 0.4.15-dev-7942-gd23573b
cdlg32.c
Go to the documentation of this file.
1/*
2 * Common Dialog Boxes interface (32 bit)
3 * Find/Replace
4 *
5 * Copyright 1999 Bertho A. Stultiens
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 */
21
22#include <stdarg.h>
23
24#define COBJMACROS
25
26#include "windef.h"
27#include "winbase.h"
28#include "wingdi.h"
29#include "winuser.h"
30#include "objbase.h"
31#include "rpcproxy.h"
32#include "commdlg.h"
33#include "cderr.h"
34#include "wine/debug.h"
35#include "wine/heap.h"
36
38
39#include "cdlg.h"
40
41
43#ifdef __REACTOS__
44CRITICAL_SECTION COMDLG32_OpenFileLock DECLSPEC_HIDDEN;
45#endif
46
48
50
51/* SHELL */
52LPITEMIDLIST (WINAPI *COMDLG32_SHSimpleIDListFromPathAW)(LPCVOID) DECLSPEC_HIDDEN;
53
54/***********************************************************************
55 * DllMain (COMDLG32.init)
56 *
57 * Initialization code for the COMDLG32 DLL
58 *
59 * RETURNS:
60 * FALSE if sibling could not be loaded or instantiated twice, TRUE
61 * otherwise.
62 */
63static const char GPA_string[] = "Failed to get entry point %s for hinst = %p\n";
64#define GPA(dest, hinst, name) \
65 if(!(dest = (void*)GetProcAddress(hinst,name)))\
66 { \
67 ERR(GPA_string, debugstr_a(name), hinst); \
68 return FALSE; \
69 }
70
72{
73 TRACE("(%p, %d, %p)\n", hInstance, Reason, Reserved);
74
75 switch(Reason)
76 {
80
81 SHELL32_hInstance = GetModuleHandleA("SHELL32.DLL");
82#ifdef __REACTOS__
83 InitializeCriticalSection(&COMDLG32_OpenFileLock);
84#endif
85
86 /* SHELL */
87 GPA(COMDLG32_SHSimpleIDListFromPathAW, SHELL32_hInstance, (LPCSTR)162);
88 break;
89
91 if (Reserved) break;
93#ifdef __REACTOS__
94 DeleteCriticalSection(&COMDLG32_OpenFileLock);
95#endif
96 break;
97 }
98 return TRUE;
99}
100#undef GPA
101
102/***********************************************************************
103 * COMDLG32_AllocMem (internal)
104 * Get memory for internal datastructure plus stringspace etc.
105 * RETURNS
106 * Success: Pointer to a heap block
107 * Failure: null
108 */
110{
111 void *ptr = heap_alloc_zero(size);
112
113 if (!ptr)
114 {
116 return NULL;
117 }
118
119 return ptr;
120}
121
122
123/***********************************************************************
124 * COMDLG32_SetCommDlgExtendedError (internal)
125 *
126 * Used to set the thread's local error value if a comdlg32 function fails.
127 */
129{
130 TRACE("(%08x)\n", err);
135 else
136 FIXME("No Tls Space\n");
137}
138
139
140/***********************************************************************
141 * CommDlgExtendedError (COMDLG32.@)
142 *
143 * Get the thread's local error value if a comdlg32 function fails.
144 * RETURNS
145 * Current error value which might not be valid
146 * if a previous call succeeded.
147 */
149{
152 else
153 return 0; /* we never set an error, so there isn't one */
154}
155
156#ifndef __REACTOS__ /* Win 7 */
157
158/*************************************************************************
159 * Implement the CommDlg32 class factory
160 *
161 * (Taken from shdocvw/factory.c; based on implementation in
162 * ddraw/main.c)
163 */
164typedef struct
165{
166 IClassFactory IClassFactory_iface;
167 HRESULT (*cf)(IUnknown*, REFIID, void**);
169
171{
172 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
173}
174
175/*************************************************************************
176 * CDLGCF_QueryInterface (IUnknown)
177 */
179 REFIID riid, void **ppobj)
180{
181 TRACE("%p (%s %p)\n", iface, debugstr_guid(riid), ppobj);
182
183 if(!ppobj)
184 return E_POINTER;
185
187 {
188 *ppobj = iface;
189 IClassFactory_AddRef(iface);
190 return S_OK;
191 }
192
193 WARN("Interface not supported.\n");
194
195 *ppobj = NULL;
196 return E_NOINTERFACE;
197}
198
199/*************************************************************************
200 * CDLGCF_AddRef (IUnknown)
201 */
203{
204 return 2; /* non-heap based object */
205}
206
207/*************************************************************************
208 * CDLGCF_Release (IUnknown)
209 */
211{
212 return 1; /* non-heap based object */
213}
214
215/*************************************************************************
216 * CDLGCF_CreateInstance (IClassFactory)
217 */
219 REFIID riid, void **ppobj)
220{
222 return This->cf(pOuter, riid, ppobj);
223}
224
225/*************************************************************************
226 * CDLGCF_LockServer (IClassFactory)
227 */
229{
230 TRACE("%p (%d)\n", iface, dolock);
231 return S_OK;
232}
233
234static const IClassFactoryVtbl CDLGCF_Vtbl =
235{
241};
242
243/*************************************************************************
244 * DllGetClassObject (COMMDLG32.@)
245 */
247{
248 static IClassFactoryImpl FileOpenDlgClassFactory = {{&CDLGCF_Vtbl}, FileOpenDialog_Constructor};
249 static IClassFactoryImpl FileSaveDlgClassFactory = {{&CDLGCF_Vtbl}, FileSaveDialog_Constructor};
250
251 TRACE("%s, %s, %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
252
253 if(IsEqualGUID(&CLSID_FileOpenDialog, rclsid))
254 return IClassFactory_QueryInterface(&FileOpenDlgClassFactory.IClassFactory_iface, riid, ppv);
255
256 if(IsEqualGUID(&CLSID_FileSaveDialog, rclsid))
257 return IClassFactory_QueryInterface(&FileSaveDlgClassFactory.IClassFactory_iface, riid, ppv);
258
260}
261
262/***********************************************************************
263 * DllRegisterServer (COMMDLG32.@)
264 */
266{
267#ifdef __REACTOS__
268 return E_FAIL; // FIXME: __wine_register_resources(COMDLG32_hInstance);
269#else
271#endif
272}
273
274/***********************************************************************
275 * DllUnregisterServer (COMMDLG32.@)
276 */
278{
279#ifdef __REACTOS__
280 return E_FAIL; // FIXME: __wine_unregister_resources(COMDLG32_hInstance);
281#else
283#endif
284}
285
286#endif /* Win 7 */
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define FIXME(fmt,...)
Definition: debug.h:111
#define WARN(fmt,...)
Definition: debug.h:112
#define CDERR_MEMALLOCFAILURE
Definition: cderr.h:14
static HINSTANCE SHELL32_hInstance
Definition: cdlg32.c:49
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
static DWORD COMDLG32_TlsIndex
Definition: cdlg32.c:47
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
Definition: cdlg32.c:71
HRESULT WINAPI DllRegisterServer(void)
Definition: cdlg32.c:265
static ULONG WINAPI CDLGCF_AddRef(IClassFactory *iface)
Definition: cdlg32.c:202
static HRESULT WINAPI CDLGCF_LockServer(IClassFactory *iface, BOOL dolock)
Definition: cdlg32.c:228
static HRESULT WINAPI CDLGCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: cdlg32.c:178
HRESULT WINAPI DllUnregisterServer(void)
Definition: cdlg32.c:277
void COMDLG32_SetCommDlgExtendedError(DWORD err)
Definition: cdlg32.c:128
static HRESULT WINAPI CDLGCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: cdlg32.c:218
static const IClassFactoryVtbl CDLGCF_Vtbl
Definition: cdlg32.c:234
#define GPA(dest, hinst, name)
Definition: cdlg32.c:64
void * COMDLG32_AllocMem(int size)
Definition: cdlg32.c:109
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:148
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
Definition: cdlg32.c:246
static const char GPA_string[]
Definition: cdlg32.c:63
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: cdlg32.c:170
static ULONG WINAPI CDLGCF_Release(IClassFactory *iface)
Definition: cdlg32.c:210
HRESULT FileOpenDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) DECLSPEC_HIDDEN
Definition: itemdlg.c:4664
HRESULT FileSaveDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv) DECLSPEC_HIDDEN
Definition: itemdlg.c:4669
HINSTANCE hInstance
Definition: charmap.c:19
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define DECLSPEC_HIDDEN
Definition: precomp.h:8
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:812
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1240
DWORD WINAPI TlsAlloc(VOID)
Definition: thread.c:1100
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1276
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1166
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLsizeiptr size
Definition: glext.h:5919
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
PVOID PVOID PWCHAR PVOID USHORT PULONG Reason
Definition: env.c:47
static PVOID ptr
Definition: dispmode.c:27
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define REFCLSID
Definition: guiddef.h:117
#define err(...)
HRESULT __wine_unregister_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:110
HRESULT __wine_register_resources(HMODULE module) DECLSPEC_HIDDEN
Definition: register.c:98
ITEMIDLIST UNALIGNED * LPITEMIDLIST
Definition: shtypes.idl:41
#define TRACE(s)
Definition: solgame.cpp:4
IClassFactory IClassFactory_iface
Definition: main.c:58
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:549
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
CONST void * LPCVOID
Definition: windef.h:191
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
#define E_POINTER
Definition: winerror.h:2365
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:2663
const char * LPCSTR
Definition: xmlstorage.h:183