Release 951124
[wine/multimedia.git] / misc / user32.c
bloba9ce9af90f873c989ce1d6f36fac944d74858649
1 /*
2 * Win32 user functions
4 * Copyright 1995 Martin von Loewis
5 */
7 /* This file contains only wrappers to existing Wine functions or trivial
8 stubs. 'Real' implementations go into context specific files */
10 #include <unistd.h>
11 #include "windows.h"
12 #include "winerror.h"
13 #include "relay32.h"
14 #include "alias.h"
15 #include "stackframe.h"
17 /* Structure copy functions */
18 static void MSG16to32(MSG *msg16,struct WIN32_MSG *msg32)
20 msg32->hwnd=(DWORD)msg16->hwnd;
21 msg32->message=msg16->message;
22 msg32->wParam=msg16->wParam;
23 msg32->lParam=msg16->lParam;
24 msg32->time=msg16->time;
25 msg32->pt.x=msg16->pt.x;
26 msg32->pt.y=msg16->pt.y;
29 static void MSG32to16(struct WIN32_MSG *msg32,MSG *msg16)
31 msg16->hwnd=(HWND)msg32->hwnd;
32 msg16->message=msg32->message;
33 msg16->wParam=msg32->wParam;
34 msg16->lParam=msg32->lParam;
35 msg16->time=msg32->time;
36 msg16->pt.x=msg32->pt.x;
37 msg16->pt.y=msg32->pt.y;
40 /***********************************************************************
41 * RegisterClassA (USER32.426)
43 ATOM USER32_RegisterClassA(WNDCLASSA* wndclass)
45 WNDCLASS copy;
46 char *s1,*s2;
47 copy.style=wndclass->style;
48 ALIAS_RegisterAlias(0,0,(DWORD)wndclass->lpfnWndProc);
49 copy.lpfnWndProc=wndclass->lpfnWndProc;
50 copy.cbClsExtra=wndclass->cbClsExtra;
51 copy.cbWndExtra=wndclass->cbWndExtra;
52 copy.hInstance=(HINSTANCE)wndclass->hInstance;
53 copy.hIcon=(HICON)wndclass->hIcon;
54 copy.hCursor=(HCURSOR)wndclass->hCursor;
55 copy.hbrBackground=(HBRUSH)wndclass->hbrBackground;
56 if(wndclass->lpszMenuName)
58 s1=alloca(strlen(wndclass->lpszMenuName)+1);
59 strcpy(s1,wndclass->lpszMenuName);
60 copy.lpszMenuName=MAKE_SEGPTR(s1);
61 }else
62 copy.lpszMenuName=0;
63 if(wndclass->lpszClassName)
65 s2=alloca(strlen(wndclass->lpszClassName)+1);
66 strcpy(s2,wndclass->lpszClassName);
67 copy.lpszClassName=MAKE_SEGPTR(s2);
69 return RegisterClass(&copy);
72 /***********************************************************************
73 * DefWindowProcA (USER32.125)
75 LRESULT USER32_DefWindowProcA(DWORD hwnd,DWORD msg,DWORD wParam,DWORD lParam)
77 /* some messages certainly need special casing. We come to that later */
78 return DefWindowProc((HWND)hwnd,msg,wParam,lParam);
81 /***********************************************************************
82 * GetMessageA (USER32.269)
84 BOOL USER32_GetMessageA(struct WIN32_MSG* lpmsg,DWORD hwnd,DWORD min,DWORD max)
86 BOOL ret;
87 MSG msg;
88 ret=GetMessage(MAKE_SEGPTR(&msg),(HWND)hwnd,min,max);
89 MSG16to32(&msg,lpmsg);
90 return ret;
93 /***********************************************************************
94 * BeginPaint (USER32.9)
96 HDC USER32_BeginPaint(DWORD hwnd,struct WIN32_PAINTSTRUCT *lpps)
98 PAINTSTRUCT ps;
99 HDC ret;
100 ret=BeginPaint((HWND)hwnd,&ps);
101 lpps->hdc=(DWORD)ps.hdc;
102 lpps->fErase=ps.fErase;
103 lpps->rcPaint.top=ps.rcPaint.top;
104 lpps->rcPaint.left=ps.rcPaint.left;
105 lpps->rcPaint.right=ps.rcPaint.right;
106 lpps->rcPaint.bottom=ps.rcPaint.bottom;
107 lpps->fRestore=ps.fRestore;
108 lpps->fIncUpdate=ps.fIncUpdate;
109 return ret;
112 /***********************************************************************
113 * EndPaint (USER32.175)
115 BOOL USER32_EndPaint(DWORD hwnd,struct WIN32_PAINTSTRUCT *lpps)
117 PAINTSTRUCT ps;
118 ps.hdc=(HDC)lpps->hdc;
119 ps.fErase=lpps->fErase;
120 ps.rcPaint.top=lpps->rcPaint.top;
121 ps.rcPaint.left=lpps->rcPaint.left;
122 ps.rcPaint.right=lpps->rcPaint.right;
123 ps.rcPaint.bottom=lpps->rcPaint.bottom;
124 ps.fRestore=lpps->fRestore;
125 ps.fIncUpdate=lpps->fIncUpdate;
126 EndPaint((HWND)hwnd,&ps);
127 return TRUE;
130 /***********************************************************************
131 * DispatchMessageA (USER32.140)
133 LONG USER32_DispatchMessageA(struct WIN32_MSG* lpmsg)
135 MSG msg;
136 LONG ret;
137 MSG32to16(lpmsg,&msg);
138 ret=DispatchMessage(&msg);
139 MSG16to32(&msg,lpmsg);
140 return ret;
143 /***********************************************************************
144 * CreateWindowExA (USER32.82)
146 DWORD USER32_CreateWindowExA(long flags,char* class,char *title,
147 long style,int x,int y,int width,int height,DWORD parent,DWORD menu,
148 DWORD instance,DWORD param)
150 char *classbuf, *titlebuf;
151 /*Have to translate CW_USEDEFAULT */
152 if(x==0x80000000)x=CW_USEDEFAULT;
153 if(width==0x80000000)width=CW_USEDEFAULT;
154 classbuf = alloca( strlen(class)+1 );
155 strcpy( classbuf, class );
156 titlebuf = alloca( strlen(title)+1 );
157 strcpy( titlebuf, title );
158 return (DWORD) CreateWindowEx(flags,MAKE_SEGPTR(classbuf),
159 MAKE_SEGPTR(titlebuf),style,x,y,width,height,
160 (HWND)parent,(HMENU)menu,(HINSTANCE)instance,
161 param);