Preliminary version of the C unit tests run-time environment.
[wine/testsucceed.git] / include / winproc.h
blob3ad4934f4c73df093524551aa3d98a3ff880dec3
1 /*
2 * Window procedure callbacks definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINPROC_H
8 #define __WINE_WINPROC_H
10 #include "windef.h"
11 #include "wine/winbase16.h"
12 #include "winnls.h"
14 typedef enum
16 WIN_PROC_INVALID,
17 WIN_PROC_16,
18 WIN_PROC_32A,
19 WIN_PROC_32W
20 } WINDOWPROCTYPE;
22 typedef enum
24 WIN_PROC_CLASS,
25 WIN_PROC_WINDOW,
26 WIN_PROC_TIMER
27 } WINDOWPROCUSER;
29 typedef void *HWINDOWPROC; /* Really a pointer to a WINDOWPROC */
31 typedef struct
33 WPARAM16 wParam;
34 LPARAM lParam;
35 LRESULT lResult;
36 } MSGPARAM16;
38 typedef struct
40 WPARAM wParam;
41 LPARAM lParam;
42 LRESULT lResult;
43 } MSGPARAM;
45 extern BOOL WINPROC_Init(void);
46 extern WNDPROC16 WINPROC_GetProc( HWINDOWPROC proc, WINDOWPROCTYPE type );
47 extern BOOL WINPROC_SetProc( HWINDOWPROC *pFirst, WNDPROC16 func,
48 WINDOWPROCTYPE type, WINDOWPROCUSER user );
49 extern void WINPROC_FreeProc( HWINDOWPROC proc, WINDOWPROCUSER user );
50 extern WINDOWPROCTYPE WINPROC_GetProcType( HWINDOWPROC proc );
52 extern INT WINPROC_MapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM *pwparam,
53 LPARAM *plparam );
54 extern INT WINPROC_MapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM *pwparam,
55 LPARAM *plparam );
56 extern INT WINPROC_MapMsg16To32A( HWND hwnd, UINT16 msg16, WPARAM16 wParam16,
57 UINT *pmsg32, WPARAM *pwparam32,
58 LPARAM *plparam );
59 extern INT WINPROC_MapMsg16To32W( HWND hwnd, UINT16 msg16, WPARAM16 wParam16,
60 UINT *pmsg32, WPARAM *pwparam32,
61 LPARAM *plparam );
62 extern INT WINPROC_MapMsg32ATo16( HWND hwnd, UINT msg32,
63 WPARAM wParam32, UINT16 *pmsg16,
64 WPARAM16 *pwparam16, LPARAM *plparam );
65 extern INT WINPROC_MapMsg32WTo16( HWND hwnd, UINT msg32,
66 WPARAM wParam32, UINT16 *pmsg16,
67 WPARAM16 *pwparam16, LPARAM *plparam );
68 extern LRESULT WINPROC_UnmapMsg32ATo32W( HWND hwnd, UINT msg, WPARAM wParam,
69 LPARAM lParam, LRESULT result );
70 extern void WINPROC_UnmapMsg32WTo32A( HWND hwnd, UINT msg, WPARAM wParam,
71 LPARAM lParam );
72 extern LRESULT WINPROC_UnmapMsg16To32A( HWND hwnd, UINT msg, WPARAM wParam,
73 LPARAM lParam, LRESULT result );
74 extern LRESULT WINPROC_UnmapMsg16To32W( HWND hwnd, UINT msg, WPARAM wParam,
75 LPARAM lParam, LRESULT result );
76 extern void WINPROC_UnmapMsg32ATo16( HWND hwnd, UINT msg, WPARAM wParam,
77 LPARAM lParam, MSGPARAM16* pm16 );
78 extern void WINPROC_UnmapMsg32WTo16( HWND hwnd, UINT msg, WPARAM wParam,
79 LPARAM lParam, MSGPARAM16* pm16 );
81 /* map a Unicode string to a 16-bit pointer */
82 inline static SEGPTR map_str_32W_to_16( LPCWSTR str )
84 LPSTR ret;
85 INT len;
87 if (!HIWORD(str)) return (SEGPTR)LOWORD(str);
88 len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
89 if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
90 WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
91 return MapLS(ret);
94 /* unmap a Unicode string that was converted to a 16-bit pointer */
95 inline static void unmap_str_32W_to_16( SEGPTR str )
97 if (!HIWORD(str)) return;
98 HeapFree( GetProcessHeap(), 0, MapSL(str) );
99 UnMapLS( str );
102 /* map a 16-bit pointer to a Unicode string */
103 inline static LPWSTR map_str_16_to_32W( SEGPTR str )
105 LPWSTR ret;
106 INT len;
108 if (!HIWORD(str)) return (LPWSTR)(ULONG_PTR)LOWORD(str);
109 len = MultiByteToWideChar( CP_ACP, 0, MapSL(str), -1, NULL, 0 );
110 if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
111 MultiByteToWideChar( CP_ACP, 0, MapSL(str), -1, ret, len );
112 return ret;
115 /* unmap a 16-bit pointer that was converted to a Unicode string */
116 inline static void unmap_str_16_to_32W( LPCWSTR str )
118 if (HIWORD(str)) HeapFree( GetProcessHeap(), 0, (void *)str );
121 #endif /* __WINE_WINPROC_H */