Click here to Skip to main content
15,914,488 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Making MFC go fullscreen Pin
Rick York18-Dec-01 8:22
mveRick York18-Dec-01 8:22 
GeneralRe: Making MFC go fullscreen Pin
18-Dec-01 9:34
suss18-Dec-01 9:34 
GeneralRe: Making MFC go fullscreen Pin
Todd.Harvey18-Dec-01 8:47
Todd.Harvey18-Dec-01 8:47 
GeneralRe: Making MFC go fullscreen Pin
18-Dec-01 9:48
suss18-Dec-01 9:48 
QuestionHow to capture IE Event in WTL.... Pin
Huu Quynh18-Dec-01 3:44
Huu Quynh18-Dec-01 3:44 
GeneralExplain EnumChildWindows(...) Pin
Rickard Andersson2018-Dec-01 2:45
Rickard Andersson2018-Dec-01 2:45 
GeneralRe: Explain EnumChildWindows(...) Pin
Bill Wilson18-Dec-01 6:21
Bill Wilson18-Dec-01 6:21 
GeneralA Drawing Problem. Please HELP ! ! ! Pin
The_Server18-Dec-01 2:44
The_Server18-Dec-01 2:44 
Hi, all ! ! !
--------

This function should draw the HBITMAP (m_hPicUp) to the Device Context (hdc).
The function also use another HBITMAP (m_hPicMask) as a mask for drawing.

Now, the problem is that it only works on the first time.
Every WM_PAINT, I call this function.
and it draws normally only at the first WM_PAINT.

Please tell me why.

void DrawIt ( HDC hdc)
{
	<code>RECT</code> r;
	::GetClientRect( m_hWnd, &r);

	if(!m_hPicUp) return;	//safe check

	<code>int</code> cx=r.right  - r.left;
	<code>int</code> cy=r.bottom - r.top;
	<code>HDC</code> hdcBmp= CreateCompatibleDC(hdc);
	<code>HBITMAP</code> hOldBmp= (<code>HBITMAP</code>)SelectObject(hdcBmp, m_hPicUp);
	
	<code>HDC</code> hdcMask= CreateCompatibleDC(hdc);
	<code>HBITMAP</code> hOldMsk= (<code>HBITMAP</code>)SelectObject(hdcMask, m_hPicMask);

	<code>HDC</code> hdcMem= CreateCompatibleDC(hdc);
	
	<code>HBITMAP</code> hBitmap;
	hBitmap= CreateCompatibleBitmap(hdc,cx,cy);
	<code>HBITMAP</code> hOldMem= (<code>HBITMAP</code>)SelectObject(hdcMem, hBitmap);
		
	BitBlt(hdcMem, r.left,r.top,cx,cy,hdc,0,0,SRCCOPY);
	BitBlt(hdcMem, r.left,r.top,cx,cy,hdcBmp,0,0,SRCINVERT);
	BitBlt(hdcMem, r.left,r.top,cx,cy,hdcMask,0,0,SRCAND);
	BitBlt(hdcMem, r.left,r.top,cx,cy,hdcBmp,0,0,SRCINVERT);
	
	BitBlt(hdc, r.left,r.top,cx,cy,hdcMem,0,0,SRCCOPY);

	DeleteObject(SelectObject(hdcBmp, hOldBmp));
	DeleteObject(SelectObject(hdcMask, hOldMsk));
	DeleteObject(SelectObject(hdcMem, hOldMem));
	DeleteObject(hBitmap);
	DeleteDC(hdcMem);
	DeleteDC(hdcMask);
	DeleteDC(hdcBmp);
}


I copied that code from CxSkinButton::DrawBitmap(...) and changed it to NOT MFC.



BTW: come to #CodeProject on DalNet (mIRC)
GeneralRe: A Drawing Problem. Please HELP ! ! ! Pin
Joaquín M López Muñoz18-Dec-01 2:50
Joaquín M López Muñoz18-Dec-01 2:50 
GeneralRe: A Drawing Problem. Please HELP ! ! ! Pin
The_Server18-Dec-01 3:21
The_Server18-Dec-01 3:21 
GeneralDLL Linkage Problem Pin
James Spibey18-Dec-01 1:15
James Spibey18-Dec-01 1:15 
GeneralRe: DLL Linkage Problem Pin
Joaquín M López Muñoz18-Dec-01 2:43
Joaquín M López Muñoz18-Dec-01 2:43 
GeneralRe: DLL Linkage Problem Pin
James Spibey18-Dec-01 3:20
James Spibey18-Dec-01 3:20 
GeneralChange of BackGround Color Pin
San18-Dec-01 1:05
San18-Dec-01 1:05 
GeneralRe: Change of BackGround Color Pin
Rickard Andersson2018-Dec-01 1:53
Rickard Andersson2018-Dec-01 1:53 
GeneralCLSID from interface Pin
Ryszard Krakowiak18-Dec-01 1:01
Ryszard Krakowiak18-Dec-01 1:01 
GeneralRe: CLSID from interface Pin
Ryszard Krakowiak18-Dec-01 1:42
Ryszard Krakowiak18-Dec-01 1:42 
GeneralRe: CLSID from interface Pin
Tim Smith18-Dec-01 2:01
Tim Smith18-Dec-01 2:01 
GeneralPalm OS newcomer... Pin
Braulio Dez17-Dec-01 23:06
Braulio Dez17-Dec-01 23:06 
GeneralRe: Palm OS newcomer... Pin
Nish Nishant17-Dec-01 23:46
sitebuilderNish Nishant17-Dec-01 23:46 
GeneralRe: Palm OS newcomer... Pin
Braulio Dez18-Dec-01 0:27
Braulio Dez18-Dec-01 0:27 
GeneralRe: Palm OS newcomer... Pin
Nish Nishant18-Dec-01 0:33
sitebuilderNish Nishant18-Dec-01 0:33 
GeneralRe: Palm OS newcomer... Pin
Braulio Dez18-Dec-01 0:40
Braulio Dez18-Dec-01 0:40 
GeneralRe: Palm OS newcomer... Pin
Braulio Dez18-Dec-01 2:49
Braulio Dez18-Dec-01 2:49 
GeneralRe: Palm OS newcomer... Pin
Nish Nishant18-Dec-01 16:05
sitebuilderNish Nishant18-Dec-01 16:05 

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.