ReactOS 0.4.17-dev-966-gf06eace
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;
45#endif
47
49
50/***********************************************************************
51 * DllMain (COMDLG32.init)
52 *
53 * Initialization code for the COMDLG32 DLL
54 *
55 * RETURNS:
56 * FALSE if sibling could not be loaded or instantiated twice, TRUE
57 * otherwise.
58 */
60{
61 TRACE("(%p, %ld, %p)\n", hInstance, Reason, Reserved);
62
63 switch(Reason)
64 {
66 {
67 ACTCTXW actctx = {0};
68
71
72#ifdef __REACTOS__
73 InitializeCriticalSection(&COMDLG32_OpenFileLock);
74#endif
75 actctx.cbSize = sizeof(actctx);
76 actctx.hModule = COMDLG32_hInstance;
77 actctx.lpResourceName = MAKEINTRESOURCEW(123);
78 actctx.dwFlags = ACTCTX_FLAG_HMODULE_VALID | ACTCTX_FLAG_RESOURCE_NAME_VALID;
81 ERR("failed to create activation context, last error %lu\n", GetLastError());
82
83 break;
84 }
86 if (Reserved) break;
89#ifdef __REACTOS__
90 DeleteCriticalSection(&COMDLG32_OpenFileLock);
91#endif
92 break;
93 }
94 return TRUE;
95}
96#undef GPA
97
98/***********************************************************************
99 * COMDLG32_AllocMem (internal)
100 * Get memory for internal datastructure plus stringspace etc.
101 * RETURNS
102 * Success: Pointer to a heap block
103 * Failure: null
104 */
106{
107 void *ptr = heap_alloc_zero(size);
108
109 if (!ptr)
110 {
112 return NULL;
113 }
114
115 return ptr;
116}
117
118
119/***********************************************************************
120 * COMDLG32_SetCommDlgExtendedError (internal)
121 *
122 * Used to set the thread's local error value if a comdlg32 function fails.
123 */
125{
126 TRACE("(%08lx)\n", err);
131 else
132 FIXME("No Tls Space\n");
133}
134
135
136/***********************************************************************
137 * CommDlgExtendedError (COMDLG32.@)
138 *
139 * Get the thread's local error value if a comdlg32 function fails.
140 * RETURNS
141 * Current error value which might not be valid
142 * if a previous call succeeded.
143 */
145{
148 else
149 return 0; /* we never set an error, so there isn't one */
150}
151
152/*************************************************************************
153 * Implement the CommDlg32 class factory
154 *
155 * (Taken from shdocvw/factory.c; based on implementation in
156 * ddraw/main.c)
157 */
158typedef struct
159{
160 IClassFactory IClassFactory_iface;
161 HRESULT (*cf)(IUnknown*, REFIID, void**);
163
165{
166 return CONTAINING_RECORD(iface, IClassFactoryImpl, IClassFactory_iface);
167}
168
169/*************************************************************************
170 * CDLGCF_QueryInterface (IUnknown)
171 */
173 REFIID riid, void **ppobj)
174{
175 TRACE("%p (%s %p)\n", iface, debugstr_guid(riid), ppobj);
176
177 if(!ppobj)
178 return E_POINTER;
179
181 {
182 *ppobj = iface;
183 IClassFactory_AddRef(iface);
184 return S_OK;
185 }
186
187 WARN("Interface not supported.\n");
188
189 *ppobj = NULL;
190 return E_NOINTERFACE;
191}
192
193/*************************************************************************
194 * CDLGCF_AddRef (IUnknown)
195 */
197{
198 return 2; /* non-heap based object */
199}
200
201/*************************************************************************
202 * CDLGCF_Release (IUnknown)
203 */
205{
206 return 1; /* non-heap based object */
207}
208
209/*************************************************************************
210 * CDLGCF_CreateInstance (IClassFactory)
211 */
213 REFIID riid, void **ppobj)
214{
216 return This->cf(pOuter, riid, ppobj);
217}
218
219/*************************************************************************
220 * CDLGCF_LockServer (IClassFactory)
221 */
223{
224 TRACE("%p (%d)\n", iface, dolock);
225 return S_OK;
226}
227
228static const IClassFactoryVtbl CDLGCF_Vtbl =
229{
235};
236
237/*************************************************************************
238 * DllGetClassObject (COMMDLG32.@)
239 */
241{
242#if (DLL_EXPORT_VERSION >= _WIN32_WINNT_VISTA)
243 static IClassFactoryImpl FileOpenDlgClassFactory = {{&CDLGCF_Vtbl}, FileOpenDialog_Constructor};
244 static IClassFactoryImpl FileSaveDlgClassFactory = {{&CDLGCF_Vtbl}, FileSaveDialog_Constructor};
245
246 TRACE("%s, %s, %p\n", debugstr_guid(rclsid), debugstr_guid(riid), ppv);
247
248 if(IsEqualGUID(&CLSID_FileOpenDialog, rclsid))
249 return IClassFactory_QueryInterface(&FileOpenDlgClassFactory.IClassFactory_iface, riid, ppv);
250
251 if(IsEqualGUID(&CLSID_FileSaveDialog, rclsid))
252 return IClassFactory_QueryInterface(&FileSaveDlgClassFactory.IClassFactory_iface, riid, ppv);
253#endif
254
256}
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
const GUID IID_IUnknown
const GUID IID_IClassFactory
#define CDERR_MEMALLOCFAILURE
Definition: cderr.h:14
static DWORD COMDLG32_TlsIndex
Definition: cdlg32.c:48
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD Reason, LPVOID Reserved)
Definition: cdlg32.c:59
static ULONG WINAPI CDLGCF_AddRef(IClassFactory *iface)
Definition: cdlg32.c:196
static HRESULT WINAPI CDLGCF_LockServer(IClassFactory *iface, BOOL dolock)
Definition: cdlg32.c:222
HANDLE COMDLG32_hActCtx
Definition: cdlg32.c:46
static HRESULT WINAPI CDLGCF_QueryInterface(IClassFactory *iface, REFIID riid, void **ppobj)
Definition: cdlg32.c:172
void COMDLG32_SetCommDlgExtendedError(DWORD err)
Definition: cdlg32.c:124
static HRESULT WINAPI CDLGCF_CreateInstance(IClassFactory *iface, IUnknown *pOuter, REFIID riid, void **ppobj)
Definition: cdlg32.c:212
static const IClassFactoryVtbl CDLGCF_Vtbl
Definition: cdlg32.c:228
HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
void * COMDLG32_AllocMem(int size)
Definition: cdlg32.c:105
DWORD WINAPI CommDlgExtendedError(void)
Definition: cdlg32.c:144
HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, void **ppv)
Definition: cdlg32.c:240
static IClassFactoryImpl * impl_from_IClassFactory(IClassFactory *iface)
Definition: cdlg32.c:164
static ULONG WINAPI CDLGCF_Release(IClassFactory *iface)
Definition: cdlg32.c:204
HRESULT FileOpenDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
HRESULT FileSaveDialog_Constructor(IUnknown *pUnkOuter, REFIID riid, void **ppv)
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
VOID WINAPI ReleaseActCtx(IN HANDLE hActCtx)
Definition: actctx.c:208
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
LPVOID WINAPI TlsGetValue(IN DWORD Index)
Definition: thread.c:1298
BOOL WINAPI TlsSetValue(IN DWORD Index, IN LPVOID Value)
Definition: thread.c:1334
BOOL WINAPI TlsFree(IN DWORD Index)
Definition: thread.c:1224
HANDLE WINAPI CreateActCtxW(PCACTCTXW pActCtx)
Definition: actctx.c:102
DWORD WINAPI DECLSPEC_HOTPATCH TlsAlloc(void)
Definition: thread.c:657
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
#define actctx
Definition: kernel32.h:8
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 MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define err(...)
#define TRACE(s)
Definition: solgame.cpp:4
IClassFactory IClassFactory_iface
Definition: main.c:44
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:687
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
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define TLS_OUT_OF_INDEXES
Definition: winbase.h:529
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
_Reserved_ PVOID Reserved
Definition: winddi.h:3974
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
#define E_POINTER
Definition: winerror.h:3480
#define CLASS_E_CLASSNOTAVAILABLE
Definition: winerror.h:3772