Problem with OnContextMenu and CTreeCtrl
Sanjay -- SGUPTA@aegonusa.com Monday, April 22, 1996 OS: Win 95 VC++4.0 I am trying to create a dialog bar which behaves in a manner similar to dialog bar in VC++ 4.0 developer studio - the dialog bar which contains tabs for class view, resource view etc. This is what I did to create the dialog bar: I created the dialog template for the dialog bar. Derivved a class from CDialogBar as CMyDialogBar : public CDialogBar. In OnCreate for Mainframe, I create an object of type CMyDialogBar with template ID the one ICreated. I override the Create function for CMyDialogBar. If Create returns fine, I create four bitmap buttons which look like bitmaps. Bitmap buttons are members of CMyDialogBar. Also, I derived a class from CTreeCtrl as CFormsTree : public CMyTree. In the Create function for CMyDialogBar, I also create the object for CMyTree. In OnCreate for CMyTree, I fill the tree with info. Now, to bring the CMyDialogBar in command message routing, I override OnCmdMsg in my app classs, where I call OnCmdMsg for the dialog class first, if the message is not handled there, I pass the message along. I want the popup menu to be handeled by the CFormsTree class itself, so I added the popup context menu using component gallery to CFormsTree class. Now the problem is that when I click right mouse button in the tree control, popup menu soes not come up - I used spy++ to find out that the message is going to parent which inthis case is CMyDialogBar. If I double click with the right mouse button, then the message comes to tree control and pop up menu is displayed. I wonder if I have to reflect the message back from the parent to the child. I will greatly appreciate any help on this. Sanjay sgupta@aegonusa.com
Klaus Guetter -- 100031.1400@CompuServe.COM Thursday, April 25, 1996 This is how I solved the same problem fort a CTreeView inside a MDI child frame. void CMyMDIChildFrame::OnContextMenu(CWnd* pWnd, CPoint point) { if (m_bLockOutMsg) { // Prevent infinite loop TRACE0("WM_CONTEXTMENU locked out\n"); return; } if ((pWnd->GetStyle() & WS_CHILD) != 0 && pWnd->GetParent() == this) { // First reflect to the control (using the message map) m_bLockOutMsg = TRUE; AfxCallWndProc(pWnd, pWnd->m_hWnd, WM_CONTEXTMENU, (UINT)pWnd, MAKELPARAM(point.x, point.y)); m_bLockOutMsg = FALSE; } Default(); } - Klaus
Sanjay -- SGUPTA@aegonusa.com Thursday, April 25, 1996 OS: Win 95 VC++4.0 I am trying to create a dialog bar which behaves in a manner similar to dialog bar in VC++ 4.0 developer studio - the dialog bar which contains tabs for class view, resource view etc. This is what I did to create the dialog bar: I created the dialog template for the dialog bar. Derivved a class from CDialogBar as CMyDialogBar : public CDialogBar. In OnCreate for Mainframe, I create an object of type CMyDialogBar with template ID the one ICreated. I override the Create function for CMyDialogBar. If Create returns fine, I create four bitmap buttons which look like bitmaps. Bitmap buttons are members of CMyDialogBar. Also, I derived a class from CTreeCtrl as CFormsTree : public CMyTree. In the Create function for CMyDialogBar, I also create the object for CMyTree. In OnCreate for CMyTree, I fill the tree with info. Now, to bring the CMyDialogBar in command message routing, I override OnCmdMsg in my app classs, where I call OnCmdMsg for the dialog class first, if the message is not handled there, I pass the message along. I want the popup menu to be handeled by the CFormsTree class itself, so I added the popup context menu using component gallery to CFormsTree class. Now the problem is that when I click right mouse button in the tree control, popup menu soes not come up - I used spy++ to find out that the message is going to parent which inthis case is CMyDialogBar. If I double click with the right mouse button, then the message comes to tree control and pop up menu is displayed. I wonder if I have to reflect the message back from the parent to the child. I will greatly appreciate any help on this. Sanjay sgupta@aegonusa.com
| Вернуться в корень Архива |