当前位置: 首页>>代码示例>>C++>>正文


C++ GetUpdateRect函数代码示例

本文整理汇总了C++中GetUpdateRect函数的典型用法代码示例。如果您正苦于以下问题:C++ GetUpdateRect函数的具体用法?C++ GetUpdateRect怎么用?C++ GetUpdateRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetUpdateRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_redraw

/*
 * Tests if a progress bar repaints itself immediately when it receives
 * some specific messages.
 */
static void test_redraw(void)
{
    RECT client_rect;
    LRESULT ret;

    SendMessageA(hProgressWnd, PBM_SETRANGE, 0, MAKELPARAM(0, 100));
    SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
    SendMessageA(hProgressWnd, PBM_SETSTEP, 20, 0);
    update_window(hProgressWnd);

    /* PBM_SETPOS */
    ok(SendMessageA(hProgressWnd, PBM_SETPOS, 50, 0) == 10, "PBM_SETPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");
    
    /* PBM_DELTAPOS */
    ok(SendMessageA(hProgressWnd, PBM_DELTAPOS, 15, 0) == 50, "PBM_DELTAPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_DELTAPOS: The progress bar should be redrawn immediately\n");
    
    /* PBM_SETPOS */
    ok(SendMessageA(hProgressWnd, PBM_SETPOS, 80, 0) == 65, "PBM_SETPOS must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_SETPOS: The progress bar should be redrawn immediately\n");
    
    /* PBM_STEPIT */
    ok(SendMessageA(hProgressWnd, PBM_STEPIT, 0, 0) == 80, "PBM_STEPIT must return the previous position\n");
    ok(!GetUpdateRect(hProgressWnd, NULL, FALSE), "PBM_STEPIT: The progress bar should be redrawn immediately\n");
    ret = SendMessageA(hProgressWnd, PBM_GETPOS, 0, 0);
    if (ret == 0)
        win_skip("PBM_GETPOS needs comctl32 > 4.70\n");
    else
        ok(ret == 100, "PBM_GETPOS returned a wrong position : %d\n", (UINT)ret);
    
    /* PBM_SETRANGE and PBM_SETRANGE32:
    Usually the progress bar doesn't repaint itself immediately. If the
    position is not in the new range, it does.
    Don't test this, it may change in future Windows versions. */

    SendMessageA(hProgressWnd, PBM_SETPOS, 0, 0);
    update_window(hProgressWnd);

    /* increase to 10 - no background erase required */
    erased = FALSE;
    SetRectEmpty(&last_paint_rect);
    SendMessageA(hProgressWnd, PBM_SETPOS, 10, 0);
    GetClientRect(hProgressWnd, &client_rect);
    ok(EqualRect(&last_paint_rect, &client_rect), "last_paint_rect was %s instead of %s\n",
       wine_dbgstr_rect(&last_paint_rect), wine_dbgstr_rect(&client_rect));
    update_window(hProgressWnd);
    ok(!erased, "Progress bar shouldn't have erased the background\n");

    /* decrease to 0 - background erase will be required */
    erased = FALSE;
    SetRectEmpty(&last_paint_rect);
    SendMessageA(hProgressWnd, PBM_SETPOS, 0, 0);
    GetClientRect(hProgressWnd, &client_rect);
    ok(EqualRect(&last_paint_rect, &client_rect), "last_paint_rect was %s instead of %s\n",
       wine_dbgstr_rect(&last_paint_rect), wine_dbgstr_rect(&client_rect));
    update_window(hProgressWnd);
    ok(erased, "Progress bar should have erased the background\n");
}
开发者ID:AndreRH,项目名称:wine,代码行数:63,代码来源:progress.c

示例2: GetUpdateRect

