* Sync up to trunk head (r65426).
[reactos.git] / dll / shellext / stobject / precomp.h
1 #pragma once
2
3 #define WIN32_NO_STATUS
4 #include <stdarg.h>
5 #include <tchar.h>
6
7 #define COBJMACROS
8 #define WIN32_NO_STATUS
9 #define _INC_WINDOWS
10 #define COM_NO_WINDOWS_H
11 #define NTOS_MODE_USER
12
13 #include <windef.h>
14 #include <winbase.h>
15 #include <winreg.h>
16 #include <winuser.h>
17 #include <wincon.h>
18 #include <ddeml.h>
19 #include <shlguid_undoc.h>
20 #include <shlwapi.h>
21 #include <shlobj.h>
22 #include <shlobj_undoc.h>
23 #include <shlwapi_undoc.h>
24 #include <tchar.h>
25 #include <strsafe.h>
26 #include <atlbase.h>
27 #include <atlcom.h>
28 #include <atlwin.h>
29
30 #include <shellapi.h>
31
32 #include <wine/debug.h>
33 #include <wine/unicode.h>
34
35 #include "resource.h"
36
37 extern HINSTANCE g_hInstance;
38
39 #define ID_ICON_VOLUME (WM_APP + 0x4CB)
40
41 #include "csystray.h"
42
43 typedef HRESULT(STDMETHODCALLTYPE * PFNSTINIT) (_In_ CSysTray * pSysTray);
44 typedef HRESULT(STDMETHODCALLTYPE * PFNSTSHUTDOWN) (_In_ CSysTray * pSysTray);
45 typedef HRESULT(STDMETHODCALLTYPE * PFNSTUPDATE) (_In_ CSysTray * pSysTray);
46 typedef HRESULT(STDMETHODCALLTYPE * PFNSTMESSAGE) (_In_ CSysTray * pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam);
47
48 struct SysTrayIconHandlers_t
49 {
50 PFNSTINIT pfnInit;
51 PFNSTSHUTDOWN pfnShutdown;
52 PFNSTUPDATE pfnUpdate;
53 PFNSTMESSAGE pfnMessage;
54 };
55
56 extern SysTrayIconHandlers_t g_IconHandlers[];
57 extern const int g_NumIcons;
58
59 /* --------------- Icon callbacks ------------------------------ */
60
61 extern HRESULT STDMETHODCALLTYPE Volume_Init(_In_ CSysTray * pSysTray);
62 extern HRESULT STDMETHODCALLTYPE Volume_Shutdown(_In_ CSysTray * pSysTray);
63 extern HRESULT STDMETHODCALLTYPE Volume_Update(_In_ CSysTray * pSysTray);
64 extern HRESULT STDMETHODCALLTYPE Volume_Message(_In_ CSysTray * pSysTray, UINT uMsg, WPARAM wParam, LPARAM lParam);
65
66 /* --------------- Utils ------------------------------ */
67
68 static __inline ULONG
69 Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
70 {
71 char szMsg[512];
72 char *szMsgStart;
73 const char *fname;
74 va_list vl;
75 ULONG uRet;
76
77 fname = strrchr(filename, '\\');
78 if (fname == NULL)
79 {
80 fname = strrchr(filename, '/');
81 }
82
83 if (fname == NULL)
84 fname = filename;
85 else
86 fname++;
87
88 szMsgStart = szMsg + sprintf(szMsg, "[%10lu] %s:%d: ", GetTickCount(), fname, line);
89
90 va_start(vl, lpFormat);
91 uRet = (ULONG) vsprintf(szMsgStart, lpFormat, vl);
92 va_end(vl);
93
94 OutputDebugStringA(szMsg);
95
96 return uRet;
97 }
98
99 #define DbgPrint(fmt, ...) \
100 Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
101
102 #if 1
103 #define FAILED_UNEXPECTEDLY(hr) (FAILED(hr) && (DbgPrint("Unexpected failure %08x.\n", hr), TRUE))
104 #else
105 #define FAILED_UNEXPECTEDLY(hr) FAILED(hr)
106 #endif
107