GrapeCity Forums

The GrapeCity Message Boards
Welcome to GrapeCity Forums Sign in | Join | Help
in Search

Cannot set focus on spread control via SetFocus...

Last post 12-17-2004, 4:21 PM by sdodd. 3 replies.
Sort Posts: Previous Next
  •  12-10-2004, 12:43 PM 14684

    Cannot set focus on spread control via SetFocus...

    We're embedding the spread control in an MFC view; we have found that when the user re-activates the spread-view, the embedded control will not take focus.  That is, when the view is re-activated, the control does not take focus, even when specifically asked to.

    We are overriding CView::OnActivateView like so:

    void CSheetView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView)
    {
        CInfoView::OnActivateView(bActivate, pActivateView, pDeactiveView);

        if ( bActivate )
        {
            m_SSWnd.SetFocus();
        }
    }

    Any idea what we're doing wrong?
  •  12-10-2004, 2:50 PM 14692 in reply to 14684

    Re: Cannot set focus on spread control via SetFocus...

    Hello,

    It sounds like when you have an ActiveX control in a CView, like this, calling the Focus methos is not activating the ActiveX control. You would probably see the same problem with any ActiveX control you use. I would suggest contacting the Microsoft group for a function call you can make to activate an ActiveX control.


    Scott S.
    Product Manager, Spread ASP.NET
    GrapeCity FarPoint
  •  12-17-2004, 4:11 PM 14938 in reply to 14692

    Re: Cannot set focus on spread control via SetFocus...

    We are migrating from the use of Formula 1's ActiveX spreadsheet control to the FarPoint Spread ActiveX control.  We embed the Formula 1 control in a CView and use SetFocus on the control to give it focus when the view is activated, just like in my example code.  And it works.  So I don't think that it is a general ActiveX control problem - it is something specific to the FarPoint Spread control.

    If you could provide a sample program that embeds your control in a CView, and properly assigns keyboard focus to the control when the user Alt-Tabs back to the program, that would be much appreciated as it would help us find what the problem is...

    Thanks

    Steve
  •  12-17-2004, 4:21 PM 14939 in reply to 14938

    Re: Cannot set focus on spread control via SetFocus...

    I think I figured out the problem.  It seems that calling the CWnd::SetFocus method on the FarPoint Spread control's wrapper  doesn't work, but calling ::SetFocus( controlWnd.GetSafeHwnd() ) does!  (Any idea why?)

    After figuring that out, I also found that overriding the CView's OnSetFocus handler is neccessary for some situations as well:

    CMyView::OnSetFocus( CWnd * p )
    {
        CParentView::OnSetFocus( p );
        ::SetFocus( m_pFarPointSpreadWnd->GetSafeHwnd() );
    }

    Thanks

    Steve
View as RSS news feed in XML
     FarPoint Forums Home