Click here to Skip to main content
16,005,437 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Graphics Library Pin
Cedric Moonen27-Nov-06 20:19
Cedric Moonen27-Nov-06 20:19 
QuestionCFileFind Question Pin
locoone27-Nov-06 17:14
locoone27-Nov-06 17:14 
AnswerRe: CFileFind Question Pin
Mila02527-Nov-06 20:28
Mila02527-Nov-06 20:28 
GeneralRe: CFileFind Question Pin
locoone28-Nov-06 15:26
locoone28-Nov-06 15:26 
GeneralRe: CFileFind Question Pin
Mila02528-Nov-06 20:40
Mila02528-Nov-06 20:40 
GeneralRe: CFileFind Question Pin
locoone29-Nov-06 11:32
locoone29-Nov-06 11:32 
QuestionZIP Using VS2005 ? Pin
Fritzables27-Nov-06 16:49
Fritzables27-Nov-06 16:49 
QuestionCompletely Owner Drawn Window Pin
Ratish Philip27-Nov-06 16:02
Ratish Philip27-Nov-06 16:02 
I want to create a window in which both the Non-Client and the Client are owner-drawn.

I know that I have to handle the WM_NCPAINT and WM_NCACTIVATE messages for Non-client drawing and WM_PAINT message for Client drawing.

For a simple test I added the following code in a Dialog based Application

BOOL COwnDrwDlg::OnNcActivate(BOOL bActive) <br />
{<br />
     if (bActive)<br />
     {<br />
        CRect rect;<br />
        GetWindowRect(&rect);<br />
<br />
        CBrush FB(RGB(0, 80, 0));<br />
        CPaintDC dc(this);<br />
        CBrush* pOld = dc.SelectObject(&FB);<br />
        dc.Rectangle(&rect);<br />
        dc.SelectObject(pOld);<br />
     }<br />
<br />
     return true;<br />
}<br />
<br />
void COwnDrwDlg::OnNcPaint() <br />
{<br />
    CRect rect;<br />
    GetWindowRect(&rect);<br />
<br />
    CString str;<br />
    str.Format(_T("OnNcPaint : Width = %d Height = %d"), rect.Width(), rect.Height());<br />
    TRACE(str);<br />
<br />
    CBrush FB(RGB(0, 80, 0));<br />
    CPaintDC dc(this);<br />
    CBrush* pOld = dc.SelectObject(&FB);<br />
    dc.Rectangle(&rect);<br />
    dc.SelectObject(pOld);<br />
}<br />
<br />
void COwnDrwDlg::OnPaint() <br />
{<br />
    CRect rect;<br />
    GetClientRect(&rect);<br />
		<br />
    if (IsIconic())<br />
    {<br />
	CPaintDC dc(this); // device context for painting<br />
<br />
	SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);<br />
<br />
	// Center icon in client rectangle<br />
	int cxIcon = GetSystemMetrics(SM_CXICON);<br />
	int cyIcon = GetSystemMetrics(SM_CYICON);<br />
	int x = (rect.Width() - cxIcon + 1) / 2;<br />
	int y = (rect.Height() - cyIcon + 1) / 2;<br />
<br />
	// Draw the icon<br />
	dc.DrawIcon(x, y, m_hIcon);<br />
    }<br />
    else<br />
    {<br />
        CBrush FB(RGB(80, 0, 0));<br />
        CPaintDC dc(this);<br />
        CBrush* pOld = dc.SelectObject(&FB);<br />
        dc.Rectangle(&rect);<br />
        dc.SelectObject(pOld);<br />
    }


I thought this much code would result in a window having a green outer rectangle and a dark red inner rectangle, minus the system buttons.

But it did not happen. All I got was captionless grey window.

Where did I go wrong? Where I can get a good documentation regarding painting the non-client area efficiently?




Cutebug Wink | ;-)

AnswerRe: Completely Owner Drawn Window Pin
Steve Echols27-Nov-06 19:39
Steve Echols27-Nov-06 19:39 
QuestionSetItemData/GetItemData Pin
cyn827-Nov-06 15:58
cyn827-Nov-06 15:58 
AnswerRe: SetItemData/GetItemData Pin
Nibu babu thomas27-Nov-06 16:49
Nibu babu thomas27-Nov-06 16:49 
GeneralRe: SetItemData/GetItemData Pin
cyn827-Nov-06 16:59
cyn827-Nov-06 16:59 
GeneralRe: SetItemData/GetItemData Pin
Nibu babu thomas27-Nov-06 17:07
Nibu babu thomas27-Nov-06 17:07 
GeneralRe: SetItemData/GetItemData Pin
Benoy Bose27-Nov-06 17:04
Benoy Bose27-Nov-06 17:04 
GeneralRe: SetItemData/GetItemData Pin
Nishad S27-Nov-06 17:09
Nishad S27-Nov-06 17:09 
GeneralRe: SetItemData/GetItemData Pin
Benoy Bose27-Nov-06 17:22
Benoy Bose27-Nov-06 17:22 
GeneralRe: SetItemData/GetItemData Pin
Nishad S27-Nov-06 17:57
Nishad S27-Nov-06 17:57 
GeneralRe: SetItemData/GetItemData Pin
Naveen27-Nov-06 19:36
Naveen27-Nov-06 19:36 
GeneralRe: SetItemData/GetItemData Pin
Benoy Bose27-Nov-06 21:59
Benoy Bose27-Nov-06 21:59 
QuestionZooming out/in Pin
cyn827-Nov-06 15:53
cyn827-Nov-06 15:53 
QuestionIs there have any faster way to get last row data Pin
vegasoul27-Nov-06 15:51
vegasoul27-Nov-06 15:51 
QuestionText file got encoded in UTF16. (VC2005) Pin
fefe.wyx27-Nov-06 15:37
fefe.wyx27-Nov-06 15:37 
QuestionHow to detect the movement of Joystick? Pin
LaHaHa27-Nov-06 15:26
LaHaHa27-Nov-06 15:26 
Questionhow to use scrolling control Pin
cyn827-Nov-06 15:05
cyn827-Nov-06 15:05 
AnswerRe: how to use scrolling control Pin
Nibu babu thomas27-Nov-06 21:38
Nibu babu thomas27-Nov-06 21:38 

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.