Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Libraries and compiler compatibility Pin
«_Superman_»13-Sep-10 4:04
professional«_Superman_»13-Sep-10 4:04 
AnswerRe: Libraries and compiler compatibility Pin
Chris Losinger13-Sep-10 4:11
professionalChris Losinger13-Sep-10 4:11 
AnswerRe: Libraries and compiler compatibility Pin
Aescleal13-Sep-10 6:24
Aescleal13-Sep-10 6:24 
GeneralRe: Libraries and compiler compatibility Pin
Joe Woodbury13-Sep-10 6:38
professionalJoe Woodbury13-Sep-10 6:38 
GeneralRe: Libraries and compiler compatibility Pin
Chris Losinger13-Sep-10 9:15
professionalChris Losinger13-Sep-10 9:15 
GeneralRe: Libraries and compiler compatibility Pin
Aescleal13-Sep-10 11:07
Aescleal13-Sep-10 11:07 
GeneralRe: Libraries and compiler compatibility Pin
Joe Woodbury13-Sep-10 11:26
professionalJoe Woodbury13-Sep-10 11:26 
QuestionProblem with Painting logic Pin
narayanagvs13-Sep-10 0:42
narayanagvs13-Sep-10 0:42 
Hi,

In my application I have a window in which there are few buttons below the window and on clicking each of the buttons Activex controls from a list with certain conditions are shown in the same window above these buttons .This is done using painting logic.The Problem I am having here is there are prev screen left overs when I swiitch between button clicks.
This bug appears only once when I open the window and do the button clicks.If at all I Minimize and Maximize my window atleast once this bug doesn't appear and every works fine.

I face the issue only when I use DeviceindependentBitmap to Bitblt.I assume the problem is with clipregions.
Please suggest me on the same.

Below is the snippets of code

case WM_PAINT:{
		RECT rc;
		HDC hdcMem, hdcOld;
		HBRUSH hbrBkGnd;
		HFONT hfntOld;
		PAINTSTRUCT ps;
		DWORD dwConnectState;

		// Don't bother Processing any WM_PAINT messages if you are in the process of 
		// shutting down Window.
		if(! bViewClosing )	 
		{
		// Get the window update region before calling BeginPaint. 
		// Note: The BeginPaint function automatically validates the update region, so any call 
		// to GetUpdateRgn made immediately after the call to BeginPaint retrieves an empty update 

		region. 
		if(hClipRgn == NULL)
		{
			hClipRgn = CreateRectRgn(0,0,0,0);
			GetUpdateRgn(hWnd, hClipRgn, FALSE);
		}
		ws = (WIN_STRUCTPTR) GetWindowLong( hWnd, 0 );
		BeginPaint(hWnd, (LPPAINTSTRUCT)&ps);

		// Get the size of the client rectangle.
		GetClientRect(hWnd, &rc);

		// Create a compatible DC.
		hdcMem = CreateCompatibleDC(ps.hdc);

		bool createFailed = false;

		// Create a DIBSection big enough for our client rectangle.
		long width = rc.right-rc.left;
		long height = rc.bottom-rc.top;
		//Start of CRL00107461 
		HWND dDeskWnd = GetDesktopWindow();
		HDC hdc= GetDC(dDeskWnd);
		int nBitCount = GetDeviceCaps(hdc,BITSPIXEL);
		if (hbmDIBSection == NULL || dibSectionWidth < width || dibSectionHeight < height)
		{
			if (hbmDIBSection != NULL)
				DeleteObject(hbmDIBSection);
			
			BITMAPINFO bmi = {0};
			bmi.bmiHeader.biSize        = sizeof(BITMAPINFOHEADER);
			bmi.bmiHeader.biWidth       = width;
			bmi.bmiHeader.biHeight      = height;
			bmi.bmiHeader.biPlanes      = 1;
		    bmi.bmiHeader.biBitCount    = nBitCount;//32;       // 32 bits per pixel.//CRL00107461
			bmi.bmiHeader.biCompression = BI_RGB;
			bmi.bmiHeader.biSizeImage   = bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight * 4; 

// 4 bytes per pixel

			LPVOID pBitmapBits = NULL;

			hbmDIBSection = CreateDIBSection(NULL, &bmi, (nBitCount > 8)? 

DIB_RGB_COLORS:DIB_PAL_COLORS , &pBitmapBits, NULL, 0);

			if (hbmDIBSection == NULL)
				createFailed = true;

			dibSectionWidth = width;
			dibSectionHeight = height;
		}

		if (createFailed == false)
		{
			// Select the bitmap into the off-screen DC.
			HBITMAP hbmOld = (HBITMAP) SelectObject(hdcMem, hbmDIBSection);

			// set the clip region -- this is used by orion to know what to draw		
			//HRGN hClipRgn = CreateRectRgn(ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right, 

ps.rcPaint.bottom);
			HRGN hOldRgn = (HRGN) SelectClipRgn(hdcMem, hClipRgn);

			// Erase the background.
			hbrBkGnd = CreateSolidBrush(ws->wBkgColor);
			FillRect(hdcMem, &rc, hbrBkGnd);
			DeleteObject(hbrBkGnd);

			//store the actual dc and substitute it with mem dc
			hdcOld = ps.hdc;
			
			ps.hdc = hdcMem;
			ws->wHDC = hdcMem;
                        ------
                        -------
			ViewPuPaint(hWnd, &ps);
			
			//restore the dc
			ps.hdc = hdcOld;
			ws->wHDC = hdcOld;
			
			// Blt the changes to the screen DC only for the necessary region given by the 

paintstruct...
			BitBlt(ps.hdc,
				   ps.rcPaint.left, ps.rcPaint.top,
				   ps.rcPaint.right-ps.rcPaint.left, ps.rcPaint.bottom-ps.rcPaint.top,
				   hdcMem,
				   ps.rcPaint.left, ps.rcPaint.top,
				   SRCCOPY);

			// Done with off-screen bitmap, clip region and DC.
			SelectClipRgn(hdcMem, hOldRgn);

			SelectObject(hdcMem, hbmOld);

		}
		else
		{
			ViewPuPaint(hWnd, &ps);
		}
		DeleteDC(hdcMem);		

		RedrawTransparentUserControls(hWnd, hClipRgn, TRUE);

		if(hClipRgn != NULL)
		{
			DeleteObject( hClipRgn );
			hClipRgn  = NULL;
		}
		EndPaint(hWnd, (LPPAINTSTRUCT)&ps);

		}
        }break;


