4 * Copyright 1995 Martin von Loewis
7 /* This file contains only wrappers to existing Wine functions or trivial
8 stubs. 'Real' implementations go into context specific files */
17 #include "stackframe.h"
21 #include "resource32.h"
28 /***********************************************************************
29 * GetMessageA (USER32.269)
31 BOOL
USER32_GetMessageA(MSG32
* lpmsg
,DWORD hwnd
,DWORD min
,DWORD max
)
35 ret
=GetMessage(MAKE_SEGPTR(&msg
),(HWND
)hwnd
,min
,max
);
36 STRUCT32_MSG16to32(&msg
,lpmsg
);
40 /***********************************************************************
41 * BeginPaint (USER32.9)
43 HDC
USER32_BeginPaint(DWORD hwnd
,PAINTSTRUCT32
*lpps
)
47 ret
=BeginPaint((HWND
)hwnd
,&ps
);
48 lpps
->hdc
=(DWORD
)ps
.hdc
;
49 lpps
->fErase
=ps
.fErase
;
50 lpps
->rcPaint
.top
=ps
.rcPaint
.top
;
51 lpps
->rcPaint
.left
=ps
.rcPaint
.left
;
52 lpps
->rcPaint
.right
=ps
.rcPaint
.right
;
53 lpps
->rcPaint
.bottom
=ps
.rcPaint
.bottom
;
54 lpps
->fRestore
=ps
.fRestore
;
55 lpps
->fIncUpdate
=ps
.fIncUpdate
;
59 /***********************************************************************
60 * EndPaint (USER32.175)
62 BOOL
USER32_EndPaint(DWORD hwnd
,PAINTSTRUCT32
*lpps
)
65 ps
.hdc
=(HDC
)lpps
->hdc
;
66 ps
.fErase
=lpps
->fErase
;
67 ps
.rcPaint
.top
=lpps
->rcPaint
.top
;
68 ps
.rcPaint
.left
=lpps
->rcPaint
.left
;
69 ps
.rcPaint
.right
=lpps
->rcPaint
.right
;
70 ps
.rcPaint
.bottom
=lpps
->rcPaint
.bottom
;
71 ps
.fRestore
=lpps
->fRestore
;
72 ps
.fIncUpdate
=lpps
->fIncUpdate
;
73 EndPaint((HWND
)hwnd
,&ps
);
77 /***********************************************************************
78 * DispatchMessageA (USER32.140)
80 LONG
USER32_DispatchMessageA(MSG32
* lpmsg
)
84 STRUCT32_MSG32to16(lpmsg
,&msg
);
85 ret
=DispatchMessage(&msg
);
86 STRUCT32_MSG16to32(&msg
,lpmsg
);
90 /***********************************************************************
91 * TranslateMessage (USER32.555)
93 BOOL
USER32_TranslateMessage(MSG32
* lpmsg
)
96 STRUCT32_MSG32to16(lpmsg
,&msg
);
97 return TranslateMessage(&msg
);
100 /***********************************************************************
101 * CreateWindowEx32A (USER32.82)
103 HWND32
CreateWindowEx32A( DWORD flags
, LPCSTR
class, LPCSTR title
,
104 DWORD style
, INT32 x
, INT32 y
, INT32 width
,
105 INT32 height
, HWND32 parent
, HMENU32 menu
,
106 HINSTANCE32 instance
, LPVOID param
)
109 HANDLE classh
=0, titleh
=0;
110 SEGPTR classsegp
=0, titlesegp
=0;
111 char *classbuf
, *titlebuf
;
114 /*Have to translate CW_USEDEFAULT */
115 if(x
==CW_USEDEFAULT32
)x
=CW_USEDEFAULT16
;
116 if(y
==CW_USEDEFAULT32
)y
=CW_USEDEFAULT16
;
117 if(width
==CW_USEDEFAULT32
)width
=CW_USEDEFAULT16
;
118 if(height
==CW_USEDEFAULT32
)height
=CW_USEDEFAULT16
;
120 /* FIXME: There has to be a better way of doing this - but neither
121 malloc nor alloca will work */
122 usec
= HIWORD(class);
123 uset
= HIWORD(title
);
126 classh
= GlobalAlloc16(0, strlen(class)+1);
127 classsegp
= WIN16_GlobalLock16(classh
);
128 classbuf
= PTR_SEG_TO_LIN(classsegp
);
129 strcpy( classbuf
, class );
132 titleh
= GlobalAlloc16(0, strlen(title
)+1);
133 titlesegp
= WIN16_GlobalLock16(titleh
);
134 titlebuf
= PTR_SEG_TO_LIN(titlesegp
);
135 strcpy( titlebuf
, title
);
138 retval
= (HWND32
)CreateWindowEx16(flags
,(usec
? classsegp
: (SEGPTR
)class),
139 (uset
? titlesegp
: (SEGPTR
)title
),style
,x
,y
,width
,height
,
140 (HWND
)parent
,(HMENU
)menu
,(HINSTANCE
)instance
,
142 if(usec
)GlobalFree16(classh
);
143 if(uset
)GlobalFree16(titleh
);
147 HWND32
CreateWindowEx32W( DWORD flags
, LPCWSTR
class, LPCWSTR title
,
148 DWORD style
, INT32 x
, INT32 y
, INT32 width
,
149 INT32 height
, HWND32 parent
, HMENU32 menu
,
150 HINSTANCE32 instance
, LPVOID param
)
157 c
= usec
? STRING32_DupUniToAnsi(class) : (LPSTR
)class;
158 t
= uset
? STRING32_DupUniToAnsi(title
) : (LPSTR
)title
;
159 hwnd
=CreateWindowEx32A(flags
,c
,t
,style
,x
,y
,width
,height
,parent
,menu
,
166 /***********************************************************************
167 * InvalidateRect (USER32.327)
169 BOOL
USER32_InvalidateRect(HWND hWnd
,const RECT32
*lpRect
,BOOL bErase
)
174 InvalidateRect(hWnd
, (RECT
*)NULL
, bErase
);
176 STRUCT32_RECT32to16(lpRect
,&r
);
177 InvalidateRect(hWnd
,&r
,bErase
);
179 /* FIXME: Return meaningful value */
183 /***********************************************************************
184 * DrawTextA (USER32.163)
186 int USER32_DrawTextA(HDC hdc
,LPCSTR lpStr
,int count
,RECT32
* r32
,UINT uFormat
)
189 STRUCT32_RECT32to16(r32
,&r
);
190 return DrawText(hdc
,lpStr
,count
,&r
,uFormat
);
193 /***********************************************************************
194 * GetClientRect (USER32.219)
196 BOOL
USER32_GetClientRect(HWND hwnd
,RECT32
*r32
)
199 GetClientRect(hwnd
,&r
);
200 STRUCT32_RECT16to32(&r
,r32
);
201 /* FIXME: return value */
205 UINT
USER32_SetTimer(HWND hwnd
, UINT id
, UINT timeout
, void *proc
)
208 dprintf_win32(stddeb
, "USER32_SetTimer: %d %d %d %08lx\n", hwnd
, id
, timeout
,
210 return SetTimer( hwnd
, id
, timeout
, MAKE_SEGPTR(proc
));
213 /* WARNING: It has not been verified that the signature or semantics
214 of the corresponding NT function is the same */
216 HWND
USER32_CreateDialogIndirectParamAorW(HINSTANCE hInst
,LPVOID templ
,
217 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
,int A
)
219 DLGTEMPLATE32
*dlgTempl
=templ
;
220 DLGITEMTEMPLATE32
*dlgitem
;
233 WORD xUnit
= xBaseUnit
;
234 WORD yUnit
= yBaseUnit
;
239 HWND hwndDefButton
=0;
242 /* parse the dialog template header*/
243 exStyle
= dlgTempl
->dwExtendedStyle
;
244 ptr
= (WORD
*)(dlgTempl
+1);
246 case 0: MenuName
=0;ptr
++;break;
247 case 0xFFFF: MenuName
=*(ptr
+1);ptr
+=2;break;
248 default: MenuName
= (DWORD
)ptr
;
249 ptr
+= STRING32_lstrlenW(ptr
)+1;
252 case 0: ClassName
= DIALOG_CLASS_ATOM
;ptr
++;break;
253 case 0xFFFF: ClassName
= *(ptr
+1);ptr
+=2;break;
254 default: ClassName
= (DWORD
)ptr
;
255 ptr
+= STRING32_lstrlenW(ptr
)+1;
257 szCaption
=(DWORD
)ptr
;
258 ptr
+=STRING32_lstrlenW(ptr
)+1;
259 if(dlgTempl
->style
& DS_SETFONT
)
263 szFontName
= (DWORD
)ptr
;
264 ptr
+=STRING32_lstrlenW(ptr
)+1;
267 if(MenuName
) hMenu
=WIN32_LoadMenuW(hInst
,(LPWSTR
)MenuName
);
268 if(dlgTempl
->style
& DS_SETFONT
)
270 fprintf(stderr
,"Win32: dialog fonts not supported yet\n");
273 /* Create dialog main window */
274 rect
.left
= rect
.top
= 0;
275 rect
.right
= dlgTempl
->cx
* xUnit
/ 4;
276 rect
.bottom
= dlgTempl
->cy
* yUnit
/ 8;
278 /* FIXME: proper modalframe handling ??*/
279 if (dlgTempl
->style
& DS_MODALFRAME
) exStyle
|= WS_EX_DLGMODALFRAME
;
281 AdjustWindowRectEx( &rect
, dlgTempl
->style
,
282 hMenu
? TRUE
: FALSE
, exStyle
);
283 rect
.right
-= rect
.left
;
284 rect
.bottom
-= rect
.top
;
286 if(dlgTempl
->x
== CW_USEDEFAULT16
)
287 rect
.left
= rect
.top
= CW_USEDEFAULT16
;
289 rect
.left
+= dlgTempl
->x
* xUnit
/ 4;
290 rect
.top
+= dlgTempl
->y
* yUnit
/ 8;
291 if (!(dlgTempl
->style
& DS_ABSALIGN
))
292 ClientToScreen(hWndParent
, (POINT
*)&rect
);
295 /* FIXME: Here is the place to consider A */
296 hwnd
= CreateWindowEx32W(exStyle
, (LPWSTR
)ClassName
, (LPWSTR
)szCaption
,
297 dlgTempl
->style
& ~WS_VISIBLE
,
298 rect
.left
, rect
.top
, rect
.right
, rect
.bottom
,
299 hWndParent
, hMenu
, hInst
, 0);
303 if(hFont
)DeleteObject(hFont
);
304 if(hMenu
)DeleteObject(hMenu
);
308 wndPtr
= WIN_FindWndPtr(hwnd
);
310 /* FIXME: should purge junk from system menu, but windows/dialog.c
311 says this does not belong here */
313 /* Create control windows */
314 dprintf_dialog(stddeb
, " BEGIN\n" );
315 dlgInfo
= (DIALOGINFO
*)wndPtr
->wExtra
;
316 dlgInfo
->msgResult
= 0; /* This is used to store the default button id */
317 dlgInfo
->hDialogHeap
= 0;
319 for (i
= 0; i
< dlgTempl
->noOfItems
; i
++)
323 fprintf(stddeb
,"DWORD aligning\n");
326 dlgitem
= (DLGITEMTEMPLATE32
*)ptr
;
327 ptr
= (WORD
*)(dlgitem
+1);
329 /* FIXME: ignore HIBYTE? */
333 ClassId
= (DWORD
)ptr
;
334 ptr
+= STRING32_lstrlenW(ptr
)+1;
341 ptr
+= STRING32_lstrlenW(ptr
)+1;
345 switch(LOWORD(ClassId
))
347 case 0x80: STRING32_AnsiToUni(buffer
,"BUTTON" ); break;
348 case 0x81: STRING32_AnsiToUni( buffer
, "EDIT" ); break;
349 case 0x82: STRING32_AnsiToUni( buffer
, "STATIC" ); break;
350 case 0x83: STRING32_AnsiToUni( buffer
, "LISTBOX" ); break;
351 case 0x84: STRING32_AnsiToUni( buffer
, "SCROLLBAR" ); break;
352 case 0x85: STRING32_AnsiToUni( buffer
, "COMBOBOX" ); break;
353 default: buffer
[0] = '\0'; break;
355 ClassId
= (DWORD
)buffer
;
357 /*FIXME: debugging output*/
358 /*FIXME: local edit ?*/
359 exStyle
= dlgitem
->dwExtendedStyle
|WS_EX_NOPARENTNOTIFY
;
362 fprintf(stderr
,"having data\n");
365 hwndCtrl
= CreateWindowEx32W(WS_EX_NOPARENTNOTIFY
,
366 (LPWSTR
)ClassId
, (LPWSTR
)Text
,
367 dlgitem
->style
| WS_CHILD
,
368 dlgitem
->x
* xUnit
/ 4,
369 dlgitem
->y
* yUnit
/ 8,
370 dlgitem
->cx
* xUnit
/ 4,
371 dlgitem
->cy
* yUnit
/ 8,
372 hwnd
, (HMENU
)((DWORD
)dlgitem
->id
),
374 SetWindowPos( hwndCtrl
, HWND_BOTTOM
, 0, 0, 0, 0,
375 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
376 /* Send initialisation messages to the control */
377 if (hFont
) SendMessage( hwndCtrl
, WM_SETFONT
, (WPARAM
)hFont
, 0 );
378 if (SendMessage( hwndCtrl
, WM_GETDLGCODE
, 0, 0 ) & DLGC_DEFPUSHBUTTON
)
380 /* If there's already a default push-button, set it back */
381 /* to normal and use this one instead. */
383 SendMessage( hwndDefButton
, BM_SETSTYLE
, BS_PUSHBUTTON
, FALSE
);
384 hwndDefButton
= hwndCtrl
;
385 dlgInfo
->msgResult
= GetWindowWord( hwndCtrl
, GWW_ID
);
388 dprintf_dialog(stddeb
, " END\n" );
390 /* Initialise dialog extra data */
391 ALIAS_RegisterAlias(0,0,lpDialogFunc
);
392 dlgInfo
->dlgProc
= lpDialogFunc
;
393 dlgInfo
->hUserFont
= hFont
;
394 dlgInfo
->hMenu
= hMenu
;
395 dlgInfo
->xBaseUnit
= xUnit
;
396 dlgInfo
->yBaseUnit
= yUnit
;
397 dlgInfo
->hwndFocus
= DIALOG_GetFirstTabItem( hwnd
);
399 /* Send initialisation messages and set focus */
400 if (dlgInfo
->hUserFont
)
401 SendMessage( hwnd
, WM_SETFONT
, (WPARAM
)dlgInfo
->hUserFont
, 0 );
402 if (SendMessage( hwnd
, WM_INITDIALOG
, (WPARAM
)dlgInfo
->hwndFocus
, dwInitParam
))
403 SetFocus( dlgInfo
->hwndFocus
);
404 if (dlgTempl
->style
& WS_VISIBLE
) ShowWindow(hwnd
, SW_SHOW
);
408 HWND
USER32_CreateDialogIndirectParamW(HINSTANCE hInst
,LPVOID dlgTempl
,
409 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
411 return USER32_CreateDialogIndirectParamAorW(hInst
,dlgTempl
,hWndParent
,
412 lpDialogFunc
,dwInitParam
,0);
415 HWND
USER32_CreateDialogIndirectParamA(HINSTANCE hInst
,LPVOID dlgTempl
,
416 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
418 return USER32_CreateDialogIndirectParamAorW(hInst
,dlgTempl
,hWndParent
,
419 lpDialogFunc
,dwInitParam
,1);
422 HWND
USER32_CreateDialogParamW(HINSTANCE hInst
,LPCWSTR lpszName
,
423 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
426 hrsrc
=FindResource32(hInst
,lpszName
,(LPWSTR
)RT_DIALOG
);
428 return USER32_CreateDialogIndirectParamW(hInst
,
429 LoadResource32(hInst
, hrsrc
),hWndParent
,lpDialogFunc
,dwInitParam
);
432 HWND
USER32_CreateDialogParamA(HINSTANCE hInst
,LPCSTR lpszName
,
433 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
436 if(!HIWORD(lpszName
))
437 res
= USER32_CreateDialogParamW(hInst
,(LPCWSTR
)lpszName
,hWndParent
,
438 lpDialogFunc
,dwInitParam
);
440 LPWSTR uni
=STRING32_DupAnsiToUni(lpszName
);
441 res
=USER32_CreateDialogParamW(hInst
,uni
,hWndParent
,
442 lpDialogFunc
,dwInitParam
);
447 int USER32_DialogBoxIndirectParamW(HINSTANCE hInstance
,LPVOID dlgTempl
,
448 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
451 hwnd
= USER32_CreateDialogIndirectParamW(hInstance
,dlgTempl
,
452 hWndParent
,lpDialogFunc
,dwInitParam
);
453 if(hwnd
)return DIALOG_DoDialogBox(hwnd
,hWndParent
);
457 int USER32_DialogBoxIndirectParamA(HINSTANCE hInstance
,LPVOID dlgTempl
,
458 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
461 hwnd
= USER32_CreateDialogIndirectParamA(hInstance
,dlgTempl
,
462 hWndParent
,lpDialogFunc
,dwInitParam
);
463 if(hwnd
)return DIALOG_DoDialogBox(hwnd
,hWndParent
);
467 int USER32_DialogBoxParamW(HINSTANCE hInstance
,LPCWSTR lpszName
,
468 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
471 hwnd
= USER32_CreateDialogParamW(hInstance
,lpszName
,
472 hWndParent
,lpDialogFunc
,dwInitParam
);
473 if(hwnd
)return DIALOG_DoDialogBox(hwnd
,hWndParent
);
477 int USER32_DialogBoxParamA(HINSTANCE hInstance
,LPCSTR lpszName
,
478 HWND hWndParent
,DLGPROC lpDialogFunc
,LPARAM dwInitParam
)
481 hwnd
= USER32_CreateDialogParamA(hInstance
,lpszName
,
482 hWndParent
,lpDialogFunc
,dwInitParam
);
483 if(hwnd
)return DIALOG_DoDialogBox(hwnd
,hWndParent
);
487 int USER32_wsprintfA( int *args
)
489 return vsprintf( (char *)args
[0], (char *)args
[1], (va_list)&args
[2] );