|
You can pass in a pointer to CMyView as parameter to SetActiveView .
You will have to store pointers to the views that you have created.
|
|
|
|
|
I am using below code for creating view.
now where i have to store the view pointer.
POSITION curTemplatePos = AfxGetApp()->GetFirstDocTemplatePosition();
while(curTemplatePos != NULL)
{
CDocTemplate* curTemplate =
AfxGetApp()->GetNextDocTemplate(curTemplatePos);
curTemplate->GetDocString(Str, CDocTemplate::docName);
if(Str==ViewType)
{
Res = curTemplate->OpenDocumentFile(NULL);
if(Res==NULL)
{
MessageBox("Error creating view\t",ViewType, MB_ICONSTOP);
return FALSE;
}
break;
}
}
CMDIChildWnd* Chi = MDIGetActive();
|
|
|
|
|
Each document template holds all open documents of its type.
POSITION p = GetFirstDocTemplatePosition();
while (p != NULL)
{
CDocTemplate* pTempl = GetNextDocTemplate(p);
POSITION pdoc = pTempl->GetFirstDocPosition();
while (pdoc != NULL)
{
CMyDoc *pDoc = static_cast<CMyDoc*>(pTempl->GetNextDoc(pdoc));
}
}
And each document contains a list of its views
POSITION viewpos = pDoc->GetFirstViewPosition();
while (viewpos != 0)
{
CMyView *pView = static_cast<CMyView>(pDoc->GetNextView(viewpos));
}
|
|
|
|
|
I reached upto there.
Now i want to activate that view. How to do this?
How to activate that view?
|
|
|
|
|
I googled a bit and found an excellent answer to that question right here[^]
|
|
|
|
|
Hi,
That (SetActiveView ) is also not working.
|
|
|
|
|
Sakhalean wrote: That (SetActiveView ) is also not working.
Of course it's working. Is your view attached to your child frame?
|
|
|
|
|
yes my view is attached to its child frame.
|
|
|
|
|
So, you have two problems...
When you click on the treeview node, you need to...
1/ open a view of the right type if it doesn't already exist.
2/ activate a view you've already created.
Are there multiple documents also?
Let's imagine this application:
A tree on the left. Parent nodes represent documents, and child nodes represent possible views. You can use CTreeCtrl::SetItemData to store a pointer to the CMyDocument at each parent node. And store a pointer (or NULL) for any CMyView objects in the child nodes.
The main trick is to make sure that closing a view sets the ItemData back to NULL in the views destructor.
Now it's just a case of being careful.
You can use a intermediate view class between CView and all your specialised view classes that do the book keeping so you only have to be careful in one place.
Good luck! Do let us know how it goes.
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
OK I have solved that problem after struggling two days.
But it was very simple.
Thank you
|
|
|
|
|
I'm glad your problem is now solved, and I hoped we helped.
Good luck with your future endeavours,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Dear all,
I want to know how to hook Microsoft Office File Open/Save Dialog box.
My exact requirements are as follows:
1. To get the full path of the MS office file that is opened(it could be word, power point or excel file)
2. If the user saves the file using "save as" option, I would like to get the full path of the target file
I appreciate any help in this direction.
I am using VC++ on windows XP
Thanks in advance........
Dinakara K
CAIR, Bangalore
|
|
|
|
|
I have mfc sdi aplication and i need to change the popup menu text
i can chage the submenu items by ading event handler ON_UPDATE_COMMAND but i cant do with the file menu because i dont have an id.Anyone knows a function to do that?
Thank You.
|
|
|
|
|
You can probably find some useful function in the CMenu[^] class.
It's time for a new signature.
|
|
|
|
|
There are id's there too. Have a look in your menu resource, and you will find the appropriate identifiers.
ID_FILE_OPEN
ID_FILE_CLOSE
ID_FILE_SAVE
ID_FILE_SAVE_AS
...
I hope you're not trying to use numbers instead of identifiers.
|
|
|
|
|
thak you i find them but i cand find for the FILE
i have FILE -???
NEW ID_FILE_NEW
OPEN ID_FILE_OPEN
but the File dont have
|
|
|
|
|
Ok, I misunderstood what item you wanted to change. See Richards answer above.
You can get the menu of the CMainFrame using GetMenu()
Look at this entry for a sample:
CWnd::GetMenu()[^]
The pMain will be your CMainFrame pointer.
|
|
|
|
|
Hi I am using CTreeCtrlEx example of code project.
I have added one function which will expand a node of tree if it has children.
void CTreeCtrlEx::ExpandEx(HTREEITEM item, UINT nCode)
{
this->Expand(item, nCode);
}
calling like this
if(shouldExpand)
m_OutlookFolders.ExpandEx(expandableNode, TVE_EXPAND);
It's working fine in Windows XP but not working in Vista/Windows7
Any way to do that in both OS ??
Thanks,
Rahul Kulshreshtha
|
|
|
|
|
It would be best to post this question in the Discussion list at the end of the article page.
|
|
|
|
|
In that case, only article writer may give the answer. But what if I want answer from other peoples like you. You post excellent answers here and if I post this question in Article-Discussion then I will not be able to get answers from you and other people's who have a great solution and mind.
Please give answer here.
|
|
|
|
|
Why I said that was because, the author has written the code and he/she would be inquisitive as to why it does not work in a newer OS.
I'm not discouraging you from posting in the general forums.
|
|
|
|
|
Thanks I posted in that article.
My problem has been solved. This was a silly mistake. Actually parent node was expanding in win7 also but that parent node was also having another parent node which I was not expanding and I was thinking that nothing is getting expand. I should recursively expand all it's parent nodes
Regards,
Rahul Kulshreshtha
|
|
|
|
|
Are you saying there was a difference how this was handled in XP and Win7?
|
|
|
|
|
No!!! Actually my XP machine was having a Tree with only two level and my Win7 machine was having Tree with 4 level of data.
I was expanding only parent folder of some node(detected by some rules) so in windows XP, I was able to see changes while in Win7 it was expanding parent folder of some node(detected by some rules) but as the detected node was on 4th level of tree so only it's parent (3rd level node) was getting expand. 2nd level and 1st level node was not getting expand because I was not expanding them. So I changed my logic to expand all parent in hierarchy and that worked
|
|
|
|
|
Well, that's a relief.
|
|
|
|