[V8i C++] NETDockableWindow external application

Hello,

I would like to integrate in my application a window external MDI, to be able to dock in Microstation.

I have the handle of the window, and was inspired by the CBNETDockableDialog class.
Aside from a few changes that I had to because my external application was not receiving some events (WM_COMMAND ...), the result is ok.
However, I have a problem with other Microstation's windows, they pass behind Microstation when I moved, or gives them the focus, I must then give focus Microstation to pass the on the top.

If the external window is docked, the problem does not occur.
If the external window is hidden the problem does not occur either

Any idea?
The code below to capture external window :
mdlNativeWindow_createMSWindow(&G_preselForm, m_hWndExternalWindox, FALSE, TRUE, 44444);
DialogHookInterests interests;
memset (&interests, 0xff, sizeof interests);

mdlNativeWindow_getNETDockableWindow (&G_pParent, 56745, _T("External Window"), TRUE, CExternalWindow_SecondaryDialogHook, &interests);
 
mdlNativeWindow_setAsChild( G_preselForm, 0, FALSE);
 
mdlNativeWindow_addToWindowList(G_preselForm);

 m_hHook = ::SetWindowsHookEx( WH_GETMESSAGE, CExternalWindow_GetMsgProc, NULL, GetCurrentThreadId());

mdlNativeWindow_setAsContent(m_hWndExternalWindox, CWnd::FromHandle(m_hWndExternalWindox), G_pParent);
mdlNativeWindow_attachContent(G_pParent, FALSE);
mdlNativeWindow_getNETDockedExtents (G_pParent);
 
 
Regards,
Goubier Sébastien

Parents
  • What do you mean by external application?  Are you creating an in-process DLL or a stand-alone executable?

     
    Regards, Jon Summers
    LA Solutions

  • I create an stand-alone executable, I would like to capture.

    Goubier SĂ©bastien

  • Do you inform MicroStation about your events in window?

    If not, you should... look into implementations of MFC dialogs for MicroStation.

    Native dialog attached to MicroStation must inform it about focusing, commands and so on, so it can manage it.

  • Hello,

    I set a Hook :

    m_hHook = ::SetWindowsHookEx( WH_GETMESSAGE, CExternalWindow_GetMsgProc, NULL, GetCurrentThreadId());

    LRESULT FAR PASCAL CDodWin_GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
        AFX_MANAGE_STATE(AfxGetStaticModuleState());

        LPMSG lpMsg = (LPMSG) lParam;
        CWnd    *pWnd;
        CWnd    *pWndFocus = (CWnd*)mdlNativeWindow_getFocusedContent();

        if (NULL != pWndFocus && pWndFocus->m_hWnd == theApp.m_hWndExternalWindox)
        {
        {
        ULong       messageLow = lpMsg->message & 0xffff;
        if ( nCode >= 0 && PM_REMOVE == wParam && messageLow != WM_CHAR )
        {

            if (WM_MOUSEACTIVATE == lpMsg->message)
            {
                pWndFocus->SetFocus();
                mdlNativeWindow_onSetFocus (G_pParent, 0);
            }
            if ( WM_MOUSEMOVE == lpMsg->message ||
                 WM_LBUTTONDOWN == lpMsg->message ||
                 WM_LBUTTONUP == lpMsg->message ||
                 WM_RBUTTONDOWN == lpMsg->message ||
                 WM_RBUTTONUP == lpMsg->message ||
                 WM_MBUTTONUP == lpMsg->message
               )
            {

                CPoint point;
                point.x = GET_X_LPARAM(lpMsg->lParam);
                point.y = GET_Y_LPARAM(lpMsg->lParam);

                mdlNativeWindow_onMouse(G_pParent, WM_MOUSEMOVE, lpMsg->wParam, point.x, point.y);
            }


            TCHAR       vkey = lpMsg->wParam;

            /* PreTranslate mouse motion messages for tooltips */
            CWinApp * pApp = AfxGetApp();
            if (WM_MOUSEMOVE == lpMsg->message)
            {
                pWndFocus->SendMessage (WM_MOUSEMOVE,lpMsg->wParam,lpMsg->lParam);
            }
            else if(lpMsg->message == WM_COMMAND)
            {
                pWndFocus->SendMessage(WM_COMMAND,lpMsg->wParam,lpMsg->lParam);
            }
            if (WM_KEYFIRST <= messageLow && messageLow <= WM_KEYLAST)
            {
                if (VK_ESCAPE == lpMsg->wParam)
                {
                    mdlNativeWindow_onEscapeKey (G_pParent, lpMsg);
                }
                else if (VK_F1 <= lpMsg->wParam && lpMsg->wParam <= VK_F24)
                {
                    mdlNativeWindow_onFunctionKey (G_preselForm, lpMsg->message, lpMsg->wParam, lpMsg->lParam);
                }
                else if (IsDialogMessage ((HWND) pWndFocus->m_hWnd, lpMsg) != 0)
                {
                    lpMsg->message = WM_NULL;
                    lpMsg->lParam  = 0;
                    lpMsg->wParam  = 0;
                }
            }
        }
        return CallNextHookEx (theApp.m_hHook, nCode, wParam, lParam);
        }
        }
        return 1;
    }

     

     


    And I try also to capture:

    WM_SIZE,WM_SETFOCUS,WM_KILLFOCUS,WM_MOUSEACTIVATE,WM_DESTROY,WM_SYSCOMMAND,WM_MOUSEMOVE... in the main frame of the stand alone exe, and transmit event to Microstation :

    switch(event)

    {

     case WM_SETFOCUS:

         mdlNativeWindow_onSetFocus(G_preselForm, pOldWnd->m_hWnd);

         break;

    case WM_KILLFOCUS:

        mdlNativeWindow_onKillFocus(G_preselForm, pOldWnd->m_hWnd);

        break;

       case WM_MOUSEACTIVATE:
          mdlNativeWindow_onMouseActivate (G_preselForm, nHitTest, message);
           break;

    ....

    }

     

    Rgds,

    Goubier Sébastien

     

     

  • I identify where the problem came.

    My stand alone app has several Childframe.

    I tried to disable them one by one, which has allowed me itentifier chilframe causing the problem
    This ChildFrame use Splitter to Create view :
    BOOL CQueryChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
    {

        // 1 - Create first static splitter
        if(!m_splitterV.CreateStatic(this, 1, 2))    // 1 row, 2 cols
        {
            return FALSE;
        }

        // 2  - Create left column view row 0, col 0 --> RecordView
        if(!m_splitterV.CreateView(0, 0, RUNTIME_CLASS(CRecordQueryView), m_splitterSize, pContext))
        {
            return FALSE;
        }

        // 3 - Create nested static splitter 1 rows, 1 col
        if(!m_splitterH.CreateStatic(&m_splitterV, 2, 1, WS_CHILD | WS_VISIBLE, m_splitterV.IdFromRowCol(0, 1)))
        {
            return FALSE;
        }

        // 4 - Create top-right view row 0, col 0
        if(!m_splitterH.CreateView(0, 0, RUNTIME_CLASS(CListReadView), m_splitterSize, pContext))
        {
            TRACE0("Failed to create top-right view\n");
            return FALSE;
        }

        // 5 - Create bottom-right view row 1, col 0
        if(!m_splitterH.CreateView(1, 0, RUNTIME_CLASS(CImageView), m_splitterSize, pContext))
        {
            return FALSE;
        }
        
        ...
     

    This is this part wich cause problem
  • It's OK, I found the cause of my problem.
    These views were using a Tooltip class that created the CWnd tooltip tooltip with WS_EX_TOPMOST style.

    I removed this style, and now it's ok.

    Goubier Sébastien

    Answer Verified By: sebgoubier 

Reply Children
No Data