Made all 16<->32 HWND conversions use explicit functions instead of
[wine] / windows / struct32.c
1 /*
2  * Win32 structure conversion functions
3  *
4  * Copyright 1996 Martin von Loewis
5  */
6
7 #include "struct32.h"
8 #include "win.h"
9 #include "winerror.h"
10
11 void STRUCT32_MSG16to32(const MSG16 *msg16,MSG *msg32)
12 {
13         msg32->hwnd = WIN_Handle32(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 = WIN_Handle16(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            = WIN_Handle16(from->hwnd);
54     to->hwndInsertAfter = WIN_Handle16(from->hwndInsertAfter);
55     to->x               = from->x;
56     to->y               = from->y;
57     to->cx              = from->cx;
58     to->cy              = from->cy;
59     to->flags           = from->flags;
60 }
61
62 void STRUCT32_WINDOWPOS16to32( const WINDOWPOS16* from, WINDOWPOS* to )
63 {
64     to->hwnd            = WIN_Handle32(from->hwnd);
65     to->hwndInsertAfter = (from->hwndInsertAfter == (HWND16)-1) ?
66                            HWND_TOPMOST : WIN_Handle32(from->hwndInsertAfter);
67     to->x               = from->x;
68     to->y               = from->y;
69     to->cx              = from->cx;
70     to->cy              = from->cy;
71     to->flags           = from->flags;
72 }
73
74 /* The strings are not copied */
75 void STRUCT32_CREATESTRUCT32Ato16( const CREATESTRUCTA* from,
76                                    CREATESTRUCT16* to )
77 {
78     to->lpCreateParams = from->lpCreateParams;
79     to->hInstance      = (HINSTANCE16)from->hInstance;
80     to->hMenu          = (HMENU16)from->hMenu;
81     to->hwndParent     = WIN_Handle16(from->hwndParent);
82     to->cy             = from->cy;
83     to->cx             = from->cx;
84     to->y              = from->y;
85     to->x              = from->x;
86     to->style          = from->style;
87     to->dwExStyle      = from->dwExStyle;
88 }
89
90 void STRUCT32_CREATESTRUCT16to32A( const CREATESTRUCT16* from,
91                                    CREATESTRUCTA *to )
92 {
93     to->lpCreateParams = from->lpCreateParams;
94     to->hInstance      = (HINSTANCE)from->hInstance;
95     to->hMenu          = (HMENU)from->hMenu;
96     to->hwndParent     = WIN_Handle32(from->hwndParent);
97     to->cy             = from->cy;
98     to->cx             = from->cx;
99     to->y              = from->y;
100     to->x              = from->x;
101     to->style          = from->style;
102     to->dwExStyle      = from->dwExStyle;
103 }
104
105 /* The strings are not copied */
106 void STRUCT32_MDICREATESTRUCT32Ato16( const MDICREATESTRUCTA* from,
107                                       MDICREATESTRUCT16* to )
108 {
109     to->hOwner = (HINSTANCE16)from->hOwner;
110     to->x      = from->x;
111     to->y      = from->y;
112     to->cx     = from->cx;
113     to->cy     = from->cy;
114     to->style  = from->style;
115     to->lParam = from->lParam;
116 }
117
118 void STRUCT32_MDICREATESTRUCT16to32A( const MDICREATESTRUCT16* from,
119                                       MDICREATESTRUCTA *to )
120 {
121     to->hOwner = (HINSTANCE)from->hOwner;
122     to->x      = from->x;
123     to->y      = from->y;
124     to->cx     = from->cx;
125     to->cy     = from->cy;
126     to->style  = from->style;
127     to->lParam = from->lParam;
128 }
129