CButton that does not gain focus? 
Author Message
 CButton that does not gain focus?

I have a CButton objects which gains focus (and hence takes away the
focus from the previous object) when user clicks on it.

How can I stop this? All I want to see is the button to be pressed,
while the main view retains focus so that users dont have to keep
clicking back on the main view (to regain focus on the main view)
everytime he clicks on a button elsewhere.



Tue, 25 Oct 2005 20:16:32 GMT  
 CButton that does not gain focus?

Quote:
> I have a CButton objects which gains focus (and hence takes away the
> focus from the previous object) when user clicks on it.

> How can I stop this? All I want to see is the button to be pressed,
> while the main view retains focus so that users dont have to keep
> clicking back on the main view (to regain focus on the main view)
> everytime he clicks on a button elsewhere.

No promises, but you could try something like the CNoFocusButton
implementation I posted a while back...

http://groups.google.com/groups?q=CNoFocusButton+group:microsoft.publ...

...although that version needs to be modified to call SetState first
thing instead of last thing in the WM_LBUTTONUP handler...

    void CNoFocusButton::OnLButtonUp(UINT nFlags, CPoint point)
    {
        SetState(FALSE);

        if (m_hWnd == ::GetCapture())
        {
            ReleaseCapture();
            CRect rc;
            GetClientRect(&rc);
            if (rc.PtInRect(point))
            {
                if (CWnd* pParent = GetParent())
                {
                    pParent->SendMessage(WM_COMMAND,
                        MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED),
(LPARAM)m_hWnd);
                }
            }
        }
    //    SetState(FALSE);
    }

--
Jeff Partch [VC++ MVP]



Wed, 26 Oct 2005 14:53:01 GMT  
 CButton that does not gain focus?

Quote:
>No promises, but you could try something like the CNoFocusButton
>implementation I posted a while back...

>http://groups.google.com/groups?q=CNoFocusButton+group:microsoft.publ...

>...although that version needs to be modified to call SetState first
>thing instead of last thing in the WM_LBUTTONUP handler...

>    void CNoFocusButton::OnLButtonUp(UINT nFlags, CPoint point)
>    {
>        SetState(FALSE);

>        if (m_hWnd == ::GetCapture())
>        {
>            ReleaseCapture();
>            CRect rc;
>            GetClientRect(&rc);
>            if (rc.PtInRect(point))
>            {
>                if (CWnd* pParent = GetParent())
>                {
>                    pParent->SendMessage(WM_COMMAND,
>                        MAKEWPARAM(GetDlgCtrlID(), BN_CLICKED),
>(LPARAM)m_hWnd);
>                }
>            }
>        }
>    //    SetState(FALSE);
>    }

Ahh so you have to kill focus manually from inside the object. Thank
you, you've given me an idea... (though this was more complicated than
I thought as I thought there was a simple flag or something for this
feature).


Thu, 27 Oct 2005 05:53:02 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. how to make a dialog gain focus

2. Radio button click event being sent when Dialog gains focus

3. Knowing when a dialog gains focus

4. how to make a dialog gain focus

5. Window is blank when it re-gains focus ..

6. Detecting keypress when the focus is on CButton

7. Q1 CButton without focus

8. CButton: focus and default

9. Desktop gains focus and does not give it back for 15 seconds.

10. Why does not CButton::DrawItem work?

11. CButton not sending message>

12. SetCursor for CButton will not work!

 

 
Powered by phpBB® Forum Software