Custom Image Button

Hello,
I know this thread is 2 years old but I was sent the link by a colleague who is learning WinCE 6 development. He was having problems using more than one CGuiButton. They were disappearing rather inexplicably. For example, pressing on one, then another would remove the bitmap from the first button.

I ran through the code on my lunch break at work and have found the cause:

Code:

void CGuiButton::OnKillFocus(CWnd* pNewWnd)
{
this->Invalidate();
}

line 139 of GuiButton.cpp : this->Invalidate(); is unnecessary in my opinion.

My own experience is fairly middle of the road, but I just wondered why it was there? I cannot see a reason to call Invalidate() on the CGuiButton on kill focus. The only reason to call Invalidate is if the region needs repainting, but for a Bitmap button, I can't see when this would be the case.
Rather than say this fixes it (it does in my case) I was wondering if you could explain why it was there in the first place as I'm sure it isn't there for nothing?