void CTitleStatic::OnPaint()
{
   PAINTSTRUCT paintStruct;

   DWORD dwRes = GetUpdateRect(NULL);
   if (dwRes == 0)
      return;
   CDC *pDC = BeginPaint(&paintStruct);

   CRect rect;
   GetClientRect(&rect);
   /*
   CBrush brush(::GetSysColor(COLOR_ACTIVECAPTION));
   pDC->FillRect(&rect, &brush);
   CString csText;
   GetWindowText(csText);
   int nOldMode = pDC->SetBkMode(TRANSPARENT);
   pDC->DrawText(csText, &rect, DT_SINGLELINE | DT_VCENTER);
   */
   
   //::DrawCaption(GetSafeHwnd(), pDC->GetSafeHdc(), &rect, DC_ACTIVE | DC_SMALLCAP | DC_TEXT | DC_GRADIENT);
   //::DrawCaption(GetSafeHwnd(), pDC->GetSafeHdc(), &rect, DC_ACTIVE | DC_SMALLCAP | DC_TEXT);
   ::DrawCaption(GetSafeHwnd(), pDC->GetSafeHdc(), &rect, DC_SMALLCAP | DC_TEXT);

   EndPaint(&paintStruct);
}
开发者ID:identity0815,项目名称:os45,代码行数:26,代码来源:TitleStatic.cpp

示例3: GetClientRect

void CNSToolbar2::OnPaint(void)
{
    CRect rcClient, updateRect, buttonRect, intersectRect;

    GetClientRect(&rcClient);
    GetUpdateRect(&updateRect);

    CPaintDC dcPaint(this);

    // Use our background color
    ::FillRect(dcPaint.m_hDC, &rcClient, sysInfo.m_hbrBtnFace);

    for (int i = 0; i < m_nNumButtons; i++)
    {
        m_pButtonArray[i]->GetClientRect(&buttonRect);

        m_pButtonArray[i]->MapWindowPoints(this, &buttonRect);

        if(intersectRect.IntersectRect(updateRect, buttonRect))
        {
            MapWindowPoints(m_pButtonArray[i], &intersectRect);
            m_pButtonArray[i]->RedrawWindow(&intersectRect);
        }

    }

}
开发者ID:vicamo,项目名称:b2g_mozilla-central,代码行数:27,代码来源:toolbar2.cpp

示例4: on_WM_PAINT

