Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/articles/cpp-tutorials/)
-   -   Custom Image Button (http://www.go4expert.com/articles/custom-image-button-t7580/)

Skezza 4Jul2012 14:58

Re: 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?

Cheers

Skezza 4Jul2012 15:01

Re: Custom Image Button
 
For those who aren't sure, comment out the line and try again.


All times are GMT +5.5. The time now is 02:52.