Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to set focus on ActiveX control in CMDIChildWnd ?

How to set focus on ActiveX control in CMDIChildWnd ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestioncomdesign
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vipsy
    wrote on last edited by
    #1

    It looks like a very simple question, but I stuck with it ! I have the selfwritten ATL ActiveX. Then I wanted to place it inside the MFC window such as CMDIChildWnd to fill the entire client area. The only thing I want is that my ActiveX can get focus when the hosting window is activated. So I put the following code: void CMyFrame::OnSetFocus(CWnd* pOldWnd) { if (m_pView!=NULL) m_pView->SetFocus(); else CMDIChildWnd::OnSetFocus(pOldWnd); } where the CMyFrame is frame derived from CMDIChildWnd, m_pView - my ActiveX pointer. It has a type of pointer to the ActiveX CWnd_wrapper created by the VC7 wizard "MFC Class from ActiveX control". The problem is that my control gets focus only once - the first time the hosting window is activated. I've tested my ActiveX in the simple dialog window - all is ok... The ActiveX is created as: int CMyFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { m_pView = new CMyControl; if (m_pView!=NULL) { CRect rect(0,0,0,0); m_pView->Create(NULL,WS_CHILD | WS_VISIBLE | WS_TABSTOP,rect,this,1); // "this" - is a parent CMDIChildWnd ... Does anybody has an idea ? Thank you very much P.S. Actually I know the reason of that :) I separated my message in two parts: If I do something completly wrong, then you will see it from the first part - please tell me if its so :) Now the details: m_pView->SetFocus() actually does the DoVerb(OLEIVERB_UIACTIVATE) i.e. activates my ActiveX UI. This is done internally by the COleControlSite::SetFocus. The problem is that default implementation of COleControlSite ignores OnFocus(FALSE) event that comes from my ActiveX when it loses the focus. COleControlSite does not call UIDeactivate upon this event. Since my control was once OLEIVERB_UIACTIVATEed and was not UIDeactivated it ignored the next DoVerb(OLEIVERB_UIACTIVATE) though it losts the focus (the ATL implementation). I cannot modify this code since its in the ATL & MFC...

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups