Solved

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

Posted on 1997-07-23
9
296 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
ID: 1165738
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
ID: 1165739
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
ID: 1165740
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
Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

 
LVL 3

Expert Comment

by:jaba
ID: 1165741
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
 

Author Comment

by:youcef
ID: 1165742
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
ID: 1165743
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
ID: 1165744
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
ID: 1165745
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
ID: 1165746
Nice ! Accept this , pls
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

821 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