Release 960623
[wine] / win32 / struct32.c
1 /*
2  * Win32 structure conversion functions
3  *
4  * Copyright 1996 Martin von Loewis
5  */
6
7 #include <stdio.h>
8 #include "windows.h"
9 #include "winerror.h"
10 #include "struct32.h"
11 #include "stddebug.h"
12 #include "debug.h"
13
14 void STRUCT32_POINT32to16(const POINT32* p32, POINT16* p16)
15 {
16         p16->x = p32->x;
17         p16->y = p32->y;
18 }
19
20 void STRUCT32_POINT16to32(const POINT16* p16, POINT32* p32)
21 {
22         p32->x = p16->x;
23         p32->y = p16->y;
24 }
25
26 void STRUCT32_SIZE16to32(const SIZE16* p16, SIZE32* p32) 
27   
28 {
29         p32->cx = p16->cx;
30         p32->cy = p16->cy;
31 }
32
33 void STRUCT32_MSG16to32(const MSG16 *msg16,MSG32 *msg32)
34 {
35         msg32->hwnd=(DWORD)msg16->hwnd;
36         msg32->message=msg16->message;
37         msg32->wParam=msg16->wParam;
38         msg32->lParam=msg16->lParam;
39         msg32->time=msg16->time;
40         msg32->pt.x=msg16->pt.x;
41         msg32->pt.y=msg16->pt.y;
42 }
43
44 void STRUCT32_MSG32to16(const MSG32 *msg32,MSG16 *msg16)
45 {
46         msg16->hwnd=(HWND)msg32->hwnd;
47         msg16->message=msg32->message;
48         msg16->wParam=msg32->wParam;
49         msg16->lParam=msg32->lParam;
50         msg16->time=msg32->time;
51         msg16->pt.x=msg32->pt.x;
52         msg16->pt.y=msg32->pt.y;
53 }
54
55 void STRUCT32_RECT32to16(const RECT32* r32, RECT16 *r16)
56 {
57         r16->left = r32->left;
58         r16->right = r32->right;
59         r16->top = r32->top;
60         r16->bottom = r32->bottom;
61 }
62
63 void STRUCT32_RECT16to32(const RECT16* r16, RECT32 *r32)
64 {
65         r32->left = r16->left;
66         r32->right = r16->right;
67         r32->top = r16->top;
68         r32->bottom = r16->bottom;
69 }
70
71 void STRUCT32_MINMAXINFO32to16( const MINMAXINFO32 *from, MINMAXINFO16 *to )
72 {
73     CONV_POINT32TO16( &from->ptReserved,     &to->ptReserved );
74     CONV_POINT32TO16( &from->ptMaxSize,      &to->ptMaxSize );
75     CONV_POINT32TO16( &from->ptMaxPosition,  &to->ptMaxPosition );
76     CONV_POINT32TO16( &from->ptMinTrackSize, &to->ptMinTrackSize );
77     CONV_POINT32TO16( &from->ptMaxTrackSize, &to->ptMaxTrackSize );
78 }
79
80 void STRUCT32_MINMAXINFO16to32( const MINMAXINFO16 *from, MINMAXINFO32 *to )
81 {
82     CONV_POINT16TO32( &from->ptReserved,     &to->ptReserved );
83     CONV_POINT16TO32( &from->ptMaxSize,      &to->ptMaxSize );
84     CONV_POINT16TO32( &from->ptMaxPosition,  &to->ptMaxPosition );
85     CONV_POINT16TO32( &from->ptMinTrackSize, &to->ptMinTrackSize );
86     CONV_POINT16TO32( &from->ptMaxTrackSize, &to->ptMaxTrackSize );
87 }
88
89 void STRUCT32_WINDOWPOS32to16( const WINDOWPOS32* from, WINDOWPOS16* to )
90 {
91     to->hwnd            = (HWND16)from->hwnd;
92     to->hwndInsertAfter = (HWND16)from->hwndInsertAfter;
93     to->x               = (INT16)from->x;
94     to->y               = (INT16)from->y;
95     to->cx              = (INT16)from->cx;
96     to->cy              = (INT16)from->cy;
97     to->flags           = (UINT16)from->flags;
98 }
99
100 void STRUCT32_WINDOWPOS16to32( const WINDOWPOS16* from, WINDOWPOS32* to )
101 {
102     to->hwnd            = (HWND32)from->hwnd;
103     to->hwndInsertAfter = (HWND32)from->hwndInsertAfter;
104     to->x               = (INT32)from->x;
105     to->y               = (INT32)from->y;
106     to->cx              = (INT32)from->cx;
107     to->cy              = (INT32)from->cy;
108     to->flags           = (UINT32)from->flags;
109 }
110
111 void STRUCT32_NCCALCSIZE32to16Flat( const NCCALCSIZE_PARAMS32* from,
112                                     NCCALCSIZE_PARAMS16* to, int validRects )
113 {
114     CONV_RECT32TO16( &from->rgrc[0], &to->rgrc[0] );
115     if (validRects)
116     {
117         CONV_RECT32TO16( &from->rgrc[1], &to->rgrc[1] );
118         CONV_RECT32TO16( &from->rgrc[2], &to->rgrc[2] );
119     }
120 }
121
122 void STRUCT32_NCCALCSIZE16to32Flat( const NCCALCSIZE_PARAMS16* from,
123                                     NCCALCSIZE_PARAMS32* to, int validRects )
124 {
125     CONV_RECT16TO32( &from->rgrc[0], &to->rgrc[0] );
126     if (validRects)
127     {
128         CONV_RECT32TO16( &from->rgrc[1], &to->rgrc[1] );
129         CONV_RECT32TO16( &from->rgrc[2], &to->rgrc[2] );
130     }
131 }
132
133 /* The strings are not copied */
134 void STRUCT32_CREATESTRUCT32Ato16( const CREATESTRUCT32A* from,
135                                    CREATESTRUCT16* to )
136 {
137     to->lpCreateParams = from->lpCreateParams;
138     to->hInstance      = (HINSTANCE16)from->hInstance;
139     to->hMenu          = (HMENU16)from->hMenu;
140     to->hwndParent     = (HWND16)from->hwndParent;
141     to->cy             = (INT16)from->cy;
142     to->cx             = (INT16)from->cx;
143     to->y              = (INT16)from->y;
144     to->x              = (INT16)from->x;
145     to->style          = from->style;
146     to->dwExStyle      = from->dwExStyle;
147 }
148
149 void STRUCT32_CREATESTRUCT16to32A( const CREATESTRUCT16* from,
150                                    CREATESTRUCT32A *to )
151 {
152     to->lpCreateParams = from->lpCreateParams;
153     to->hInstance      = (HINSTANCE32)from->hInstance;
154     to->hMenu          = (HMENU32)from->hMenu;
155     to->hwndParent     = (HWND32)from->hwndParent;
156     to->cy             = (INT32)from->cy;
157     to->cx             = (INT32)from->cx;
158     to->y              = (INT32)from->y;
159     to->x              = (INT32)from->x;
160     to->style          = from->style;
161     to->dwExStyle      = from->dwExStyle;
162 }