accessing the 2n template on the list
what does this statement mean
iterate through all the DocTemplates in the App, use CWinApp::GetFirstDocTemplatePosition() and CWinApp::GetNextDocTemplate().
i want to access the doctemplate2 which i have registeredin the app class and display it in a window.
how should i iterate and get the pointer to this doctemplate ?
regards
Re: accessing the 2n template on the list
Quote:
Originally posted by mohamed123
what does this statement mean
iterate through all the DocTemplates in the App, use CWinApp::GetFirstDocTemplatePosition() and CWinApp::GetNextDocTemplate().
It means to write code like this:
Code:
void CMyApp::DoSomethingToAllTemplates()
{
POSITION pos = GetFirstDocTemplatePosition();
while(pos)
{
CDocTemplate* pTemplate = GetNextDocTemplate(pos);
// Do something with pTemplate here...
}
}
This is the 'official' way. To get the second template, you could use a counter or just write something like this:
Code:
POSITION pos = GetFirstDocTemplatePosition();
if(pos)
{
GetNextDocTemplate(pos);
if(pos)
{
CDocTemplate* pTemplate = GetNextDocTemplate(pos);
// pTemplate now points to the second template
}
}
However, I always found it easier to store the pointers to multiple templates in member variables of the app and access them directly.