Click here to Skip to main content
15,896,912 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Sending HTTP Post via TCP/IP Pin
Moak14-Sep-10 0:22
Moak14-Sep-10 0:22 
GeneralRe: Sending HTTP Post via TCP/IP Pin
Dustin Henry14-Sep-10 7:02
Dustin Henry14-Sep-10 7:02 
QuestionValidating console input Pin
Danzy8313-Sep-10 7:33
Danzy8313-Sep-10 7:33 
AnswerRe: Validating console input Pin
mk1488213-Sep-10 9:08
mk1488213-Sep-10 9:08 
AnswerRe: Validating console input Pin
Aescleal13-Sep-10 11:10
Aescleal13-Sep-10 11:10 
Questiondelete option in IE8 address bar Pin
inza113-Sep-10 7:04
inza113-Sep-10 7:04 
Answersomeone?any idea? Pin
inza122-Sep-10 4:50
inza122-Sep-10 4:50 
QuestionCalling APIs Problem In Drivers Pin
Coder-12345613-Sep-10 7:00
Coder-12345613-Sep-10 7:00 
AnswerRe: Calling APIs Problem In Drivers Pin
JudyL_MD13-Sep-10 11:07
JudyL_MD13-Sep-10 11:07 
QuestionSet the RibbonComboBox to Drop List type by code Pin
coolhem13-Sep-10 4:23
coolhem13-Sep-10 4:23 
AnswerRe: Set the RibbonComboBox to Drop List type by code Pin
Eugen Podsypalnikov13-Sep-10 9:15
Eugen Podsypalnikov13-Sep-10 9:15 
GeneralRe: Set the RibbonComboBox to Drop List type by code Pin
coolhem13-Sep-10 14:56
coolhem13-Sep-10 14:56 
GeneralRe: Set the RibbonComboBox to Drop List type by code Pin
Eugen Podsypalnikov13-Sep-10 19:55
Eugen Podsypalnikov13-Sep-10 19:55 
GeneralRe: Set the RibbonComboBox to Drop List type by code Pin
coolhem13-Sep-10 21:25
coolhem13-Sep-10 21:25 
GeneralRe: Set the RibbonComboBox to Drop List type by code Pin
Eugen Podsypalnikov14-Sep-10 0:00
Eugen Podsypalnikov14-Sep-10 0:00 
GeneralRe: Set the RibbonComboBox to Drop List type by code Pin
coolhem14-Sep-10 22:59
coolhem14-Sep-10 22:59 
QuestionLibraries and compiler compatibility Pin
funwithdolphin13-Sep-10 3:10
funwithdolphin13-Sep-10 3:10 
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.

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.