Solved

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

Posted on 1997-07-23
9
275 Views
Last Modified: 2012-05-07
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
 
0
Comment
Question by:youcef
  • 4
  • 4
9 Comments
 
LVL 3

Expert Comment

by:jaba
Comment Utility
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 ?

0
 

Author Comment

by:youcef
Comment Utility
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);

0
 

Author Comment

by:youcef
Comment Utility
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.

0
 
LVL 3

Expert Comment

by:jaba
Comment Utility
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 ?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:youcef
Comment Utility
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.
0
 
LVL 8

Expert Comment

by:gelbert
Comment Utility
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 )
0
 
LVL 3

Expert Comment

by:jaba
Comment Utility
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
}
0
 

Author Comment

by:youcef
Comment Utility
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.
0
 
LVL 3

Accepted Solution

by:
jaba earned 50 total points
Comment Utility
Nice ! Accept this , pls
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now