From: Jacek Caban jacek@codeweavers.com
--- dlls/user32/button.c | 4 ++-- dlls/user32/clipboard.c | 6 +++--- dlls/user32/combo.c | 4 ++-- dlls/user32/dialog.c | 2 +- dlls/user32/edit.c | 10 +++++----- dlls/user32/icontitle.c | 2 +- dlls/user32/mdi.c | 2 +- dlls/user32/msgbox.c | 2 +- dlls/user32/painting.c | 16 ---------------- dlls/user32/static.c | 2 +- dlls/user32/user32.spec | 2 +- dlls/win32u/dce.c | 9 +++++++++ dlls/win32u/menu.c | 6 +++--- dlls/win32u/syscall.c | 1 + dlls/win32u/sysparams.c | 2 +- dlls/win32u/win32u.spec | 2 +- dlls/wow64win/syscall.h | 1 + dlls/wow64win/user.c | 7 +++++++ include/ntuser.h | 1 + 19 files changed, 42 insertions(+), 39 deletions(-)
diff --git a/dlls/user32/button.c b/dlls/user32/button.c index 2c661ffcce0..10a111562a7 100644 --- a/dlls/user32/button.c +++ b/dlls/user32/button.c @@ -141,7 +141,7 @@ static inline void paint_button( HWND hwnd, LONG style, UINT action ) { if (btnPaintFunc[style] && IsWindowVisible(hwnd)) { - HDC hdc = GetDC( hwnd ); + HDC hdc = NtUserGetDC( hwnd ); btnPaintFunc[style]( hwnd, hdc, action ); NtUserReleaseDC( hwnd, hdc ); } @@ -328,7 +328,7 @@ LRESULT ButtonWndProc_common(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, /* Clear an old text here as Windows does */ if (IsWindowVisible(hWnd)) { - HDC hdc = GetDC(hWnd); + HDC hdc = NtUserGetDC(hWnd); HBRUSH hbrush; RECT client, rc; HWND parent = GetParent(hWnd); diff --git a/dlls/user32/clipboard.c b/dlls/user32/clipboard.c index db86b447148..dd33bd7df82 100644 --- a/dlls/user32/clipboard.c +++ b/dlls/user32/clipboard.c @@ -349,7 +349,7 @@ static HANDLE render_synthesized_bitmap( HANDLE data, UINT from ) { BITMAPINFO *bmi; HANDLE ret = 0; - HDC hdc = GetDC( 0 ); + HDC hdc = NtUserGetDC( 0 );
if ((bmi = GlobalLock( data ))) { @@ -369,7 +369,7 @@ static HANDLE render_synthesized_dib( HANDLE data, UINT format, UINT from ) BITMAPINFO *bmi, *src; DWORD src_size, header_size, bits_size; HANDLE ret = 0; - HDC hdc = GetDC( 0 ); + HDC hdc = NtUserGetDC( 0 );
if (from == CF_BITMAP) { @@ -428,7 +428,7 @@ static HANDLE render_synthesized_metafile( HANDLE data ) void *bits; METAFILEPICT *pict; ENHMETAHEADER header; - HDC hdc = GetDC( 0 ); + HDC hdc = NtUserGetDC( 0 );
size = GetWinMetaFileBits( data, 0, NULL, MM_ISOTROPIC, hdc ); if ((bits = HeapAlloc( GetProcessHeap(), 0, size ))) diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index e03a168b237..6afd841f82a 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -162,7 +162,7 @@ static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc )
static INT combo_get_text_height(const HEADCOMBO *combo) { - HDC hdc = GetDC(combo->self); + HDC hdc = NtUserGetDC(combo->self); HFONT prev_font = 0; TEXTMETRICW tm;
@@ -659,7 +659,7 @@ static void CBPaintText( else if(!(lphc->wState & CBF_NOREDRAW) && IsWindowVisible( lphc->self )) { /* paint text field ourselves */ - HDC hdc = hdc_paint ? hdc_paint : GetDC(lphc->self); + HDC hdc = hdc_paint ? hdc_paint : NtUserGetDC(lphc->self); UINT itemState = ODS_COMBOBOXEDIT; HFONT hPrevFont = (lphc->hFont) ? SelectObject(hdc, lphc->hFont) : 0; HBRUSH hPrevBrush, hBkgBrush; diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c index 68c0d804ca7..d13594324e0 100644 --- a/dlls/user32/dialog.c +++ b/dlls/user32/dialog.c @@ -469,7 +469,7 @@ static HWND DIALOG_CreateIndirect( HINSTANCE hInst, LPCVOID dlgTemplate,
if (template.style & DS_SETFONT) { - HDC dc = GetDC(0); + HDC dc = NtUserGetDC(0);
if (template.pointSize == 0x7fff) { diff --git a/dlls/user32/edit.c b/dlls/user32/edit.c index d950cb89889..74411d385e2 100644 --- a/dlls/user32/edit.c +++ b/dlls/user32/edit.c @@ -380,7 +380,7 @@ static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData_linedef(EDITSTATE *es, HD HRESULT hr;
if (!udc) - udc = GetDC(es->hwndSelf); + udc = NtUserGetDC(es->hwndSelf); if (es->font) old_font = SelectObject(udc, es->font);
@@ -421,7 +421,7 @@ static SCRIPT_STRING_ANALYSIS EDIT_UpdateUniscribeData(EDITSTATE *es, HDC dc, IN HDC udc = dc;
if (!udc) - udc = GetDC(es->hwndSelf); + udc = NtUserGetDC(es->hwndSelf); if (es->font) old_font = SelectObject(udc, es->font);
@@ -2885,7 +2885,7 @@ static void EDIT_EM_SetMargins(EDITSTATE *es, INT action,
/* Set the default margins depending on the font */ if (es->font && (left == EC_USEFONTINFO || right == EC_USEFONTINFO)) { - HDC dc = GetDC(es->hwndSelf); + HDC dc = NtUserGetDC(es->hwndSelf); HFONT old_font = SelectObject(dc, es->font); LONG width = GdiGetCharDimensions(dc, &tm, NULL), rc_width; RECT rc; @@ -3798,7 +3798,7 @@ static void EDIT_WM_SetFocus(EDITSTATE *es) /* single line edit updates itself */ if (IsWindowVisible(es->hwndSelf) && !(es->style & ES_MULTILINE)) { - HDC hdc = GetDC(es->hwndSelf); + HDC hdc = NtUserGetDC(es->hwndSelf); EDIT_WM_Paint(es, hdc); NtUserReleaseDC( es->hwndSelf, hdc ); } @@ -3859,7 +3859,7 @@ static void EDIT_WM_SetFont(EDITSTATE *es, HFONT font, BOOL redraw)
es->font = font; EDIT_InvalidateUniscribeData(es); - dc = GetDC(es->hwndSelf); + dc = NtUserGetDC(es->hwndSelf); if (font) old_font = SelectObject(dc, font); GetTextMetricsW(dc, &tm); diff --git a/dlls/user32/icontitle.c b/dlls/user32/icontitle.c index cce3f45250f..047ac5ef1c8 100644 --- a/dlls/user32/icontitle.c +++ b/dlls/user32/icontitle.c @@ -47,7 +47,7 @@ static BOOL ICONTITLE_SetTitlePos( HWND hwnd, HWND owner ) length = lstrlenW( str ); }
- if (!(hDC = GetDC( hwnd ))) return FALSE; + if (!(hDC = NtUserGetDC( hwnd ))) return FALSE;
hPrevFont = SelectObject( hDC, hIconTitleFont );
diff --git a/dlls/user32/mdi.c b/dlls/user32/mdi.c index ce608b3ba9f..f579298544a 100644 --- a/dlls/user32/mdi.c +++ b/dlls/user32/mdi.c @@ -823,7 +823,7 @@ static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild ) { HDC hMemDC; HBITMAP hBitmap, hOldBitmap; - HDC hdc = GetDC(hChild); + HDC hdc = NtUserGetDC(hChild);
if (hdc) { diff --git a/dlls/user32/msgbox.c b/dlls/user32/msgbox.c index 22ddc30efed..4a14a868c73 100644 --- a/dlls/user32/msgbox.c +++ b/dlls/user32/msgbox.c @@ -231,7 +231,7 @@ static void MSGBOX_OnInit(HWND hwnd, LPMSGBOXPARAMSW lpmb) ileft = rect.left; iwidth = rect.right - ileft;
- hdc = GetDC(hwnd); + hdc = NtUserGetDC(hwnd); hPrevFont = SelectObject( hdc, (HFONT)SendMessageW( hwnd, WM_GETFONT, 0, 0 ));
/* Get the number of visible buttons and their size */ diff --git a/dlls/user32/painting.c b/dlls/user32/painting.c index 89451e4e46b..a231dd68a3d 100644 --- a/dlls/user32/painting.c +++ b/dlls/user32/painting.c @@ -22,22 +22,6 @@ #include "user_private.h"
-/*********************************************************************** - * GetDC (USER32.@) - * - * Get a device context. - * - * RETURNS - * Success: Handle to the device context - * Failure: NULL. - */ -HDC WINAPI GetDC( HWND hwnd ) -{ - if (!hwnd) return NtUserGetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW ); - return NtUserGetDCEx( hwnd, 0, DCX_USESTYLE ); -} - - /*********************************************************************** * GetWindowDC (USER32.@) */ diff --git a/dlls/user32/static.c b/dlls/user32/static.c index f5cef12b12a..f3953f7610a 100644 --- a/dlls/user32/static.c +++ b/dlls/user32/static.c @@ -275,7 +275,7 @@ static VOID STATIC_TryPaintFcn(HWND hwnd, LONG full_style) LONG style = full_style & SS_TYPEMASK;
GetClientRect( hwnd, &rc ); - hdc = GetDC( hwnd ); + hdc = NtUserGetDC( hwnd ); hrgn = set_control_clipping( hdc, &rc ); hbrush = STATIC_SendWmCtlColorStatic( hwnd, hdc ); if (staticPaintFunc[style]) diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 88684c29506..464348201cb 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -287,7 +287,7 @@ @ stdcall GetCursorFrameInfo(long long long ptr ptr) @ stdcall GetCursorInfo(ptr) NtUserGetCursorInfo @ stdcall GetCursorPos(ptr) -@ stdcall GetDC(long) +@ stdcall GetDC(long) NtUserGetDC @ stdcall GetDCEx(long long long) NtUserGetDCEx @ stdcall GetDesktopWindow() @ stdcall GetDialogBaseUnits() diff --git a/dlls/win32u/dce.c b/dlls/win32u/dce.c index da5d5078b09..360b985c339 100644 --- a/dlls/win32u/dce.c +++ b/dlls/win32u/dce.c @@ -1029,6 +1029,15 @@ INT WINAPI NtUserReleaseDC( HWND hwnd, HDC hdc ) return release_dc( hwnd, hdc, FALSE ); }
+/*********************************************************************** + * NtUserGetDC (win32u.@) + */ +HDC WINAPI NtUserGetDC( HWND hwnd ) +{ + if (!hwnd) return NtUserGetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW ); + return NtUserGetDCEx( hwnd, 0, DCX_USESTYLE ); +} + /********************************************************************** * NtUserWindowFromDC (win32u.@) */ diff --git a/dlls/win32u/menu.c b/dlls/win32u/menu.c index 98456446e11..a6b7ec38003 100644 --- a/dlls/win32u/menu.c +++ b/dlls/win32u/menu.c @@ -2960,7 +2960,7 @@ static void calc_popup_menu_size( struct menu *menu, UINT max_height ) SetRectEmpty( &menu->items_rect );
if (menu->nItems == 0) return; - hdc = NtUserGetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW ); + hdc = NtUserGetDC( 0 );
NtGdiSelectFont( hdc, get_menu_font( FALSE ));
@@ -3163,7 +3163,7 @@ static void select_item( HWND owner, HMENU hmenu, UINT index, BOOL send_select, if (!menu || !menu->nItems || !menu->hWnd) return;
if (menu->FocusedItem == index) return; - if (menu->wFlags & MF_POPUP) hdc = NtUserGetDCEx( menu->hWnd, 0, DCX_USESTYLE ); + if (menu->wFlags & MF_POPUP) hdc = NtUserGetDC( menu->hWnd ); else hdc = NtUserGetDCEx( menu->hWnd, 0, DCX_CACHE | DCX_WINDOW); if (!top_popup) { @@ -3369,7 +3369,7 @@ static HMENU show_sub_popup( HWND owner, HMENU hmenu, BOOL select_first, UINT fl /* correct item if modified as a reaction to WM_INITMENUPOPUP message */ if (!(item->fState & MF_HILITE)) { - if (menu->wFlags & MF_POPUP) hdc = NtUserGetDCEx( menu->hWnd, 0, DCX_USESTYLE ); + if (menu->wFlags & MF_POPUP) hdc = NtUserGetDC( menu->hWnd ); else hdc = NtUserGetDCEx( menu->hWnd, 0, DCX_CACHE | DCX_WINDOW );
NtGdiSelectFont( hdc, get_menu_font( FALSE )); diff --git a/dlls/win32u/syscall.c b/dlls/win32u/syscall.c index ec6cd859ff6..8c603dbf81e 100644 --- a/dlls/win32u/syscall.c +++ b/dlls/win32u/syscall.c @@ -169,6 +169,7 @@ static void * const syscalls[] = NtUserGetCursor, NtUserGetCursorFrameInfo, NtUserGetCursorInfo, + NtUserGetDC, NtUserGetDCEx, NtUserGetDisplayConfigBufferSizes, NtUserGetDoubleClickTime, diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index d02ff16a2c0..5854e000fea 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -3496,7 +3496,7 @@ DWORD get_dialog_base_units(void) { HDC hdc;
- if ((hdc = NtUserGetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW ))) + if ((hdc = NtUserGetDC( 0 ))) { cx = get_char_dimensions( hdc, NULL, &cy ); NtUserReleaseDC( 0, hdc ); diff --git a/dlls/win32u/win32u.spec b/dlls/win32u/win32u.spec index c9c126ec2f3..43d9b3904d0 100644 --- a/dlls/win32u/win32u.spec +++ b/dlls/win32u/win32u.spec @@ -915,7 +915,7 @@ @ stdcall -syscall NtUserGetCursor() @ stdcall -syscall NtUserGetCursorFrameInfo(long long ptr ptr) @ stdcall -syscall NtUserGetCursorInfo(ptr) -@ stub NtUserGetDC +@ stdcall -syscall NtUserGetDC(long) @ stdcall -syscall NtUserGetDCEx(long long long) @ stub NtUserGetDManipHookInitFunction @ stub NtUserGetDesktopID diff --git a/dlls/wow64win/syscall.h b/dlls/wow64win/syscall.h index e9b63f365dd..288dd593c2f 100644 --- a/dlls/wow64win/syscall.h +++ b/dlls/wow64win/syscall.h @@ -155,6 +155,7 @@ SYSCALL_ENTRY( NtUserGetCursor ) \ SYSCALL_ENTRY( NtUserGetCursorFrameInfo ) \ SYSCALL_ENTRY( NtUserGetCursorInfo ) \ + SYSCALL_ENTRY( NtUserGetDC ) \ SYSCALL_ENTRY( NtUserGetDCEx ) \ SYSCALL_ENTRY( NtUserGetDisplayConfigBufferSizes ) \ SYSCALL_ENTRY( NtUserGetDoubleClickTime ) \ diff --git a/dlls/wow64win/user.c b/dlls/wow64win/user.c index 256add62aab..934612dce8a 100644 --- a/dlls/wow64win/user.c +++ b/dlls/wow64win/user.c @@ -1918,6 +1918,13 @@ NTSTATUS WINAPI wow64_NtUserGetCursorInfo( UINT *args ) return TRUE; }
+NTSTATUS WINAPI wow64_NtUserGetDC( UINT *args ) +{ + HWND hwnd = get_handle( &args ); + + return HandleToUlong( NtUserGetDC( hwnd )); +} + NTSTATUS WINAPI wow64_NtUserGetDCEx( UINT *args ) { HWND hwnd = get_handle( &args ); diff --git a/include/ntuser.h b/include/ntuser.h index 5331b3d7400..c27af731f29 100644 --- a/include/ntuser.h +++ b/include/ntuser.h @@ -733,6 +733,7 @@ HCURSOR WINAPI NtUserGetCursor(void); HCURSOR WINAPI NtUserGetCursorFrameInfo( HCURSOR hCursor, DWORD istep, DWORD *rate_jiffies, DWORD *num_steps ); BOOL WINAPI NtUserGetCursorInfo( CURSORINFO *info ); +HDC WINAPI NtUserGetDC( HWND hwnd ); HDC WINAPI NtUserGetDCEx( HWND hwnd, HRGN clip_rgn, DWORD flags ); LONG WINAPI NtUserGetDisplayConfigBufferSizes( UINT32 flags, UINT32 *num_path_info, UINT32 *num_mode_info );