Thanks
Satya
Today is a gift, that's why it is called the present.

AnswerRe: Problem with Painting logic Pin
Niklas L13-Sep-10 1:53
Niklas L13-Sep-10 1:53 
QuestionAccess Denied in Local System Account Service Pin
gothic_coder12-Sep-10 21:18
gothic_coder12-Sep-10 21:18 
AnswerRe: Access Denied in Local System Account Service Pin
bob1697213-Sep-10 8:51
bob1697213-Sep-10 8:51 
GeneralRe: Access Denied in Local System Account Service Pin
gothic_coder13-Sep-10 21:17
gothic_coder13-Sep-10 21:17 
GeneralRe: Access Denied in Local System Account Service Pin
bob1697214-Sep-10 3:19
bob1697214-Sep-10 3:19 
GeneralRe: Access Denied in Local System Account Service Pin
gothic_coder14-Sep-10 20:52
gothic_coder14-Sep-10 20:52 
GeneralRe: Access Denied in Local System Account Service Pin
bob1697220-Sep-10 4:59
bob1697220-Sep-10 4:59 
QuestionUngroup Excel columns Pin
Mugdha_Aditya12-Sep-10 19:23
Mugdha_Aditya12-Sep-10 19:23 
AnswerRe: Ungroup Excel columns Pin
Niklas L13-Sep-10 2:23
Niklas L13-Sep-10 2:23 
GeneralRe: Ungroup Excel columns Pin
Mugdha_Aditya13-Sep-10 3:32
Mugdha_Aditya13-Sep-10 3:32 
QuestionChoosing files from a directory Pin
Danzy8312-Sep-10 11:36
Danzy8312-Sep-10 11:36 
AnswerRe: Choosing files from a directory Pin
Luc Pattyn12-Sep-10 12:03
sitebuilderLuc Pattyn12-Sep-10 12:03 
GeneralRe: Choosing files from a directory Pin
Danzy8312-Sep-10 12:58
Danzy8312-Sep-10 12:58 
GeneralRe: Choosing files from a directory Pin
Luc Pattyn12-Sep-10 13:04
sitebuilderLuc Pattyn12-Sep-10 13:04 
GeneralRe: Choosing files from a directory Pin
Danzy8312-Sep-10 13:40
Danzy8312-Sep-10 13:40 
GeneralRe: Choosing files from a directory Pin
Luc Pattyn12-Sep-10 13:57
sitebuilderLuc Pattyn12-Sep-10 13:57 
GeneralRe: Choosing files from a directory Pin
Danzy8312-Sep-10 14:12
Danzy8312-Sep-10 14:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.