static LPARAM
on_WM_PAINT(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
{
	HDC dc;
	PAINTSTRUCT ps;

	// WM_PAINT message
	// http://msdn.microsoft.com/en-us/library/windows/desktop/dd145213(v=vs.85).aspx
	// > A window may receive internal paint messages as a result
	// > of calling RedrawWindow with the RDW_INTERNALPAINT flag
	// > set. In this case, the window may not have an update
	// > region. An application should call the GetUpdateRect
	// > function to determine whether the window has an
	// > update region. If GetUpdateRect returns zero, the
	// > application should not call the BeginPaint and EndPaint
	// > functions.
	if (GetUpdateRect(hwnd, NULL, FALSE) == 0) {
		return 0;
	}

	dc = BeginPaint(hwnd, &ps);
	TextOut(dc, 0, 0, _T("hello"), 5);
	EndPaint(hwnd, &ps);

	return 0;
}
开发者ID:vbarbarosh,项目名称:w339_winapi_env,代码行数:26,代码来源:desktop-app.c

示例5: OnPaint

void gfxPreviewWind::OnPaint() 
{
	if (!mlEdit.isMaterialListValid())
		return;
	
	if (m_matType == TS::Material::MatPalette || m_matType == TS::Material::MatTexture ||
		m_matType == TS::Material::MatNull) {
		RECT rect;
		if (GetUpdateRect(&rect)) {
			PAINTSTRUCT ps;
			BeginPaint(&ps);
			Refresh();
			EndPaint(&ps);
		} else {
			Refresh();
		}
	} else {
		// The material is an RGB, so we'll call on windows to display it, dithering in 256
		// color mode, or displaying real color in true-color modes...
		//
		CPaintDC dc(this); // device context for painting
		
		UInt8 red   = m_pMaterial->fParams.fRGB.fRed;
		UInt8 green = m_pMaterial->fParams.fRGB.fGreen;
		UInt8 blue  = m_pMaterial->fParams.fRGB.fBlue;
		
		COLORREF m_color = RGB(red, green, blue);

		CBrush brRGB( m_color );
		dc.FillRect( &dc.m_ps.rcPaint, &brRGB );
	}
}
开发者ID:AltimorTASDK,项目名称:TribesRebirth,代码行数:32,代码来源:gfxPreviewWind.cpp

示例6: getDirtyRects

static void getDirtyRects(HWND window, Vector<CGRect>& outRects)
{
    ASSERT_ARG(outRects, outRects.isEmpty());

    RECT clientRect;
    if (!GetClientRect(window, &clientRect))
        return;

    auto region = adoptGDIObject(::CreateRectRgn(0, 0, 0, 0));
    int regionType = GetUpdateRgn(window, region.get(), false);
    if (regionType != COMPLEXREGION) {
        RECT dirtyRect;
        if (GetUpdateRect(window, &dirtyRect, false))
            outRects.append(winRectToCGRect(dirtyRect, clientRect));
        return;
    }

    DWORD dataSize = ::GetRegionData(region.get(), 0, 0);
    auto regionDataBuffer = std::make_unique<unsigned char[]>(dataSize);
    RGNDATA* regionData = reinterpret_cast<RGNDATA*>(regionDataBuffer.get());
    if (!::GetRegionData(region.get(), dataSize, regionData))
        return;

    outRects.resize(regionData->rdh.nCount);

    RECT* rect = reinterpret_cast<RECT*>(regionData->Buffer);
    for (size_t i = 0; i < outRects.size(); ++i, ++rect)
        outRects[i] = winRectToCGRect(*rect, clientRect);
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:29,代码来源:CACFLayerTreeHost.cpp

示例7: OfficePanePaint

/******************************************************************************
* OfficePanePaint  *
*------------------*
*   Description:
*       Do the paint on the office pane.
*
******************************************************************************/
void OfficePanePaint( HWND hWnd )
{
    if ( GetUpdateRect( hWnd, NULL, TRUE ) )
    {
        PAINTSTRUCT ps;
        HDC hDC;
        TCHAR tBuf[MAX_LOADSTRING];
        BeginPaint( hWnd, &ps );
        hDC = ps.hdc;
        HFONT hOldFont = (HFONT) SelectObject( hDC, s_hDrawingFont );
        COLORREF sOldColor = SetTextColor( hDC, RGB( 255, 255, 255 ) );
        SetBkMode(hDC, TRANSPARENT);
        
        RECT rc;
        RECT clientRC;
        GetClientRect( hWnd, &clientRC );
        
        LoadString( g_hInst, IDS_OFFICE, tBuf, MAX_LOADSTRING );
        rc.left = 0;
        rc.right = 450;
        int iHeight = DrawText( hDC, tBuf, -1, &rc, DT_CALCRECT | DT_WORDBREAK );
        int iWidth = rc.right - rc.left;
        rc.left = (clientRC.right - iWidth) / 2;
        rc.right = rc.left + iWidth;
        rc.top = 25;
        rc.bottom = rc.top + iHeight + 1;
        DrawText( hDC, tBuf, -1, &rc, DT_WORDBREAK );
        
        SetTextColor( hDC, sOldColor );
        SelectObject( hDC, hOldFont );
        EndPaint( hWnd, &ps );
    }        
}
开发者ID:Ippei-Murofushi,项目名称:WindowsSDK7-Samples,代码行数:40,代码来源:display.cpp

示例8: SysMsgHook

LRESULT CALLBACK SysMsgHook(int nCode, WPARAM wParam, LPARAM lParam)
{
	MSG *cw = (MSG*)lParam;

	switch (cw->message) {
		case WM_ERASEBKGND:
		case WM_PAINT:
			if (cw->hwnd == desktopWnd) {
				RECT rt;

				if (!GetUpdateRect(cw->hwnd, &rt, false)) {
					::GetClientRect(cw->hwnd, &rt);
				}

				WaitForSingleObject(hSem, INFINITE);
				UnionRect(&dskWndPaintedRect, &dskWndPaintedRect, &rt);
				ReleaseSemaphore(hSem, 1, NULL);

				dskWndPainted = TRUE;
			}
			break;
		default:
			break;
	}

	return CallNextHookEx(hWndMsgHook, nCode, wParam, lParam);
}
开发者ID:AnotherFoxGuy,项目名称:winpenguins,代码行数:27,代码来源:Winmon.cpp

示例9: GetUpdateRect

BOOL CColorStatic::OnEraseBkgnd(CDC* pDC)
{
	CRect rcClient;
	GetUpdateRect(&rcClient);			  
	pDC->FillSolidRect(rcClient, RGB(255,255,255));	
	return FALSE;	
}
开发者ID:idaohang,项目名称:GNSS_Viewer_V2,代码行数:7,代码来源:ColorStatic.cpp

示例10: Paint

void PlayerPanel::Paint()
{
  if (Handle != NULL && GetUpdateRect(Handle, NULL, 0) != 0)
  {
    PAINTSTRUCT PS;
    HDC DC = BeginPaint(Handle, &PS);
    if (DC != NULL)
    {
      /* Create a buffer DC to draw on */
      HDC Buffer = CreateCompatibleDC(DC);
      HBITMAP Bitmap = CreateCompatibleBitmap(DC,Width,Height);
      SelectObject(Buffer, Bitmap);
      /* Paint the background */
      HBRUSH OldBrush = (HBRUSH)SelectObject(Buffer,CreateSolidBrush(GetSysColor(COLOR_BTNFACE)));
      HPEN OldPen = (HPEN)SelectObject(Buffer,CreatePen(PS_SOLID,1,GetSysColor(COLOR_BTNFACE)));
      Rectangle(Buffer,0,0,Width,Height);
      DeleteObject(SelectObject(Buffer,OldPen));
      DeleteObject(SelectObject(Buffer,OldBrush));
      /* Draw the chess piece */
      DrawChessPiece(Buffer,0,2);
      /* Draw the player's information */
      DrawPlayerInformation(Buffer,Height-2,1,Width-Height,Height-2);
      /* Draw the buffer into the destination DC */
      BitBlt(DC,0,0,Width,Height,Buffer,0,0,SRCCOPY);
      /* Cleanup */
      DeleteDC(Buffer);
      DeleteObject(Bitmap);
    }
    EndPaint(Handle, &PS);
  }
}
开发者ID:Malbeth81,项目名称:alphachess,代码行数:31,代码来源:playerpanel.cpp

示例11: DoOnPaint

void CDeviceView::DoOnPaint(HDC hDC)
{
	// Paint only if we have an update region.
	if (GetUpdateRect(m_hWnd, NULL, FALSE) || m_bForcePaint)
		OnPaint(hDC);
	m_bForcePaint = FALSE;
}
开发者ID:grakidov,项目名称:Render3D,代码行数:7,代码来源:cdeviceview.cpp

示例12: OnPaint

//-----------------------------------------------------------------------------
// Purpose: Renders the title window. A special font is used if the mouse is
//			over the title window or if the window's menu is open.
//-----------------------------------------------------------------------------
void CTitleWnd::OnPaint(void)
{
	if (m_szTitle[0] != '\0')
	{
		if (GetUpdateRect(NULL, TRUE))
		{
			CPaintDC dc(this);
			CFont *pFontOld;

			if ((m_bMouseOver) || (m_bMenuOpen))
			{
				pFontOld = dc.SelectObject(&m_FontActive);
				dc.SetTextColor(RGB(255, 255, 255));
			}
			else
			{
				pFontOld = dc.SelectObject(&m_FontNormal);
				dc.SetTextColor(RGB(200, 200, 200));
			}

			dc.SetBkMode(TRANSPARENT);
			dc.TextOut(0, 0, m_szTitle, strlen(m_szTitle));
			dc.SelectObject(pFontOld);
		}
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:30,代码来源:titlewnd.cpp

示例13: getDirtyRects

static void getDirtyRects(HWND window, Vector<CGRect>& outRects)
{
    ASSERT_ARG(outRects, outRects.isEmpty());

    RECT clientRect;
    if (!GetClientRect(window, &clientRect))
        return;

    HRGN region = CreateRectRgn(0, 0, 0, 0);
    int regionType = GetUpdateRgn(window, region, false);
    if (regionType != COMPLEXREGION) {
        RECT dirtyRect;
        if (GetUpdateRect(window, &dirtyRect, false))
            outRects.append(winRectToCGRect(dirtyRect, clientRect));
        return;
    }

    DWORD dataSize = GetRegionData(region, 0, 0);
    OwnArrayPtr<unsigned char> regionDataBuffer(new unsigned char[dataSize]);
    RGNDATA* regionData = reinterpret_cast<RGNDATA*>(regionDataBuffer.get());
    if (!GetRegionData(region, dataSize, regionData))
        return;

    outRects.resize(regionData->rdh.nCount);

    RECT* rect = reinterpret_cast<RECT*>(regionData->Buffer);
    for (size_t i = 0; i < outRects.size(); ++i, ++rect)
        outRects[i] = winRectToCGRect(*rect, clientRect);

    DeleteObject(region);
}
开发者ID:flwh,项目名称:Alcatel_OT_985_kernel,代码行数:31,代码来源:WKCACFLayerRenderer.cpp

示例14: CounterPanePaint

/******************************************************************************
* CounterPanePaint *
*------------------*
*   Description:
*       Do the paint on the counter pane.
*
******************************************************************************/
void CounterPanePaint( HWND hWnd, LPCTSTR szCounterDisplay )
{
    if ( GetUpdateRect( hWnd, NULL, TRUE ) )
    {
        PAINTSTRUCT ps;
        HDC hDC;
        BeginPaint( hWnd, &ps );
        hDC = ps.hdc;
        HFONT hOldFont = (HFONT) SelectObject( hDC, s_hDrawingFont );
        COLORREF sOldColor = SetTextColor( hDC, RGB( 255, 255, 255 ) );
        SetBkMode(hDC, TRANSPARENT);
        
        RECT rc;
        RECT clientRC;
        GetClientRect( hWnd, &clientRC );
        
        rc.left = 0;
        rc.right = 450;
        int iHeight = DrawText( hDC, szCounterDisplay, -1, &rc, DT_CALCRECT | DT_WORDBREAK );
        int iWidth = rc.right - rc.left;
        rc.left = (clientRC.right - iWidth) / 2;
        rc.right = rc.left + iWidth;
        rc.top = 100;
        rc.bottom = rc.top + iHeight + 1;
        DrawText( hDC, szCounterDisplay, -1, &rc, DT_WORDBREAK );
        
        SetTextColor( hDC, sOldColor );
        SelectObject( hDC, hOldFont );
        EndPaint( hWnd, &ps );
    }

}
开发者ID:mkane848,项目名称:HLPlague,代码行数:39,代码来源:display.cpp

示例15: BoxPreviewWndProc

INT_PTR CALLBACK BoxPreviewWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg) {
	case WM_PAINT:
		if (GetUpdateRect(hwnd, 0, FALSE)) {
			PAINTSTRUCT ps;
			HDC mydc = BeginPaint(hwnd, &ps);
			BoxPreview_OnPaint(hwnd, mydc, GetWindowLongPtr(hwnd, GWLP_USERDATA));
			EndPaint(hwnd, &ps);
			return TRUE;
		}
		break;

	case WM_PRINT:
	case WM_PRINTCLIENT:
		BoxPreview_OnPaint(hwnd, (HDC)wParam, GetWindowLongPtr(hwnd, GWLP_USERDATA));
		return TRUE;

	case WM_LBUTTONDOWN:
		ReleaseCapture();
		SendMessage(hwnd, WM_SYSCOMMAND, 0xF012 /*SC_DRAGMOVE*/, 0);
		return TRUE;
	}
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:25,代码来源:opt_skins.cpp


注:本文中的GetUpdateRect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。