323deb65e535e7aa26c37ce06abc5ffbd9d52038
[reactos.git] / dll / win32 / browseui / precomp.h
1 #ifndef _BROWSEUI_PCH_
2 #define _BROWSEUI_PCH_
3
4 #include <stdarg.h>
5
6 #define WIN32_NO_STATUS
7 #define _INC_WINDOWS
8 #define COM_NO_WINDOWS_H
9
10 #include <windef.h>
11 #include <winbase.h>
12 #include <wincon.h>
13 #include <shlobj.h>
14 #include <tlogstg.h>
15 #include <shlobj_undoc.h>
16 #include <shlguid_undoc.h>
17 #include <shdeprecated.h>
18 #include <tchar.h>
19 #include <atlbase.h>
20 #include <atlcom.h>
21 #include <atlwin.h>
22 #include <perhist.h>
23 #include <exdispid.h>
24 #include <shlwapi.h>
25 #include <shlwapi_undoc.h>
26 #include <wine/debug.h>
27
28 #include "resource.h"
29
30 #include "aclmulti.h"
31 #include "addressband.h"
32 #include "addresseditbox.h"
33 #include "bandproxy.h"
34 #include "bandsite.h"
35 #include "bandsitemenu.h"
36 #include "brandband.h"
37 #include "internettoolbar.h"
38 #include "commonbrowser.h"
39 #include "globalfoldersettings.h"
40 #include "regtreeoptions.h"
41 #include <stdio.h>
42
43 static __inline ULONG
44 Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
45 {
46 char szMsg[512];
47 char *szMsgStart;
48 const char *fname;
49 va_list vl;
50 ULONG uRet;
51
52 fname = strrchr(filename, '\\');
53 if (fname == NULL)
54 {
55 fname = strrchr(filename, '/');
56 if (fname != NULL)
57 fname++;
58 }
59 else
60 fname++;
61
62 if (fname == NULL)
63 fname = filename;
64
65 szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
66
67 va_start(vl, lpFormat);
68 uRet = (ULONG) vsprintf(szMsgStart, lpFormat, vl);
69 va_end(vl);
70
71 OutputDebugStringA(szMsg);
72
73 return uRet;
74 }
75
76 #define DbgPrint(fmt, ...) \
77 Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
78
79 #if 1
80 #define FAILED_UNEXPECTEDLY(hr) (FAILED(hr) && (DbgPrint("Unexpected failure %08x.\n", hr), TRUE))
81 #else
82 #define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
83 #endif
84
85
86 template <class Base>
87 class CComDebugObject : public Base
88 {
89 public:
90 CComDebugObject(void * = NULL)
91 {
92 _pAtlModule->Lock();
93 }
94
95 virtual ~CComDebugObject()
96 {
97 this->FinalRelease();
98 _pAtlModule->Unlock();
99 }
100
101 STDMETHOD_(ULONG, AddRef)()
102 {
103 int rc = this->InternalAddRef();
104 DbgPrint("RefCount is now %d(++)!\n", rc);
105 return rc;
106 }
107
108 STDMETHOD_(ULONG, Release)()
109 {
110 ULONG newRefCount;
111
112 newRefCount = this->InternalRelease();
113 DbgPrint("RefCount is now %d(--)!\n", newRefCount);
114 if (newRefCount == 0)
115 delete this;
116 return newRefCount;
117 }
118
119 STDMETHOD(QueryInterface)(REFIID iid, void **ppvObject)
120 {
121 return this->_InternalQueryInterface(iid, ppvObject);
122 }
123
124 static HRESULT WINAPI CreateInstance(CComDebugObject<Base> **pp)
125 {
126 CComDebugObject<Base> *newInstance;
127 HRESULT hResult;
128
129 ATLASSERT(pp != NULL);
130 if (pp == NULL)
131 return E_POINTER;
132
133 hResult = E_OUTOFMEMORY;
134 newInstance = NULL;
135 ATLTRY(newInstance = new CComDebugObject<Base>())
136 if (newInstance != NULL)
137 {
138 newInstance->SetVoid(NULL);
139 newInstance->InternalFinalConstructAddRef();
140 hResult = newInstance->_AtlInitialConstruct();
141 if (SUCCEEDED(hResult))
142 hResult = newInstance->FinalConstruct();
143 if (SUCCEEDED(hResult))
144 hResult = newInstance->_AtlFinalConstruct();
145 newInstance->InternalFinalConstructRelease();
146 if (hResult != S_OK)
147 {
148 delete newInstance;
149 newInstance = NULL;
150 }
151 }
152 *pp = newInstance;
153 return hResult;
154 }
155 };
156
157 WINE_DEFAULT_DEBUG_CHANNEL(browseui);
158
159 #endif /* _BROWSEUI_PCH_ */