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