Release 970914
[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_MSG16to32(const MSG16 *msg16,MSG32 *msg32)
15 {
16         msg32->hwnd=(HWND32)msg16->hwnd;
17         msg32->message=msg16->message;
18         msg32->wParam=msg16->wParam;
19         msg32->lParam=msg16->lParam;
20         msg32->time=msg16->time;
21         msg32->pt.x=msg16->pt.x;
22         msg32->pt.y=msg16->pt.y;
23 }
24
25 void STRUCT32_MSG32to16(const MSG32 *msg32,MSG16 *msg16)
26 {
27         msg16->hwnd=(HWND16)msg32->hwnd;
28         msg16->message=msg32->message;
29         msg16->wParam=msg32->wParam;
30         msg16->lParam=msg32->lParam;
31         msg16->time=msg32->time;
32         msg16->pt.x=msg32->pt.x;
33         msg16->pt.y=msg32->pt.y;
34 }
35
36 void STRUCT32_MINMAXINFO32to16( const MINMAXINFO32 *from, MINMAXINFO16 *to )
37 {
38     CONV_POINT32TO16( &from->ptReserved,     &to->ptReserved );
39     CONV_POINT32TO16( &from->ptMaxSize,      &to->ptMaxSize );
40     CONV_POINT32TO16( &from->ptMaxPosition,  &to->ptMaxPosition );
41     CONV_POINT32TO16( &from->ptMinTrackSize, &to->ptMinTrackSize );
42     CONV_POINT32TO16( &from->ptMaxTrackSize, &to->ptMaxTrackSize );
43 }
44
45 void STRUCT32_MINMAXINFO16to32( const MINMAXINFO16 *from, MINMAXINFO32 *to )
46 {
47     CONV_POINT16TO32( &from->ptReserved,     &to->ptReserved );
48     CONV_POINT16TO32( &from->ptMaxSize,      &to->ptMaxSize );
49     CONV_POINT16TO32( &from->ptMaxPosition,  &to->ptMaxPosition );
50     CONV_POINT16TO32( &from->ptMinTrackSize, &to->ptMinTrackSize );
51     CONV_POINT16TO32( &from->ptMaxTrackSize, &to->ptMaxTrackSize );
52 }
53
54 void STRUCT32_WINDOWPOS32to16( const WINDOWPOS32* from, WINDOWPOS16* to )
55 {
56     to->hwnd            = (HWND16)from->hwnd;
57     to->hwndInsertAfter = (HWND16)from->hwndInsertAfter;
58     to->x               = (INT16)from->x;
59     to->y               = (INT16)from->y;
60     to->cx              = (INT16)from->cx;
61     to->cy              = (INT16)from->cy;
62     to->flags           = (UINT16)from->flags;
63 }
64
65 void STRUCT32_WINDOWPOS16to32( const WINDOWPOS16* from, WINDOWPOS32* to )
66 {
67     to->hwnd            = (HWND32)from->hwnd;
68     to->hwndInsertAfter = (HWND32)from->hwndInsertAfter;
69     to->x               = (INT32)from->x;
70     to->y               = (INT32)from->y;
71     to->cx              = (INT32)from->cx;
72     to->cy              = (INT32)from->cy;
73     to->flags           = (UINT32)from->flags;
74 }
75
76 void STRUCT32_NCCALCSIZE32to16Flat( const NCCALCSIZE_PARAMS32* from,
77                                     NCCALCSIZE_PARAMS16* to, int validRects )
78 {
79     CONV_RECT32TO16( &from->rgrc[0], &to->rgrc[0] );
80     if (validRects)
81     {
82         CONV_RECT32TO16( &from->rgrc[1], &to->rgrc[1] );
83         CONV_RECT32TO16( &from->rgrc[2], &to->rgrc[2] );
84     }
85 }
86
87 void STRUCT32_NCCALCSIZE16to32Flat( const NCCALCSIZE_PARAMS16* from,
88                                     NCCALCSIZE_PARAMS32* to, int validRects )
89 {
90     CONV_RECT16TO32( &from->rgrc[0], &to->rgrc[0] );
91     if (validRects)
92     {
93         CONV_RECT32TO16( &from->rgrc[1], &to->rgrc[1] );
94         CONV_RECT32TO16( &from->rgrc[2], &to->rgrc[2] );
95     }
96 }
97
98 /* The strings are not copied */
99 void STRUCT32_CREATESTRUCT32Ato16( const CREATESTRUCT32A* from,
100                                    CREATESTRUCT16* to )
101 {
102     to->lpCreateParams = from->lpCreateParams;
103     to->hInstance      = (HINSTANCE16)from->hInstance;
104     to->hMenu          = (HMENU16)from->hMenu;
105     to->hwndParent     = (HWND16)from->hwndParent;
106     to->cy             = (INT16)from->cy;
107     to->cx             = (INT16)from->cx;
108     to->y              = (INT16)from->y;
109     to->x              = (INT16)from->x;
110     to->style          = from->style;
111     to->dwExStyle      = from->dwExStyle;
112 }
113
114 void STRUCT32_CREATESTRUCT16to32A( const CREATESTRUCT16* from,
115                                    CREATESTRUCT32A *to )
116 {
117     to->lpCreateParams = from->lpCreateParams;
118     to->hInstance      = (HINSTANCE32)from->hInstance;
119     to->hMenu          = (HMENU32)from->hMenu;
120     to->hwndParent     = (HWND32)from->hwndParent;
121     to->cy             = (INT32)from->cy;
122     to->cx             = (INT32)from->cx;
123     to->y              = (INT32)from->y;
124     to->x              = (INT32)from->x;
125     to->style          = from->style;
126     to->dwExStyle      = from->dwExStyle;
127 }
128
129 /* The strings are not copied */
130 void STRUCT32_MDICREATESTRUCT32Ato16( const MDICREATESTRUCT32A* from,
131                                       MDICREATESTRUCT16* to )
132 {
133     to->hOwner = (HINSTANCE16)from->hOwner;
134     to->x      = (INT16)from->x;     
135     to->y      = (INT16)from->y;     
136     to->cx     = (INT16)from->cx;    
137     to->cy     = (INT16)from->cy;    
138     to->style  = from->style; 
139     to->lParam = from->lParam;
140 }
141
142 void STRUCT32_MDICREATESTRUCT16to32A( const MDICREATESTRUCT16* from,
143                                       MDICREATESTRUCT32A *to )
144 {
145     to->hOwner = (HINSTANCE32)from->hOwner;
146     to->x      = (INT32)from->x;     
147     to->y      = (INT32)from->y;     
148     to->cx     = (INT32)from->cx;    
149     to->cy     = (INT32)from->cy;    
150     to->style  = from->style; 
151     to->lParam = from->lParam;
152 }
153