Fixed some bugs in thread safeness for wnd struct.
[wine] / win32 / struct32.c
1 /*
2  * Win32 structure conversion functions
3  *
4  * Copyright 1996 Martin von Loewis
5  */
6
7 #include "struct32.h"
8 #include "winerror.h"
9 #include "debug.h"
10
11 void STRUCT32_MSG16to32(const MSG16 *msg16,MSG *msg32)
12 {
13         msg32->hwnd=(HWND)msg16->hwnd;
14         msg32->message=msg16->message;
15         msg32->wParam=msg16->wParam;
16         msg32->lParam=msg16->lParam;
17         msg32->time=msg16->time;
18         msg32->pt.x=msg16->pt.x;
19         msg32->pt.y=msg16->pt.y;
20 }
21
22 void STRUCT32_MSG32to16(const MSG *msg32,MSG16 *msg16)
23 {
24         msg16->hwnd=(HWND16)msg32->hwnd;
25         msg16->message=msg32->message;
26         msg16->wParam=msg32->wParam;
27         msg16->lParam=msg32->lParam;
28         msg16->time=msg32->time;
29         msg16->pt.x=msg32->pt.x;
30         msg16->pt.y=msg32->pt.y;
31 }
32
33 void STRUCT32_MINMAXINFO32to16( const MINMAXINFO *from, MINMAXINFO16 *to )
34 {
35     CONV_POINT32TO16( &from->ptReserved,     &to->ptReserved );
36     CONV_POINT32TO16( &from->ptMaxSize,      &to->ptMaxSize );
37     CONV_POINT32TO16( &from->ptMaxPosition,  &to->ptMaxPosition );
38     CONV_POINT32TO16( &from->ptMinTrackSize, &to->ptMinTrackSize );
39     CONV_POINT32TO16( &from->ptMaxTrackSize, &to->ptMaxTrackSize );
40 }
41
42 void STRUCT32_MINMAXINFO16to32( const MINMAXINFO16 *from, MINMAXINFO *to )
43 {
44     CONV_POINT16TO32( &from->ptReserved,     &to->ptReserved );
45     CONV_POINT16TO32( &from->ptMaxSize,      &to->ptMaxSize );
46     CONV_POINT16TO32( &from->ptMaxPosition,  &to->ptMaxPosition );
47     CONV_POINT16TO32( &from->ptMinTrackSize, &to->ptMinTrackSize );
48     CONV_POINT16TO32( &from->ptMaxTrackSize, &to->ptMaxTrackSize );
49 }
50
51 void STRUCT32_WINDOWPOS32to16( const WINDOWPOS* from, WINDOWPOS16* to )
52 {
53     to->hwnd            = (HWND16)from->hwnd;
54     to->hwndInsertAfter = (HWND16)from->hwndInsertAfter;
55     to->x               = (INT16)from->x;
56     to->y               = (INT16)from->y;
57     to->cx              = (INT16)from->cx;
58     to->cy              = (INT16)from->cy;
59     to->flags           = (UINT16)from->flags;
60 }
61
62 void STRUCT32_WINDOWPOS16to32( const WINDOWPOS16* from, WINDOWPOS* to )
63 {
64     to->hwnd            = (HWND)from->hwnd;
65     to->hwndInsertAfter = (HWND)from->hwndInsertAfter;
66     to->x               = (INT)from->x;
67     to->y               = (INT)from->y;
68     to->cx              = (INT)from->cx;
69     to->cy              = (INT)from->cy;
70     to->flags           = (UINT)from->flags;
71 }
72
73 void STRUCT32_NCCALCSIZE32to16Flat( const NCCALCSIZE_PARAMS* from,
74                                     NCCALCSIZE_PARAMS16* to, int validRects )
75 {
76     CONV_RECT32TO16( &from->rgrc[0], &to->rgrc[0] );
77     if (validRects)
78     {
79         CONV_RECT32TO16( &from->rgrc[1], &to->rgrc[1] );
80         CONV_RECT32TO16( &from->rgrc[2], &to->rgrc[2] );
81     }
82 }
83
84 void STRUCT32_NCCALCSIZE16to32Flat( const NCCALCSIZE_PARAMS16* from,
85                                     NCCALCSIZE_PARAMS* to, int validRects )
86 {
87     CONV_RECT16TO32( &from->rgrc[0], &to->rgrc[0] );
88     if (validRects)
89     {
90         CONV_RECT32TO16( &from->rgrc[1], &to->rgrc[1] );
91         CONV_RECT32TO16( &from->rgrc[2], &to->rgrc[2] );
92     }
93 }
94
95 /* The strings are not copied */
96 void STRUCT32_CREATESTRUCT32Ato16( const CREATESTRUCTA* from,
97                                    CREATESTRUCT16* to )
98 {
99     to->lpCreateParams = from->lpCreateParams;
100     to->hInstance      = (HINSTANCE16)from->hInstance;
101     to->hMenu          = (HMENU16)from->hMenu;
102     to->hwndParent     = (HWND16)from->hwndParent;
103     to->cy             = (INT16)from->cy;
104     to->cx             = (INT16)from->cx;
105     to->y              = (INT16)from->y;
106     to->x              = (INT16)from->x;
107     to->style          = from->style;
108     to->dwExStyle      = from->dwExStyle;
109 }
110
111 void STRUCT32_CREATESTRUCT16to32A( const CREATESTRUCT16* from,
112                                    CREATESTRUCTA *to )
113 {
114     to->lpCreateParams = from->lpCreateParams;
115     to->hInstance      = (HINSTANCE)from->hInstance;
116     to->hMenu          = (HMENU)from->hMenu;
117     to->hwndParent     = (HWND)from->hwndParent;
118     to->cy             = (INT)from->cy;
119     to->cx             = (INT)from->cx;
120     to->y              = (INT)from->y;
121     to->x              = (INT)from->x;
122     to->style          = from->style;
123     to->dwExStyle      = from->dwExStyle;
124 }
125
126 /* The strings are not copied */
127 void STRUCT32_MDICREATESTRUCT32Ato16( const MDICREATESTRUCTA* from,
128                                       MDICREATESTRUCT16* to )
129 {
130     to->hOwner = (HINSTANCE16)from->hOwner;
131     to->x      = (INT16)from->x;     
132     to->y      = (INT16)from->y;     
133     to->cx     = (INT16)from->cx;    
134     to->cy     = (INT16)from->cy;    
135     to->style  = from->style; 
136     to->lParam = from->lParam;
137 }
138
139 void STRUCT32_MDICREATESTRUCT16to32A( const MDICREATESTRUCT16* from,
140                                       MDICREATESTRUCTA *to )
141 {
142     to->hOwner = (HINSTANCE)from->hOwner;
143     to->x      = (INT)from->x;     
144     to->y      = (INT)from->y;     
145     to->cx     = (INT)from->cx;    
146     to->cy     = (INT)from->cy;    
147     to->style  = from->style; 
148     to->lParam = from->lParam;
149 }
150