hhctrl.ocx: Move more code from doWinMain.
[wine] / dlls / hhctrl.ocx / hhctrl.h
1 /*
2  * Copyright 2005 James Hawkins
3  * Copyright 2007 Jacek Caban for CodeWeavers
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  */
19
20 #ifndef HHCTRL_H
21 #define HHCTRL_H
22
23 #include <stdarg.h>
24
25 #define COBJMACROS
26
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "winnls.h"
31 #include "htmlhelp.h"
32 #include "ole2.h"
33 #include "exdisp.h"
34 #include "mshtmhst.h"
35
36 #ifdef INIT_GUID
37 #include "initguid.h"
38 #endif
39
40 #include "wine/itss.h"
41 #include "wine/unicode.h"
42
43 #define WB_GOBACK     0
44 #define WB_GOFORWARD  1
45 #define WB_GOHOME     2
46 #define WB_SEARCH     3
47 #define WB_REFRESH    4
48 #define WB_STOP       5
49
50 typedef struct CHMInfo
51 {
52     IITStorage *pITStorage;
53     IStorage *pStorage;
54     LPCWSTR szFile;
55
56     IStream *strings_stream;
57     char **strings;
58     DWORD strings_size;
59 } CHMInfo;
60
61
62 typedef struct {
63     IOleClientSite *client_site;
64     IWebBrowser2 *web_browser;
65     IOleObject *wb_object;
66
67     HH_WINTYPEW WinType;
68     CHMInfo *pCHMInfo;
69     HWND hwndTabCtrl;
70     HWND hwndSizeBar;
71     HFONT hFont;
72 } HHInfo;
73
74 BOOL InitWebBrowser(HHInfo*,HWND);
75 void ReleaseWebBrowser(HHInfo*);
76 void ResizeWebBrowser(HHInfo*,DWORD,DWORD);
77 void DoPageAction(HHInfo*,DWORD);
78
79 CHMInfo *OpenCHM(LPCWSTR szFile);
80 BOOL LoadWinTypeFromCHM(CHMInfo *pCHMInfo, HH_WINTYPEW *pHHWinType);
81 CHMInfo *CloseCHM(CHMInfo *pCHMInfo);
82
83 /* memory allocation functions */
84
85 static inline void *hhctrl_alloc(size_t len)
86 {
87     return HeapAlloc(GetProcessHeap(), 0, len);
88 }
89
90 static inline void *hhctrl_alloc_zero(size_t len)
91 {
92     return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
93 }
94
95 static inline void *hhctrl_realloc(void *mem, size_t len)
96 {
97     return HeapReAlloc(GetProcessHeap(), 0, mem, len);
98 }
99
100 static inline void *hhctrl_realloc_zero(void *mem, size_t len)
101 {
102     return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
103 }
104
105 static inline BOOL hhctrl_free(void *mem)
106 {
107     return HeapFree(GetProcessHeap(), 0, mem);
108 }
109
110 static inline LPWSTR strdupW(LPCWSTR str)
111 {
112     LPWSTR ret;
113     int size;
114
115     if(!str)
116         return NULL;
117
118     size = (strlenW(str)+1)*sizeof(WCHAR);
119     ret = hhctrl_alloc(size);
120     memcpy(ret, str, size);
121
122     return ret;
123 }
124
125 static inline LPWSTR strdupAtoW(LPCSTR str)
126 {
127     LPWSTR ret;
128     DWORD len;
129
130     if(!str)
131         return NULL;
132
133     len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
134     ret = hhctrl_alloc(len*sizeof(WCHAR));
135     MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len);
136
137     return ret;
138 }
139
140 extern HINSTANCE hhctrl_hinstance;
141
142 #endif