Click here to Skip to main content
15,895,777 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: ActiveX Pin
KarstenK16-Apr-09 4:35
mveKarstenK16-Apr-09 4:35 
QuestionSendMessage in VS 2008 Pin
CString(0xcccccccc)15-Apr-09 7:41
CString(0xcccccccc)15-Apr-09 7:41 
AnswerRe: SendMessage in VS 2008 Pin
Stuart Dootson15-Apr-09 9:43
professionalStuart Dootson15-Apr-09 9:43 
GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)15-Apr-09 12:48
CString(0xcccccccc)15-Apr-09 12:48 
GeneralRe: SendMessage in VS 2008 Pin
Stuart Dootson15-Apr-09 15:33
professionalStuart Dootson15-Apr-09 15:33 
GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)15-Apr-09 21:31
CString(0xcccccccc)15-Apr-09 21:31 
GeneralRe: SendMessage in VS 2008 Pin
Stuart Dootson15-Apr-09 22:30
professionalStuart Dootson15-Apr-09 22:30 
GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)16-Apr-09 11:38
CString(0xcccccccc)16-Apr-09 11:38 
It's not the first time I see that article of Paul DiLascia. His ideeas are nice, just one problem they don't work in my implementation. Anyway, there's something wrong with the article, the author wonders about the undocumented wParam = 1 (in WM_NCPAINT), while the MSDN clearly states it stands for "entire NC area needs repainting".

As about your code, first of all thank you for your effort.
Basically you're doing what I'm doing, just my code doesn't work.

Did you test it with VS 2008 ?

I tried to browse the MFC sources, it's a brand new world, there's no more WindowProc with message loop. Lots of ATL code.

My code follows:
void CMainFrame::OnNcPaint()
{
	const MSG* pMsg = GetCurrentMessage();

	CRgn rgnWnd, rgnCli, rgnMenu;
	int iMenuHeight = GetSystemMetrics(SM_CYMENU); //height of the menu bar

	// Compute the NC region as a difference between the window rect and client rect.
	// The region must be relative to top left corner of the window
	CRect rcWnd, rcCli;
	// Get the window rect (relative to the top-left corner of the window)
	GetWindowRect(&rcWnd);
	CPoint ptOffset = - rcWnd.TopLeft();
	rcWnd.OffsetRect(ptOffset);

	// Get the client rect (relative to the top-left corner of the window)
	GetClientRect(&rcCli);
	ClientToScreen(rcCli);
	rcCli.OffsetRect(ptOffset);
	
	// Include de menu bar in the client area
	rcCli.top -= iMenuHeight;

	// Create regions for the window rect and client rect
	rgnWnd.CreateRectRgn(rcWnd.left, rcWnd.top ,rcWnd.right ,rcWnd.bottom);
	rgnCli.CreateRectRgn(rcCli.left, rcCli.top ,rcCli.right ,rcCli.bottom);
	
	// Obtain their difference (that will be the entire non client area without the menu bar)
	rgnWnd.CombineRgn(&rgnWnd, &rgnCli, RGN_DIFF);

	// Create a region for the menu bar
	rgnMenu.CreateRectRgn(rcCli.left, rcCli.top, rcCli.right, rcCli.top + iMenuHeight);

	if(pMsg->wParam != 1) // Is only a part of the nc area requiring repaint ?
	{ // If it's so:
		// Get the region requiring painting:
		CRgn r;
		r.CreateRectRgn(0,0,0,0);
		r.CopyRgn(CRgn::FromHandle((HRGN) pMsg->wParam));
		r.OffsetRgn(ptOffset); // Screen coordinates need to be transformed to window coordinates
		
		// Intersect with the NC area without the menu bar:
		rgnWnd.CombineRgn(&rgnWnd, &r, RGN_AND);
		
		// Intersect with the menu bar:
		rgnMenu.CombineRgn(&rgnMenu, &r, RGN_AND);
	}

	// Paint the nonclient area without the menu bar:
	CWindowDC dc(this);
	CBrush brush;
	brush.CreateSolidBrush(RGB( 255, 0, 0 ));
	dc.FillRgn(&rgnWnd, &brush);

	// Paint the menu bar:
	CRect rcBox;
	rgnMenu.GetRgnBox(&rcBox);
	if(!rcBox.IsRectEmpty()) // Make sure the region is not empty
		::DefWindowProc(m_hWnd, WM_NCPAINT, (WPARAM) rgnMenu.m_hObject, 0); // has no effect
}

GeneralRe: SendMessage in VS 2008 Pin
Stuart Dootson16-Apr-09 13:46
professionalStuart Dootson16-Apr-09 13:46 
GeneralRe: SendMessage in VS 2008 Pin
CString(0xcccccccc)16-Apr-09 22:16
CString(0xcccccccc)16-Apr-09 22:16 
Questioncreating tooltip that follows cusor, to display coordinates. Pin
soongez15-Apr-09 6:21
soongez15-Apr-09 6:21 
AnswerRe: creating tooltip that follows cusor, to display coordinates. Pin
Stuart Dootson15-Apr-09 9:40
professionalStuart Dootson15-Apr-09 9:40 
QuestionRe: creating tooltip that follows cusor, to display coordinates. Pin
Maximilien15-Apr-09 10:06
Maximilien15-Apr-09 10:06 
AnswerRe: creating tooltip that follows cusor, to display coordinates. Pin
soongez15-Apr-09 15:19
soongez15-Apr-09 15:19 
AnswerRe: creating tooltip that follows cusor, to display coordinates. Pin
Rolf Kristensen15-Apr-09 20:49
Rolf Kristensen15-Apr-09 20:49 
QuestionDate Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 4:09
Don Jones BNYMellon15-Apr-09 4:09 
AnswerRe: Date Picker Control - Need to switch from British to American Format. Pin
led mike15-Apr-09 4:18
led mike15-Apr-09 4:18 
GeneralRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 4:59
Don Jones BNYMellon15-Apr-09 4:59 
QuestionRe: Date Picker Control - Need to switch from British to American Format. Pin
David Crow15-Apr-09 5:57
David Crow15-Apr-09 5:57 
AnswerRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 7:36
Don Jones BNYMellon15-Apr-09 7:36 
QuestionRe: Date Picker Control - Need to switch from British to American Format. Pin
David Crow15-Apr-09 7:39
David Crow15-Apr-09 7:39 
AnswerRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 8:00
Don Jones BNYMellon15-Apr-09 8:00 
GeneralRe: Date Picker Control - Need to switch from British to American Format. Pin
Don Jones BNYMellon15-Apr-09 8:17
Don Jones BNYMellon15-Apr-09 8:17 
GeneralRe: Date Picker Control - Need to switch from British to American Format. Pin
David Crow15-Apr-09 9:15
David Crow15-Apr-09 9:15 
Questionhow to get the linux kernel version in cpp program Pin
scamguru15-Apr-09 3:09
scamguru15-Apr-09 3:09 

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.