Exemplo n.º 1
0
/*
 * 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");
}
Exemplo n.º 2
0
WindowProcType WndProc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) {
	if (message == WM_CREATE) {
		return 0; /* Success */
	}
	else if (message == WM_DESTROY) {
		PostQuitMessage(0);
		return 0; /* OK */
	}
	else if (message == WM_SETCURSOR) {
		if (LOWORD(lparam) == HTCLIENT) {
			SetCursor(LoadCursor(NULL,IDC_ARROW));
			return 1;
		}
		else {
			return DefWindowProc(hwnd,message,wparam,lparam);
		}
	}
	else if (message == WM_ERASEBKGND) {
		RECT um;

		if (GetUpdateRect(hwnd,&um,FALSE)) {
			HBRUSH oldBrush,newBrush;
			HPEN oldPen,newPen;

			newPen = (HPEN)GetStockObject(NULL_PEN);
			newBrush = (HBRUSH)GetStockObject(WHITE_BRUSH);

			oldPen = SelectObject((HDC)wparam,newPen);
			oldBrush = SelectObject((HDC)wparam,newBrush);

			Rectangle((HDC)wparam,um.left,um.top,um.right+1,um.bottom+1);

			SelectObject((HDC)wparam,oldBrush);
			SelectObject((HDC)wparam,oldPen);
		}

		return 1; /* Important: Returning 1 signals to Windows that we processed the message. Windows 3.0 gets really screwed up if we don't! */
	}
	else if (message == WM_PAINT) {
		RECT um;

		if (GetUpdateRect(hwnd,&um,TRUE)) {
			PAINTSTRUCT ps;

			BeginPaint(hwnd,&ps);
			TextOut(ps.hdc,0,0,HelloWorldText,strlen(HelloWorldText));
			DrawIcon(ps.hdc,5,20,AppIcon);
			EndPaint(hwnd,&ps);
		}

		return 0; /* Return 0 to signal we processed the message */
	}
	else {
		return DefWindowProc(hwnd,message,wparam,lparam);
	}

	return 0;
}
Exemplo n.º 3
0
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);
}
Exemplo n.º 4
0
bool QWindowsWindow::handleWmPaint(HWND hwnd, UINT message,
                                         WPARAM, LPARAM)
{
    // Ignore invalid update bounding rectangles
    if (!GetUpdateRect(m_data.hwnd, 0, FALSE))
        return false;
    if (message == WM_ERASEBKGND) // Backing store - ignored.
        return true;
    PAINTSTRUCT ps;
    if (testFlag(OpenGLSurface)) {
        // Observed painting problems with Aero style disabled (QTBUG-7865).
        if (testFlag(OpenGLDoubleBuffered))
            InvalidateRect(hwnd, 0, false);
        BeginPaint(hwnd, &ps);
        QWindowSystemInterface::handleSynchronousExposeEvent(window(),
                                                             QRegion(qrectFromRECT(ps.rcPaint)));
        EndPaint(hwnd, &ps);
    } else {
        releaseDC();
        m_hdc = BeginPaint(hwnd, &ps);
        setFlag(WithinWmPaint);

        const QRect updateRect = qrectFromRECT(ps.rcPaint);
        if (QWindowsContext::verboseIntegration)
            qDebug() << __FUNCTION__ << this << window() << updateRect;

        QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRegion(updateRect));
        clearFlag(WithinWmPaint);
        m_hdc = 0;
        EndPaint(hwnd, &ps);
    }
    return true;
}
Exemplo n.º 5
0
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);
        }

    }

}
Exemplo n.º 6
0
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;
}
Exemplo n.º 7
0
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 );
	}
}
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);
}
/******************************************************************************
* 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 );
    }        
}
Exemplo n.º 10
0
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);
}
Exemplo n.º 11
0
void CToolbarControlBar::OnPaint(void)
{
    CRect rcClient, updateRect, toolbarRect, intersectRect;

    GetClientRect(&rcClient);
    GetUpdateRect(&updateRect);
    m_pToolbar->GetClientRect(&toolbarRect);

    CPaintDC dcPaint(this);

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

#ifdef _WIN32
    DrawBorders(&dcPaint, rcClient);
#endif

    m_pToolbar->MapWindowPoints(this, &toolbarRect);

    if(intersectRect.IntersectRect(updateRect, toolbarRect))
    {
        MapWindowPoints(m_pToolbar, &intersectRect);
        m_pToolbar->RedrawWindow(&intersectRect);
    }
}
Exemplo n.º 12
0
BOOL CColorStatic::OnEraseBkgnd(CDC* pDC)
{
	CRect rcClient;
	GetUpdateRect(&rcClient);			  
	pDC->FillSolidRect(rcClient, RGB(255,255,255));	
	return FALSE;	
}
Exemplo n.º 13
0
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);
  }
}
Exemplo n.º 14
0
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;
}
Exemplo n.º 15
0
//-----------------------------------------------------------------------------
// 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);
		}
	}
}
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);
}
Exemplo n.º 17
0
/******************************************************************************
* 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 );
    }

}
Exemplo n.º 18
0
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);
}
Exemplo n.º 19
0
// window procedure
LRESULT CALLBACK SpectrumWindowProc(HWND h, UINT m, WPARAM w, LPARAM l)
{
	switch (m) {
		case WM_LBUTTONDOWN:
		case WM_RBUTTONDOWN:
		case WM_MOUSEMOVE:
			if (w&MK_LBUTTON) SetLoopStart(LOWORD(l)*bpp); // set loop start
			if (w&MK_RBUTTON) SetLoopEnd(LOWORD(l)*bpp); // set loop end
			return 0;

		case WM_MBUTTONDOWN:
			BASS_ChannelSetPosition(chan,LOWORD(l)*bpp,BASS_POS_BYTE); // set current pos
			return 0;

		case WM_TIMER:
			InvalidateRect(h,0,0); // refresh window
			return 0;

		case WM_PAINT:
			if (GetUpdateRect(h,0,0)) {
				PAINTSTRUCT p;
				HDC dc;
				if (!(dc=BeginPaint(h,&p))) return 0;
				BitBlt(dc,0,0,WIDTH,HEIGHT,wavedc,0,0,SRCCOPY); // draw peak waveform
				DrawTimeLine(dc,loop[0],0xffff00,12); // loop start
				DrawTimeLine(dc,loop[1],0x00ffff,24); // loop end
				DrawTimeLine(dc,BASS_ChannelGetPosition(chan,BASS_POS_BYTE),0xffffff,0); // current pos
				EndPaint(h,&p);
			}
			return 0;

		case WM_CREATE:
			win=h;
			// initialize output
			if (!BASS_Init(-1,44100,0,win,NULL)) {
				Error("Can't initialize device");
				return -1;
			}
			if (!PlayFile()) { // start a file playing
				BASS_Free();
				return -1;
			}
			SetTimer(h,0,100,0); // set update timer (10hz)
			break;

		case WM_DESTROY:
			KillTimer(h,0);
			if (scanthread) { // still scanning
				killscan=TRUE;
				WaitForSingleObject((HANDLE)scanthread,1000); // wait for the thread
			}
			BASS_Free();
			if (wavedc) DeleteDC(wavedc);
			if (wavebmp) DeleteObject(wavebmp);
			PostQuitMessage(0);
			break;
	}
	return DefWindowProc(h, m, w, l);
}
Exemplo n.º 20
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : pDC - 
// Output : Returns TRUE on success, FALSE on failure.
//-----------------------------------------------------------------------------
BOOL CTextureBox::OnEraseBkgnd(CDC *pDC) 
{
	CRect r;
	GetUpdateRect(r);
	pDC->SetROP2(R2_COPYPEN);
	FillRect(pDC->m_hDC, r, HBRUSH(GetStockObject(BLACK_BRUSH)));
	return TRUE;
}
Exemplo n.º 21
0
void as_Sound::updateGridColored()
{
    HWND hWndGrid;
    HDC hDC;
    RECT rc;

    //    static LONG s_lPixel[5] = { CLR_INVALID, CLR_INVALID, CLR_INVALID, CLR_INVALID, CLR_INVALID };
    static LONG s_lX = 0;
    static LONG s_lY = 0;
    COLORREF color = 0;
    COLORREF darkColor = 0;

    if (NULL == hWndGridView)
        return;

    hWndGrid = GetDlgItem(hWndGridView, IDC_GRID);
    hDC = GetDC(hWndGrid);

    // Don't update the grid if a WM_PAINT will be called soon
    BOOL bUpdateInProgress = GetUpdateRect(hWndGridView, NULL, FALSE);
    if (bUpdateInProgress)
    {
        return;
    }

    color = this->color;
    darkColor = RGB(GetRValue(color) * 0.5, GetGValue(color) * 0.5, GetBValue(color) * 0.5);

    s_lX = this->oldGridPosX;
    s_lY = this->oldGridPosY;

    // Draw a crosshair object darker than normal the trail
    SetPixel(hDC, s_lX - 1, s_lY + 0, darkColor);
    SetPixel(hDC, s_lX + 0, s_lY - 1, darkColor);
    SetPixel(hDC, s_lX + 0, s_lY + 0, darkColor);
    SetPixel(hDC, s_lX + 0, s_lY + 1, darkColor);
    SetPixel(hDC, s_lX + 1, s_lY + 0, darkColor);

    // Convert the world space x,y coordinates to pixel coordinates
    GetClientRect(hWndGrid, &rc);

    // attention: x, z are horizontal, y is vertical axis !!!

    s_lX = (LONG)(((rc.right - rc.left) / 2) + 50 * (this->Position[0]));
    s_lY = (LONG)(((rc.bottom - rc.top) / 2) - 50 * (this->Position[2]));

    // Draw a crosshair object in light pixels
    SetPixel(hDC, s_lX - 1, s_lY + 0, color);
    SetPixel(hDC, s_lX + 0, s_lY - 1, color);
    SetPixel(hDC, s_lX + 0, s_lY + 0, color);
    SetPixel(hDC, s_lX + 0, s_lY + 1, color);
    SetPixel(hDC, s_lX + 1, s_lY + 0, color);

    ReleaseDC(hWndGrid, hDC);

    this->oldGridPosX = s_lX;
    this->oldGridPosY = s_lY;
}
Exemplo n.º 22
0
LRESULT CALLBACK Proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) {
    Window* window = (Window*)GetWindowLong(hwnd, GWL_USERDATA);
    switch (message) {
    case  WM_ERASEBKGND:
        return true;
    case WM_PAINT:
        {
            RECT rect;
            GetUpdateRect(hwnd, &rect, FALSE);
            SkRect clip_rect = SkRect::MakeXYWH(
                SkIntToScalar(rect.left), 
                SkIntToScalar(rect.top), 
                SkIntToScalar(rect.right - rect.left),
                SkIntToScalar(rect.bottom - rect.top));
            window->Draw(clip_rect);
            TexturePool::GetInstance()->CanvasToScreen(clip_rect);
        }
        break;
    case WM_SIZE:
        {
            if(wParam != SIZE_MINIMIZED) {
                RECT rect;
                GetClientRect(hwnd, &rect);
                window->SetGeometry(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
                window->Dolayout();
            }
        }
        break;
    case WM_GETMINMAXINFO:
        {
            LPMINMAXINFO lpMMI = (LPMINMAXINFO)lParam;
            if(window->LimitMaxWidth() < (int)(INT32_MAX - GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYBORDER))) {
                lpMMI->ptMaxTrackSize.x = window->LimitMaxWidth() + GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYBORDER);
            }
            if(window->LimitMaxHeight() < (int)(INT32_MAX - GetSystemMetrics(SM_CYBORDER) + GetSystemMetrics(SM_CYBORDER))) {
                lpMMI->ptMaxTrackSize.y = window->LimitMaxHeight() + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER);
            }
            RECT inner_rect, window_rect;
            GetClientRect(hwnd, &inner_rect);
            GetWindowRect(hwnd, &window_rect);

            lpMMI->ptMinTrackSize.x = window->LimitMinWidth() + 
                ((window_rect.right - window_rect.left) - (inner_rect.right - inner_rect.left));

            lpMMI->ptMinTrackSize.y = window->LimitMinHeight() +
                ((window_rect.bottom - window_rect.top) - (inner_rect.bottom - inner_rect.top));
        }
    default:
        auto events = EventFactory::GetInstance()->CreateEvent(message, wParam, lParam);
        for (auto event:events) {
            if(event && event->Target()) {
                event->Target()->DoEvent(event.get());
            }
        }
    }
    return CallWindowProc(window->oldProc_, hwnd, message, wParam, lParam);
}
Exemplo n.º 23
0
/******************************************************************************
* EntryPanePaint *
*----------------*
*   Description:
*       Do the paint on the entry pane.
*
******************************************************************************/
void EntryPanePaint( HWND hWnd, LPCTSTR szName )
{
    if ( GetUpdateRect( hWnd, NULL, TRUE ) )
    {
        PAINTSTRUCT ps;
        HDC hDC;
        TCHAR tBuf[MAX_LOADSTRING];
        TCHAR tLoadBuf[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 );
        
        rc.left = 0;
        rc.right = 100;
        LoadString( g_hInst, IDS_ENTERSTORE, tBuf, MAX_LOADSTRING );
        int iHeight = DrawText( hDC, tBuf, -1, &rc, DT_CALCRECT | DT_WORDBREAK );
        rc.left += 25;
        rc.right += 25;
        rc.top = ( clientRC.bottom - iHeight ) / 2;
        rc.bottom = rc.top + iHeight + 1;
        DrawText( hDC, tBuf, -1, &rc, DT_WORDBREAK );
        
        rc.left = 0;
        rc.right = 100;
        LoadString( g_hInst, IDS_ENTEROFFICE, tBuf, MAX_LOADSTRING );
        iHeight = DrawText( hDC, tBuf, -1, &rc, DT_CALCRECT | DT_WORDBREAK );
        rc.left = clientRC.right - 125;
        rc.right = rc.left + 100;
        rc.top = ( clientRC.bottom - iHeight ) / 2;
        rc.bottom = rc.top + iHeight + 1;
        DrawText( hDC, tBuf, -1, &rc, DT_WORDBREAK );


        LoadString( g_hInst, IDS_WELCOME, tLoadBuf, MAX_LOADSTRING );
        _stprintf_s( tBuf, _countof(tBuf), tLoadBuf, szName );
        rc.left = 0;
        rc.right = 450;
        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 );
    }
}
Exemplo n.º 24
0
LRESULT HubMessageControl::onChangeFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
  if (GetUpdateRect(NULL, FALSE)) {
    Invalidate();
  }
  else {
    dcdebug("call drawFocusRect in onChangeFocus\n");
    CClientDC dc(m_hWnd);
    drawFocusRect(dc);
  }
  return 0;
}
Exemplo n.º 25
0
static LRESULT CALLBACK progress_subclass_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    if (msg == WM_PAINT)
    {
        GetUpdateRect(hWnd, &last_paint_rect, FALSE);
    }
    else if (msg == WM_ERASEBKGND)
    {
        erased = TRUE;
    }
    return CallWindowProcA(progress_wndproc, hWnd, msg, wParam, lParam);
}
Exemplo n.º 26
0
void CMatCanvas::OnPaint()
{
	RECT rect;
	if (GetUpdateRect(&rect)) {
		PAINTSTRUCT ps;
	  	BeginPaint(&ps);
		Refresh();
		EndPaint(&ps);
	}
	else
		Refresh();
}
Exemplo n.º 27
0
static void init(void)
{
    HMODULE hComctl32;
    BOOL (WINAPI *pInitCommonControlsEx)(const INITCOMMONCONTROLSEX*);
    WNDCLASSA wc;
    RECT rect;
    BOOL ret;

    hComctl32 = GetModuleHandleA("comctl32.dll");
    pInitCommonControlsEx = (void*)GetProcAddress(hComctl32, "InitCommonControlsEx");
    if (pInitCommonControlsEx)
    {
        INITCOMMONCONTROLSEX iccex;
        iccex.dwSize = sizeof(iccex);
        iccex.dwICC  = ICC_PROGRESS_CLASS;
        pInitCommonControlsEx(&iccex);
    }
    else
        InitCommonControls();
  
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = GetModuleHandleA(NULL);
    wc.hIcon = NULL;
    wc.hCursor = LoadCursorA(NULL, (LPCSTR)IDC_ARROW);
    wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
    wc.lpszMenuName = NULL;
    wc.lpszClassName = progressTestClass;
    wc.lpfnWndProc = progress_test_wnd_proc;
    RegisterClassA(&wc);

    SetRect(&rect, 0, 0, 400, 20);
    ret = AdjustWindowRect(&rect, WS_OVERLAPPEDWINDOW, FALSE);
    ok(ret, "got %d\n", ret);
    
    hProgressParentWnd = CreateWindowExA(0, progressTestClass, "Progress Bar Test", WS_OVERLAPPEDWINDOW,
      CW_USEDEFAULT, CW_USEDEFAULT, rect.right - rect.left, rect.bottom - rect.top, NULL, NULL, GetModuleHandleA(NULL), 0);
    ok(hProgressParentWnd != NULL, "failed to create parent wnd\n");

    GetClientRect(hProgressParentWnd, &rect);
    hProgressWnd = CreateWindowExA(0, PROGRESS_CLASSA, "", WS_CHILD | WS_VISIBLE,
      0, 0, rect.right, rect.bottom, hProgressParentWnd, NULL, GetModuleHandleA(NULL), 0);
    ok(hProgressWnd != NULL, "failed to create parent wnd\n");
    progress_wndproc = (WNDPROC)SetWindowLongPtrA(hProgressWnd, GWLP_WNDPROC, (LPARAM)progress_subclass_proc);
    
    ShowWindow(hProgressParentWnd, SW_SHOWNORMAL);
    ok(GetUpdateRect(hProgressParentWnd, NULL, FALSE), "GetUpdateRect: There should be a region that needs to be updated\n");
    flush_events();
    update_window(hProgressParentWnd);    
}
Exemplo n.º 28
0
HDC WINAPI 
BeginPaint(HWND hwnd, LPPAINTSTRUCT lpPaint)
{
	HDC	hdc;

	/* first update non-client area*/
	if(mwforceNCpaint || hwnd->paintNC != mwpaintNC) {
		MwPaintNCArea(hwnd);
		hwnd->paintNC = mwpaintNC;
	}

	/* If ERASEMOVE:
	 * Don't allow windows to repaint while user is moving
	 * a window.  Instead, just erase backgrounds
	 * and indicate delayed painting required, which
	 * will occur after user completes window move.
	 */
	if(mwERASEMOVE && dragwp) {
		hdc = NULL;
		lpPaint->fErase = !DefWindowProc(hwnd, WM_ERASEBKGND, 0, 0L);
		hwnd->gotPaintMsg = PAINT_DELAYPAINT;
	} else {
		HideCaret(hwnd);

		/* FIXME: mdemo requires update excluded or draw errors occur*/
		hdc = GetDCEx(hwnd, NULL, DCX_DEFAULTCLIP
				|DCX_EXCLUDEUPDATE);	/* FIXME - bug*/

		/* erase client background, always w/alpha blending*/
		if(hwnd->nEraseBkGnd > 0 || mwforceNCpaint)
			lpPaint->fErase = !SendMessage(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0L);
		else
			lpPaint->fErase = 0;

		hwnd->nEraseBkGnd = 0;
	}
	lpPaint->hdc = hdc;

	if( hwnd->paintBrush != NULL )
		DeleteObject ( hwnd->paintBrush );
	if( hwnd->paintPen != NULL )
		DeleteObject ( hwnd->paintPen );
	hwnd->paintBrush = NULL;
	hwnd->paintPen = NULL;

	GetUpdateRect(hwnd, &lpPaint->rcPaint, FALSE);
	return hdc;
}
Exemplo n.º 29
0
static	LRESULT	Wm_PaintProc(HWND hWnd)
{
	PAINTSTRUCT	ps;
	HDC			PaintDC;

	// TODO: Add any drawing code here...
	if(GetUpdateRect(hWnd,NULL,TRUE))
	{
	    char tmp[200];
	    PaintDC=BeginPaint(hWnd,&ps);
	    sprintf(tmp,"DrawGr((HDC)%ld",PaintDC);
	    G__calc(tmp); /* Call Cint parser */
	    /* DrawGr(PaintDC); */
	    EndPaint(hWnd, &ps);
	}
	return	0;
}
Exemplo n.º 30
0
//-----------------------------------------------------------------------------
// Name: UpdateGrid()
// Desc: Draws a red dot in the dialog's grid bitmap at the x,y coordinate.
//-----------------------------------------------------------------------------
VOID UpdateGrid( HWND hDlg, FLOAT x, FLOAT y )
{
    static LONG s_lPixel[5] = { CLR_INVALID,CLR_INVALID,CLR_INVALID,CLR_INVALID,CLR_INVALID };
    static LONG s_lX = 0;
    static LONG s_lY = 0;

    HWND hWndGrid = GetDlgItem( hDlg, IDC_RENDER_WINDOW );
    HDC  hDC      = GetDC( hWndGrid );
    RECT rc;

    // Don't update the grid if a WM_PAINT will be called soon
    BOOL bUpdateInProgress = GetUpdateRect(hDlg,NULL,FALSE);
    if( bUpdateInProgress )
        return;

    if( s_lPixel[0] != CLR_INVALID ) 
    {
        // Replace pixels from that were overdrawn last time
        SetPixel( hDC, s_lX-1, s_lY+0, s_lPixel[0] );
        SetPixel( hDC, s_lX+0, s_lY-1, s_lPixel[1] );
        SetPixel( hDC, s_lX+0, s_lY+0, s_lPixel[2] );
        SetPixel( hDC, s_lX+0, s_lY+1, s_lPixel[3] );
        SetPixel( hDC, s_lX+1, s_lY+0, s_lPixel[4] );   
    }

    // Convert the world space x,y coordinates to pixel coordinates
    GetClientRect( hWndGrid, &rc );
    s_lX = (LONG)( ( x/ORBIT_MAX_RADIUS + 1 ) * ( rc.left + rc.right ) / 2 );
    s_lY = (LONG)( (-y/ORBIT_MAX_RADIUS + 1 ) * ( rc.top + rc.bottom ) / 2 );

    // Save the pixels before drawing the cross hair
    s_lPixel[0] = GetPixel( hDC, s_lX-1, s_lY+0 );
    s_lPixel[1] = GetPixel( hDC, s_lX+0, s_lY-1 );
    s_lPixel[2] = GetPixel( hDC, s_lX+0, s_lY+0 );
    s_lPixel[3] = GetPixel( hDC, s_lX+0, s_lY+1 );
    s_lPixel[4] = GetPixel( hDC, s_lX+1, s_lY+0 );

    // Draw a crosshair object in red pixels
    SetPixel( hDC, s_lX-1, s_lY+0, 0x000000ff );
    SetPixel( hDC, s_lX+0, s_lY-1, 0x000000ff );
    SetPixel( hDC, s_lX+0, s_lY+0, 0x000000ff );
    SetPixel( hDC, s_lX+0, s_lY+1, 0x000000ff );
    SetPixel( hDC, s_lX+1, s_lY+0, 0x000000ff );

    ReleaseDC( hWndGrid, hDC );
}