Commit be6f5ed9 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

win32u: Move NtUserGetDC implementation from user32.

parent 6905b76b
......@@ -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);
......
......@@ -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 )))
......
......@@ -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;
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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 );
......
......@@ -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)
{
......
......@@ -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 */
......
......@@ -23,22 +23,6 @@
/***********************************************************************
* 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.@)
*/
HDC WINAPI GetWindowDC( HWND hwnd )
......
......@@ -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])
......
......@@ -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()
......
......@@ -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.@)
*/
......
......@@ -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 ));
......
......@@ -169,6 +169,7 @@ static void * const syscalls[] =
NtUserGetCursor,
NtUserGetCursorFrameInfo,
NtUserGetCursorInfo,
NtUserGetDC,
NtUserGetDCEx,
NtUserGetDisplayConfigBufferSizes,
NtUserGetDoubleClickTime,
......
......@@ -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 );
......
......@@ -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
......
......@@ -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 ) \
......
......@@ -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 );
......
......@@ -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 );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment