コード例 #1
0
ファイル: MsgSgTreeView.cpp プロジェクト: cfz/busmaster
/**
 * \brief Add Edit Message
 *
 * Displays message detials dialog to add new message
 * or edit selecetd message base on the parameter passed.
 */
void CMsgSgTreeView::vAddEditMessage(BOOL bMode)
{
    CMsgSignal* pTempMsgSg = NULL;
    CMsgSgDetView* pMsgSgDetView = NULL;
    pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);
    sMESSAGE* pMsg =    NULL;

    // For Edit mode
    if ( bMode == TRUE )
    {
        CTreeCtrl& omTree = GetTreeCtrl();
        HTREEITEM hItem =
            omTree.GetSelectedItem();

        if (hItem != NULL)
        {
            CString omStr = omTree.GetItemText(hItem);
            pMsg =
                pTempMsgSg->psGetMessagePointerInactive( omStr );
        }
    }

    // End Edit mode
    CMessageDetailsDlg odMsgDlg(m_sDbParams, pMsg,NULL);

    if (odMsgDlg.DoModal() == IDOK )
    {
        vSetMessageName(odMsgDlg.m_omStrMessageName);
        vSetTextBold();
        // Get message pointer
        sMESSAGE* pMsg =
            pTempMsgSg->psGetMessagePointerInactive(odMsgDlg.m_omStrMessageName);
        CMainFrame* pMainFrm = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

        if ( pMainFrm != NULL )
        {
            pMsgSgDetView =
                pMainFrm->podGetMsgSgDetView(m_sDbParams.m_eBus);

            if ( pMsg != NULL && pMsgSgDetView != NULL )
            {
                // check if the controls in the form view are hidden
                if ( pMsgSgDetView->bGetControlStatus() == TRUE )//  TRUE - Hidden
                {
                    // Controls are hidden, unhide
                    pMsgSgDetView->vHideControls(SW_SHOW);
                }

                pMsgSgDetView->vDisplayMsgSgInformation( pMsg );
            }
        }
    }
}
コード例 #2
0
ファイル: MsgSgTreeView.cpp プロジェクト: cfz/busmaster
/**
 * \brief On Selection Change
 *
 * Called by the frame work when an item selection is
 * changed. Updates message information on the right pane
 * depending on the selected item
 */
void CMsgSgTreeView::OnSelchanged(NMHDR* pNMHDR, LRESULT* pResult)
{
    NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
    // TODO: Add your control notification handler code here
    *pResult = 0;
    // check if any data in the form view
    // is missing. If yes,
    // don't let the user to select any item
    // from the tree view
    CMsgSgDetView* pMsgSgDetView = NULL;
    CTreeCtrl& om_tree = GetTreeCtrl();
    sMESSAGE* pMsg = NULL;
    CMsgSignal* pTempMsgSg = NULL;
    pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);
    CMainFrame* pMainFrm = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

    if ( pMainFrm != NULL )
    {
        pMsgSgDetView =
            pMainFrm->podGetMsgSgDetView(m_sDbParams.m_eBus);

        if ( pMsgSgDetView != NULL)
        {
            if ( pMsgSgDetView->bGetControlStatus() == FALSE )//  TRUE - Hidden
            {
                if (pMsgSgDetView->
                        GetDlgItem(IDC_EDIT_MSG_NAME)->
                        GetWindowTextLength() == 0 )
                {
                    pMsgSgDetView->m_omStrMessageName
                        = m_omSelectedItemText;
                    om_tree.SetItemText( m_hTreeItem,m_omSelectedItemText );
                    pMsgSgDetView->UpdateData(TRUE);
                }

                if ( pMsgSgDetView->
                        GetDlgItem(IDC_EDIT_MSGCODE)->
                        GetWindowTextLength() == 0 )
                {
                    pMsg = pTempMsgSg->psGetMessagePointerInactive(
                               pMsgSgDetView->m_omStrMessageName );

                    if (pMsg != NULL)
                        pMsgSgDetView->m_omStrMessageCode.
                        Format( "%x", pMsg->m_unMessageCode);

                    pMsgSgDetView->UpdateData(TRUE);
                }
            }
        }
    }

    // Get handle to selected item
    HTREEITEM hSelectedItem = pNMTreeView->itemNew.hItem;

    if ( (hSelectedItem != NULL) && (pMsgSgDetView != NULL) )
    {
        if ( !om_tree.ItemHasChildren(hSelectedItem))// only for message names
        {
            CString omStrMsgName = om_tree.GetItemText( hSelectedItem );
            m_omSelectedItemText = omStrMsgName;
            // Get message pointer from the data structure
            // corresponding to the message selected name
            sMESSAGE* pMsg =
                pTempMsgSg->psGetMessagePointerInactive( omStrMsgName );

            if ( pMsg != NULL )
            {
                // check if the controls in the form view are hidden
                if ( pMsgSgDetView->bGetControlStatus() == TRUE )//  TRUE - Hidden
                {
                    // Controls are hidden, unhide
                    pMsgSgDetView->vHideControls(SW_SHOW);
                }

                // Fill the msg signals details for this message
                pMsgSgDetView->vDisplayMsgSgInformation( pMsg );
            }
        }
        else
        {
            // Item is root
            // Hide all controls
            pMsgSgDetView->vHideControls(SW_HIDE);
        }
    }
}
コード例 #3
0
ファイル: MsgSgTreeView.cpp プロジェクト: cfz/busmaster
/**
 * \brief On Right Click Tree Item
 *
 * Displays pop up menu depending on the selected item
 */
void CMsgSgTreeView::OnRightClickTreeItem(NMHDR* /*pNMHDR*/, LRESULT* pResult)
{
    UINT uFlags = 0;
    CTreeCtrl& om_Tree = GetTreeCtrl();
    CMenu* m_pomContextMenu = new CMenu;
    HTREEITEM hSelectedItem = om_Tree.HitTest( m_omRightClickPoint, &uFlags );
    CMsgSgDetView* pMsgSgDetView = NULL;
    sMESSAGE* pMsg = NULL;
    CMainFrame* pMainFrm = static_cast<CMainFrame*> (AfxGetApp()->m_pMainWnd);

    if ( pMainFrm != NULL )
    {
        pMsgSgDetView =
            pMainFrm->podGetMsgSgDetView(m_sDbParams.m_eBus);
    }

    if ( uFlags != TVHT_ONITEMICON && uFlags != TVHT_ONITEMLABEL )
    {
        hSelectedItem = NULL ;
    }
    else
    {
        om_Tree.SelectItem( hSelectedItem );
        // Display the selected message details in the
        // right view
        CMsgSignal* pTempMsgSg = NULL;
        pTempMsgSg = *((CMsgSignal**)m_sDbParams.m_ppvActiveDB);

        if ( !om_Tree.ItemHasChildren(hSelectedItem))// only for message names
        {
            CString omStrMsgName = om_Tree.GetItemText( hSelectedItem );
            m_omSelectedItemText = omStrMsgName;

            // Get message pointer from the data structure
            // corresponding to the message selected name
            if ( pMsgSgDetView != NULL )
            {
                pMsg =
                    pTempMsgSg->psGetMessagePointerInactive( omStrMsgName );
            }

            if ( pMsg != NULL )
            {
                // check if the controls in the form view are hidden
                if ( pMsgSgDetView->bGetControlStatus() == TRUE )//  TRUE - Hidden
                {
                    // Controls are hidden, unhide
                    pMsgSgDetView->vHideControls(SW_SHOW);
                }

                // Fill the msg signals details for this message
                pMsgSgDetView->vDisplayMsgSgInformation( pMsg );
            }
        }
        else
        {
            // Item is root
            // Hide all controls
            pMsgSgDetView->vHideControls(SW_HIDE);
        }

        // Get the parent of selected item to identify
        // whether it is a Message name or the root
        HTREEITEM hParentItem = om_Tree.GetParentItem( hSelectedItem );
        // Load the Menu from the resource
        m_pomContextMenu->DestroyMenu();
        m_pomContextMenu->LoadMenu(IDM_MSG_OPN_MENU);
        CMenu* pomSubMenu = m_pomContextMenu->GetSubMenu(0);

        if ( hParentItem == NULL && m_pomContextMenu != NULL ) // Selected item corresponds to root
        {
            pomSubMenu->EnableMenuItem(IDM_NEW_MSG, MF_BYCOMMAND | MF_ENABLED   );
            pomSubMenu->EnableMenuItem(IDM_DELETE_MSG, MF_BYCOMMAND | MF_DISABLED |MF_GRAYED );
            pomSubMenu->EnableMenuItem(IDM_EDIT_MSG, MF_BYCOMMAND | MF_DISABLED |MF_GRAYED );
        }
        else
        {
            pomSubMenu->EnableMenuItem(IDM_NEW_MSG, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
            pomSubMenu->EnableMenuItem(IDM_DELETE_MSG, MF_BYCOMMAND | MF_ENABLED);
            pomSubMenu->EnableMenuItem(IDM_EDIT_MSG, MF_BYCOMMAND | MF_ENABLED);
        }

        ClientToScreen(&m_omRightClickPoint);
        pomSubMenu->TrackPopupMenu( TPM_LEFTALIGN |TPM_RIGHTBUTTON,
                                    m_omRightClickPoint.x,
                                    m_omRightClickPoint.y,
                                    this,
                                    NULL);
    }

    if (m_pomContextMenu != NULL )
    {
        delete m_pomContextMenu;
    }

    *pResult = 0;
}