In the above code, when i click on button, OnButtonSelect() is not getting called even i added the button notification message in Message Map. After investigation i understood, the Base class mentioned in Message map and my class is from CScrollView and it cannot inherit the button features.
If this is true, how can i access the button message in my function.
I want to create the buttons in runtime and want to do some operation based on the button click.
Is it possible to notify in case if my class is derived from CScrollView?
Hey, Many thanks. It was working fine if i give this as window in CButton Create. But on my window i am loading active x control and hence i am giving active x control object so that it will always render on top of the window.
If i give "this", the button will be visible, once i load the active x control, the control will be on top and button will go back and thats the reason i gave active x control object instead of "this"
I will investigate like how to render it on top of active x control window, by creating it on "this" window.
Even i gave the style of my button as push_button, why it appears as flat one without any push behavior. I added the button to the main window by this. I dint even loaded the active x control but even then it looks like flat button. Even i click on that button there is no depth i can see on it, there is no response from the button.
for (int i = 0; i < 1; i++)
m_button[i].Create(_T("Hi"), BS_PUSHBUTTON | WS_CHILD, CRect(0, 250, 120, 300), this, 101);
My class is derived from CTabView. I dint added any view yet. Just on that window i created this button at the bottom , i mean on the tab control bar to simulate it as a tab.
My class is just derived from CTabView. I dint add any view or functionality except adding a button. Even though they are different, during button creation i gave "this" (which one does it refer? tab control or TabView) as the parent window. If "this" refers to tabcontrol then it should behave normally. right? Even i want to add button on TabControl bar itself but not on view.
You can see my window with tab control and the look of the button in below link. I just created a class which inherits from CTabView which created a window with tabcontrol and added a code to create a button at bottom of the window. But the button does not look like push button.
Instead of inheriting a class from CTabview, this time i inherited from CScrollView and created a button on it which you can see in below link. This button perfectly looks like pushbutton and when i click on the button, there is some interaction i can see, i.e., button movement in and out. You can even observe a border on this button since i clicked on it.
I created a class which inherits from CTabView as follows:
class CTabClass : public CTabView
m_CView = RUNTIME_CLASS(CDocumentView);
AddView(m_CView,_T("Tab2")); //this creating 2nd tab but throwing assertions and //finally crashing while accessing it.
I want only one view for all the tabs. Is it possible in MFC?
How many more times do you plan to repost this question? We have explained why this will not do what you want, and given some suggestions for finding an alternative approach. Please try some of those suggestions for yourself.
Yes, it could work, but not like you tried above ... think that m_CView is the same CView instance on every tab, which is impossible ... but you can try to create a new instance on every AddView call, something like that:
this is simplistic approach, that I wrote it just you see the point, but in a real situation, you have to elaborate this: create any instance of CYourView object you need, add every one of them in an array of pointers, and supply this pointers on AddView call as first argument. Do you understand what I say ?
And the solution that I just give you is more as you see why your approach is not working than to be applied in your application ... because the creation of your CYourView is not that simple ... they must be attached at you CDocument, and so on ...
Because you have problems in completing your task, this reveal that your approach is not right ... you have to think to another ...
Based on user selection, the graphics on the CView should change. On this CView i will load some Active X control to render the graphics on this window.
If i create multiple CViews with new object, then i have to load the Active X Control on each CView which is a costly operation and memory increases and it not a good way to deal as there are many issues with memory, performance and other areas in my application.
Thats why i want multiple tabs with one single view to solve my issue.