MDI focus problem

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi everyone,

I have a standard MFC MDI app. I have a bunch of views open at the same
time. I want to draw a hilite box around the view that has focus at the
moment. But I'm not sure how to do this since I seem to be receiving my
messages wrong. I though for starters I could just do this in the view
class:

void CMyView::OnLButtonDown()
{
::SendMessage(this->GetSafeHwnd(), WM_SETFOCUS, 0, 0);
}

void CMyView::OnSetFocus()
{
this->m_bFocus = true;
this->Invalidate(); // draw focus box around me now.
}

void CMyView::OnKillFocus()
{
this->m_bFocus = false;
this->Invalidate(); // erase focus box around me now.
}

Yeah but it seems like if I click the title bar of the view it fails
miserably. What messages should I handle so I don't end up with 5
'focused' views at once, or none at all?

Thanks

.


Quantcast