Link to home
Start Free TrialLog in
Avatar of youcef
youcef

asked on

How to get My CFormview title added to the list of the Windows opened files

I am using VC++ (1.5) and I am creating 4 CFormview windows which contains list boxes, each form view got a special title and ID resouce. Basically I am using OpenDocumentFile(NULL) to trigger the whole process for each form view, and because I've have no ducument to open (my form view build their content from a database) I couldnt get the form view title to show under Windows Menu as opened document so the user can user the keyboard to get their and select them.

how the MFC is doing when you call OpenDocumentFile(filename); I've looked at the code and I couldnt see anything that update the menu or popup menu???

Any Help will be appreciated
 
Avatar of jaba
jaba

MFC nt doing  anything to add you view title into Windows menu . If you using MDI application, MDI Frame and MDI client doing it. I think, you doing somthing wrong while initialisation of you views. How you setting title to view ? Do you using different teplates to create views ? Do you caling OpenDocumentFile member of CWinApp or CDocumentTemplate class ?

Avatar of youcef

ASKER

Thanks for your valuable comment, here are more details:
My Application is an MDI one, and I am creating different template for each Form view window (basically they are using the same MDI frame, Document, and view the only difference is the ID resource which point to different Icon and title).

And I am using the CDocumentTemplate OpenDocumentFile, here is an extract of the code that trigger the process:

void MyCwinApp::NewWindow(){

CMultiDocTemplate* pDocTemplate;

      pDocTemplate = new CMultiDocTemplate(
            IDR_WAITING+iBinId,
            RUNTIME_CLASS(CFaxLinkDoc),
            RUNTIME_CLASS(CAELMDI),
            RUNTIME_CLASS(CListBoxForm));
      AddDocTemplate(pDocTemplate);        

      pDocTemplate->OpenDocumentFile(NULL);

Avatar of youcef

ASKER

Thanks for your valuable comment, here are more details:
My Application is an MDI one, and I am creating different template for each Form view window (basically they are using the same MDI frame, Document, and view the only difference is the ID resource which point to different Icon and title).

And I am using the CDocumentTemplate OpenDocumentFile, here is an extract of the code that trigger the process:

void MyCwinApp::NewWindow(int iBinId){

CMultiDocTemplate* pDocTemplate;

      pDocTemplate = new CMultiDocTemplate(
            IDR_WAITING+iBinId,
            RUNTIME_CLASS(CFaxLinkDoc),
            RUNTIME_CLASS(CAELMDI),
            RUNTIME_CLASS(CListBoxForm));
      AddDocTemplate(pDocTemplate);        

      pDocTemplate->OpenDocumentFile(NULL);
}

Hope this will help.

Hmm , do you keep pDocTemplate pointer or creating new instance every time when you want to open window of this class ?
And , what kind of messages /virtual function you override in CAELMDI ?
Avatar of youcef

ASKER

I create a new instance every time I want to create a window of that class (basically I do it only once for every form view) i.e. at the end I end up with 1 instance window for each class that last till the application close.

As for CAEMDI I am using/overriding the following Messages:

      afx_msg void OnClose();
      afx_msg void OnDestroy();
      afx_msg void OnMDIActivate(BOOL,CWnd*,CWnd*);
      afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);

Note: I've just created another Form,View,Document template That I am using for the purpose to show the summary report/content of each window it's an rpt (Crystal Report) file that I am opening using openDocumentFile(rtp file name) of the CWinApp and suddenly all the windows title appears under the Windows Menu?????
Still dont understand Why not before the rpt file is opened the system doesnt seems to work.
You can use CWnd::GetMenu() to retrive pointer to CMenu object of MainFrame and then call CMenu::GetSubMenu() to get pointer to "Windows" popup menu. Then you can call CMenu::AppendMenu() to add whatever you want ( title and ID of your form view )
Check you OnMDIActivate function. Do you calling base class member ?
OnMDIActivate(BOOL flag,CWnd* pWndL,CWnd* pWndN)
{
CMDIChildWnd::OnMDIActivate(flag,pWndL, pWndN);
// you code here
}
Avatar of youcef

ASKER

Hi Jaba,
You got it right men, I've just put the base class CMDIChildWnd::OnMDIActivate(flag,pWndL, pWndN); and the magic happened, Thank you very much, you are a saver.
ASKER CERTIFIED SOLUTION
Avatar of jaba
jaba

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial