user: Replace WINDOWPROCTYPE by a unicode flag in WINPROC_GetProc/AllocProc.
[wine] / dlls / user / winproc.h
1 /*
2  * Window procedure callbacks definitions
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_WINPROC_H
22 #define __WINE_WINPROC_H
23
24 #include <stdarg.h>
25
26 #include "windef.h"
27 #include "winbase.h"
28 #include "wine/winbase16.h"
29 #include "winnls.h"
30
31 typedef enum
32 {
33     WIN_PROC_INVALID,
34     WIN_PROC_16,
35     WIN_PROC_32A,
36     WIN_PROC_32W
37 } WINDOWPROCTYPE;
38
39 typedef struct
40 {
41     WPARAM16    wParam;
42     LPARAM      lParam;
43     LRESULT     lResult;
44 } MSGPARAM16;
45
46 typedef struct
47 {
48     WPARAM    wParam;
49     LPARAM      lParam;
50     LRESULT     lResult;
51 } MSGPARAM;
52
53 struct tagWINDOWPROC;
54
55 extern WNDPROC16 WINPROC_GetProc16( WNDPROC proc );
56 extern WNDPROC WINPROC_AllocProc16( WNDPROC16 func );
57 extern WNDPROC WINPROC_GetProc( WNDPROC proc, BOOL unicode );
58 extern WNDPROC WINPROC_AllocProc( WNDPROC func, BOOL unicode );
59 extern WINDOWPROCTYPE WINPROC_GetProcType( WNDPROC proc );
60
61 extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam,
62                                      LPARAM *plparam );
63 extern INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16,
64                                     UINT *pmsg32, WPARAM *pwparam32,
65                                     LPARAM *plparam );
66 extern INT WINPROC_MapMsg16To32W( HWND hwnd, UINT16 msg16, WPARAM16 wParam16,
67                                     UINT *pmsg32, WPARAM *pwparam32,
68                                     LPARAM *plparam );
69 extern INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32,
70                                     WPARAM wParam32, UINT16 *pmsg16,
71                                     WPARAM16 *pwparam16, LPARAM *plparam );
72 extern INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32,
73                                     WPARAM wParam32, UINT16 *pmsg16,
74                                     WPARAM16 *pwparam16, LPARAM *plparam );
75 extern LRESULT WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam,
76                                          LPARAM lParam, LRESULT result,
77                                          WNDPROC dispatch );
78 extern LRESULT WINPROC_UnmapMsg16To32A( HWND hwnd, UINT msg, WPARAM wParam,
79                                         LPARAM lParam, LRESULT result );
80 extern LRESULT WINPROC_UnmapMsg16To32W( HWND hwnd, UINT msg, WPARAM wParam,
81                                         LPARAM lParam, LRESULT result,
82                                         WNDPROC dispatch );
83 extern void WINPROC_UnmapMsg32ATo16( HWND hwnd, UINT msg, WPARAM wParam,
84                                      LPARAM lParam, MSGPARAM16* pm16 );
85 extern void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam,
86                                      LPARAM lParam, MSGPARAM16* pm16 );
87
88 extern INT_PTR WINPROC_CallDlgProc16( DLGPROC16 func, HWND16 hwnd, UINT16 msg, WPARAM16 wParam, LPARAM lParam );
89 extern INT_PTR WINPROC_CallDlgProcA( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
90 extern INT_PTR WINPROC_CallDlgProcW( DLGPROC func, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam );
91
92 /* map a Unicode string to a 16-bit pointer */
93 inline static SEGPTR map_str_32W_to_16( LPCWSTR str )
94 {
95     LPSTR ret;
96     INT len;
97
98     if (!HIWORD(str)) return (SEGPTR)LOWORD(str);
99     len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
100     if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
101         WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
102     return MapLS(ret);
103 }
104
105 /* unmap a Unicode string that was converted to a 16-bit pointer */
106 inline static void unmap_str_32W_to_16( SEGPTR str )
107 {
108     if (!HIWORD(str)) return;
109     HeapFree( GetProcessHeap(), 0, MapSL(str) );
110     UnMapLS( str );
111 }
112
113 /* map a 16-bit pointer to a Unicode string */
114 inline static LPWSTR map_str_16_to_32W( SEGPTR str )
115 {
116     LPWSTR ret;
117     INT len;
118
119     if (!HIWORD(str)) return (LPWSTR)(ULONG_PTR)LOWORD(str);
120     len = MultiByteToWideChar( CP_ACP, 0, MapSL(str), -1, NULL, 0 );
121     if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
122         MultiByteToWideChar( CP_ACP, 0, MapSL(str), -1, ret, len );
123     return ret;
124 }
125
126 /* unmap a 16-bit pointer that was converted to a Unicode string */
127 inline static void unmap_str_16_to_32W( LPCWSTR str )
128 {
129     if (HIWORD(str)) HeapFree( GetProcessHeap(), 0, (void *)str );
130 }
131
132
133 /* Class functions */
134 struct tagCLASS;  /* opaque structure */
135 struct tagWND;
136 extern void CLASS_RegisterBuiltinClasses(void);
137 extern void CLASS_AddWindow( struct tagCLASS *class, struct tagWND *win, WINDOWPROCTYPE type );
138 extern void CLASS_FreeModuleClasses( HMODULE16 hModule );
139
140 #endif  /* __WINE_WINPROC_H */