|
It is sufficient to comment the message map entries (which should be created too by the wizard).
By the presence of the context menu handler I assumed that you want to use it.
All I can think of is that the NM_RDBLCLK notification is not send by some processing in the default (right mouse button related) MFC CWnd or derivatives handlers.
Another source of not getting the notification might be handling the message in your derived tree control using ON_NOTIFY_REFLECT() . If so, use ON_NOTIFY_REFLECT_EX() instead and return FALSE to get the notification passed to the parent.
|
|
|
|
|
Thank you for your time, Jochen.
No, I am not using any derived CTreeCtrl, so, I cannot use anything than ON_NOTIFY notification.
|
|
|
|
|
Be sure that your CTreeCtrl has the CS_DBLCLKS class style.
Try to handle WM_RBUTTONDBLCLK message.
|
|
|
|
|
I have tried double-click too, not working:
ON_NOTIFY(NM_RDBLCLK, IDC_TREE1, &CTestTreeView::OnNMRDblclkTree1)
ON_NOTIFY(NM_DBLCLK, IDC_TREE1, &CTestTreeView::OnNMDblclkTree1)
void CTestTreeView::OnNMRDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
MessageBox(_T("Right dbl-click"));
*pResult = 0;
}
void CTestTreeView::OnNMDblclkTree1(NMHDR *pNMHDR, LRESULT *pResult)
{
MessageBox(_T("Left dbl-click"));
*pResult = 0;
}
I modified the control style, as follow:
void CTestTreeView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
m_Tree.ModifyStyle(0, CS_DBLCLKS);
ResizeParentToFit();
}
where m_Tree is my CTreeCtrl object.
|
|
|
|
|
_Flaviu wrote:
m_Tree.ModifyStyle(0, CS_DBLCLKS);
No, it won't work!
just because CS_DBLCLKS is not a window style. It is a window class style!
But forget this! Note that double-click in a tree control is used by default to expand/collapse tree items!
So these messages are handled by control itself and therefore you cannot handle them in your code.
|
|
|
|
|
Yes, you are right, I guess this messages (double-click, and right double click) are handled by the control, that is why I cannot catch them. Thank you !
|
|
|
|
|
You could subclass the Tree Control (in your own class derived from CTreeCtrl).
In the derived class implement the ON_NOTIFY_REFLECT_EX macro to handle left/right double click and then pass (or not) this message for the further handling.
|
|
|
|
|
Hi
I have a requirement where i need to display few tabs and render something in only one view instead of creating multiple views for each tab. The reason is i am loading an active x control on that view. So, i written class which inherits from CTabView, but When i call AddView(), each AddView() is creating a new object and i need to load active x control on each view which is violating my requirement and unnecessary memory is getting created.
Is there is any way to create only one view for all the tabs, such that i can create only one view and load active x control on that view and switch the tabs to render different things on one view.?
Currently i am trying with tabbedpane assuming my above requirement will get solved.
Please let me know incase if there is any other option?
modified 13-Mar-18 23:59pm.
|
|
|
|
|
Why do you need multiple tabs in the first place? It sounds like you just want your view to render different data based on some external setting or user selection.
|
|
|
|
|
I have some drawings to display.
For Eg: I have a drawing file which internally contains 5 sub drawings in it. So based on no. of sub drawings, i have to create 5 tabs. In each tab each sub drawing should get render. But user is allowed to view only one sub drawing at a time i.e., the active tab drawing. Thats the reason why i need to create tabs.
When i click on first tab, first sub drawing will be displayed. if second tab is selected then second sub drawing should be displayed. like wise rest of the drawing when user selects the tab.
|
|
|
|
|
According to your original question your requirement is to have only a single View, so you do not need multiple tabs. You just need to render the appropriate drawing when the user makes a choice.
|
|
|
|
|
Yes exactly. I need only one view. But the User interaction should be on tabs. To be more precise, i need the UI in the form of tabs but the view should be only one.
But when i call Addview(), each time a new view is getting created.
|
|
|
|
|
Sampath579 wrote: But when i call Addview(), each time a new view is getting created. You need to show your code; it is difficult to guess what you are doing.
|
|
|
|
|
class MyMainClass : public CTabView
{
int OnCreate(LPCREATESTRUCT lpCreateStruct);
};
int MyMainClass::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CTabView::OnCreate(lpCreateStruct) == -1)
return -1;
AddView(RUNTIME_CLASS(CDrawingView), _T("Tab1"));
AddView(RUNTIME_CLASS(CDrawingView), _T("Tab2"));
}
class CDrawingView : public CScrollView
{
/.... rendering logic.
}
So, each time i call AddView() the CDrawingView class is getting instantiated and new view is getting created. Instead only one view should be available and new tabs should get created.
|
|
|
|
|
The whole point of using AddView is to add a new View to the tab group. The documentation (CTabView::AddView[^])
makes it clear that it creates a new View for each call. If you want a single View then you will need to find an alternative to the CTabView control.
|
|
|
|
|
Yes. I am looking into that feature and could not get any such behavior and posted it here.
|
|
|
|
|
Then don't call AddView!
Instead try to operate the CMFCTabCtrl class (or some of its base ones) to add/remove/change tabs and "on-change-tab" just display the only one view you have.
|
|
|
|
|
ok. How can it solve my problem.
class MyMainClass : public CScrollView
{
int OnCreate(LPCREATESTRUCT lpCreateStruct);
}
int MyMainClass::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CScrollView::OnCreate(lpCreateStruct) == -1)
return -1;
if (!tab.Create(CMFCTabCtrl::STYLE_FLAT, CRect(0,0,100,100), this, 1))
{
TRACE0("Failed to create output tab window\n");
return -1;
}
tab.AddTab(this, _T("tab1"),101);
tab.AddTab(this, _T("tab1"),102);
return 0;
}
Above piece of code created a tabcontrol with 2 tabs on it. But with out some view on this window how can i render some thing.
sorry if i miss anything to create view. Do i need to inherit my class from CMFCtabCtrl or is it ok even if i inherit from CScrollView?
Also when i select the second tab, my application is getting hanged. What could be the reason?
Edit 2:
I have gone through some examples and understood that, "this" in below call created issues.
tab.AddTab(this, _T("tab1"),101)
instead of this, we need to provide the control we are going to add to that tab control. For eg;
CEdit edit;
we need to give &edit instead of this. I saw this in microsoft samples.
This also does not solve my problem. In case if i have 3 tabs, then i need to create 3 CViews and add them to tabcontrol. Again this is like kind of creating new view for each tab.
But i want only one view and different tabs.
modified 13-Mar-18 13:32pm.
|
|
|
|
|
Sampath579 wrote: I have gone through some examples and understood that, "this" in below call created issues.
tab.AddTab(this, _T("tab1"),101)
instead of this, we need to provide the control we are going to add to that tab control
Did you try to provide the same View for all created tabs?
|
|
|
|
|
I tried with CEdit as per the example in msdn. But instead of CEdit i need CView. If i declare
CView m_windView; //throwing error since it contains virtual functions and we need to implement them.
|
|
|
|
|
Which class should i take in order to display my drawings in the view. I tried with CView and CScrollView. Both the classes contains virtual functions and it showing error. I need a view where mouse down , mouse up, mouse wheel should work on it.
Any suggestions please.
|
|
|
|
|
How to load a CView in tab which is created using CMFCTabCtrl.
|
|
|
|
|
Then i created CMFCTabCtl and created a tab control. Next, how to add a CView to tabs? I saw samples like how to add a CEdit control to tab but dint get any clue on how to add CView to tabs?
If i can add a Cview to tabs then my problem would be solved. I can add same CView to all the tabs and finally i will end up with one view and mutliple tabs which is my requirement.
|
|
|
|
|
Victor,
May i know how can know whether user selected different tabs? I mean my function should know when user selects different tabs, based on that i can refresh my single view. ?
|
|
|
|
|