MDI newbie ?

I want to add a "reload" command that will close the current(and only)
document and reload it again.  Here is what I have tried so far:
<code>
 AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_NEW);
 while(AfxGetApp()->GetOpenDocumentCount() > 0);
 AfxGetApp()->OpenDocumentFile(currentFluPath);
</code>

This doesn't work, because, as I've learned ID_FILE_NEW create just that, a
new blank document so count is still 1.  I can't figure out what I should
check for, how I can know when the ID_FILE_NEW is done so that I can call
OpenDocumentFile()

Does this make sense what I want to do?  Basically, I just want to reload a
file and offer the user to chance to save in the case there are changes.

Thanks for any help.


0
sss1 (24)
5/26/2005 2:58:46 PM
vc.mfc 33608 articles. 0 followers. Follow

6 Replies
670 Views

Similar Articles

[PageSpeed] 37

>I want to add a "reload" command that will close the current(and only)
>document and reload it again.

Steve,

Try something like this:

void CAtestDoc::OnReload() 
{ 
        // Reload the current document 
        CString sFile = GetPathName(); 
        OnOpenDocument( sFile ); 
} 

Dave
0
davidl7375 (2060)
5/26/2005 4:47:11 PM
"David Lowndes" <davidl@example.invalid> wrote in message
news:0avb91l0vbh7lfki5rvgbbu09hhojsbbr1@4ax.com...
> >I want to add a "reload" command that will close the current(and only)
> >document and reload it again.
>
> Steve,
>
> Try something like this:
>
> void CAtestDoc::OnReload()
> {
>         // Reload the current document
>         CString sFile = GetPathName();
>         OnOpenDocument( sFile );
> }
>
Hi David,
Thank you for the response.

I'm not seeing the benefit here.  I'm sure it's there, but I don't get it.
Currently I am clearing out the existing doc and it appears that this isn't
completing before the load doc is called.  I think.

Would you mind explaing a bit more, possible at a higher level the process
you are suggesting?

thanks again!
> Dave


0
sss1 (24)
5/26/2005 5:21:42 PM
>I'm not seeing the benefit here.  I'm sure it's there, but I don't get it.

I was trying to show you a simple way of getting started with what you
wanted to do.

Here's a more complete example that I think does precisely what you
asked for. This is a method of your CDocument derived class - I've got
it invoked from a menu command.

// Reload the current document 
void CamfcappDoc::OnViewReload()
{
  if ( IsModified() )
  {
    /* Save a copy of the current file without
     * renaming the document's file name
     */
    DoSave( NULL, false );
  }
  CString sFile = GetPathName();
  OnOpenDocument( sFile ); 
}

Dave
-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl7375 (2060)
5/26/2005 9:21:04 PM
"David Lowndes" <davidl@example.invalid> wrote in message
news:r6fc91l16343i3tthb306idkjekus51h91@4ax.com...
> >I'm not seeing the benefit here.  I'm sure it's there, but I don't get
it.
>
> I was trying to show you a simple way of getting started with what you
> wanted to do.
>
> Here's a more complete example that I think does precisely what you
> asked for. This is a method of your CDocument derived class - I've got
> it invoked from a menu command.
>
> // Reload the current document
> void CamfcappDoc::OnViewReload()
> {
>   if ( IsModified() )
>   {
>     /* Save a copy of the current file without
>      * renaming the document's file name
>      */
>     DoSave( NULL, false );
>   }
>   CString sFile = GetPathName();
>   OnOpenDocument( sFile );
> }
>

Great, thank you for the additional explanation, David.
I have added the new method to my derived CDocument class and wired
everything up.  The only part I'm stuck on now is how I access the CDocument
from either my current location for the menu event handler which is
CMainFrame or from the Application class.

I have found access to the list of DocumentTemplates, but I don't see how
they are related.  Do you mind suggesting a way to access the CDocument
instance in question from CMainFrame or WinApp?

I'm not sure why all the event handlers are located in CMainFrame, I
inherited this MDI app yesterday :(
> Dave
> -- 
> MVP VC++ FAQ: http://www.mvps.org/vcfaq


0
sss1 (24)
5/26/2005 10:46:33 PM
"Steve" <sss@sss.com> wrote in message
news:exibFTkYFHA.3660@TK2MSFTNGP10.phx.gbl...
>
> "David Lowndes" <davidl@example.invalid> wrote in message
> news:r6fc91l16343i3tthb306idkjekus51h91@4ax.com...
> > >I'm not seeing the benefit here.  I'm sure it's there, but I don't get
> it.
> >
> > I was trying to show you a simple way of getting started with what you
> > wanted to do.
> >
> > Here's a more complete example that I think does precisely what you
> > asked for. This is a method of your CDocument derived class - I've got
> > it invoked from a menu command.
> >
> > // Reload the current document
> > void CamfcappDoc::OnViewReload()
> > {
> >   if ( IsModified() )
> >   {
> >     /* Save a copy of the current file without
> >      * renaming the document's file name
> >      */
> >     DoSave( NULL, false );
> >   }
> >   CString sFile = GetPathName();
> >   OnOpenDocument( sFile );
> > }
> >
>
> Great, thank you for the additional explanation, David.
> I have added the new method to my derived CDocument class and wired
> everything up.  The only part I'm stuck on now is how I access the
CDocument
> from either my current location for the menu event handler which is
> CMainFrame or from the Application class.
>
> I have found access to the list of DocumentTemplates, but I don't see how
> they are related.  Do you mind suggesting a way to access the CDocument
> instance in question from CMainFrame or WinApp?
>
> I'm not sure why all the event handlers are located in CMainFrame, I
> inherited this MDI app yesterday :(

Hi Dave,
OK, I have solved this with the magical method GetActiveDocument()  ;)

Thank you again!
> > Dave
> > -- 
> > MVP VC++ FAQ: http://www.mvps.org/vcfaq
>
>


0
sss1 (24)
5/26/2005 11:10:11 PM
>I'm not sure why all the event handlers are located in CMainFrame, I
>inherited this MDI app yesterday :(

Perhaps they shouldn't be! ;)

I'm glad you've got it working.

Dave
0
davidl7375 (2060)
5/27/2005 8:41:12 AM
Reply:

Similar Artilces:

MDI appliccation problem
Hi, I am working on an MDI application. I am haveing a strange problemin this application. I have 2 dialogs in the main MDI application (Common settings & standard about app dialog). I have my Doc/View/Frame coming from various DLLs. When I start my application, and use the dialogs (common dialog OR About App) it works fine (i.e. dialog s are displayed properly with proper filled values). Now I create a new instance of a Document by clicking New in Fuile Menu or Ctrl+N (I have 2 document types available right now), and then close the document (by Close in File menu or Ctrl+F4). After ...

NEWBIE ( select the same folder )
Hi! This code mark unread the picked up folder messages. It works correctly. But how can I mark unread always a specific folder (ex. "fax")? Thanks in advance M. ----- Dim olApp As Outlook.Application Dim olSession As Outlook.NameSpace Dim olStartFolder As Outlook.MAPIFolder Dim strPrompt As String Set olApp = Application Set olSession = olApp.GetNamespace("MAPI") ' **** HERE I WANT SELECT ALWAYS THE FOLDER NAMED "fax" Set olStartFolder = olSession.PickFolder For Each objItem In olStartFolder.Items objItem.UnRead = False...

How to set MDI view as background view?
I am developing a MDI application and have the requirement to allow for the definition of a single background view. By using a bulletin board analogy, it is more clear what is needed. In this analogy, the background view would be the bulletin board and all other views would be the flyers in the foreground. I have no problems implementing this by changing the z-order of the desired background view by calling the frame window's SetWindowPos() method, provided that no view is maximized. However, I need to implement this capability regardless of the window state; normal, maximized, minimize...

Newbie Needs help with dates
Using SQL 2005 I want to be able to take whatever date is provided and report on all records between that and that date minus 13 months. Select * FROM table WHERE month_dt Between '06/01/2009' and '06/01/2009' -13 Is this possible and if so how? Any help is greatly appreciated. -- Message posted via SQLMonster.com http://www.sqlmonster.com/Uwe/Forums.aspx/sql-server-programming/201001/1 Try: Select * FROM table WHERE month_dt Between dateadd (mm, -13, '06/01/2009') and '06/01/2009' -- Tom ---------------------------------...

Creating Document in MDI app
Hi, In my application I wish to be able to export certain data to another file. In one of the functions in my view I need to create a new document, call some functions on it then save and close the document. I am struggling to find how to do this. I have only one Document template in my app. The code I have so far is: POSITION p = GetApp()->GetFirstDocTemplatePosition(); CDocTemplate* pTem = GetApp()->GetNextDocTemplate(p); CBob_photoDoc* pDoc = (CBob_photoDoc*) pTem->OpenDocumentFile(GetApp()->m_pProfStrs->DefFile,false); CBob_photoDoc is my document class. I can now...

MDI within MDI?...
Hi All, I have an MDI app where I want each child window to in turn host another MDI parent, allowing a managed frame of children for each top-level MDI child. The purpose is a "workspace" driven UI where the top-level children are maximised and displayed as tabs only, but each has to be able to host further framed windows within it. I am not an MFC expert on MDI/SDI, nor on the underlying API requirements. I have been able to create primitive child frame in the top-level view's OnInitialUpdate, specifying the view as the parent, which does bounds clipping OK, however I'm l...

Newbie Help!
Im am fairly new to MS excel. Ill try and describe my problem as best can. One of the lab technitions at work has an external 'grip tester' tha sends road readings into an excel file on the fly. My problem only relates to ONE column. Every now and then about four o five readings are put in, followed by around 10 blank spaces. and so o and so on all the way DOWN the page. What this guy has asked me is if there is a way to replace all th 'null values' (blank spaces) with a fixed one (i.e 3.5). Withou replacing the scattered readings. No good copy pasting as there are so many...

Newbie programming question
greetings I need something cleared up. I am learning to use SQL as an efficient language to manipulate data in tables. I'm also making good progress in learning VBA, using it to manipulate forms, controls, reports, data, etc. So far, so good. Here is my question. What really is DAO and ADO? What is their relationship with SQL and VBA? Really I'm just trying to come to grips with how I should think of DAO and ADO in the context of the languages SQL and VBA. any help appreciated Victoria Victoria, Have a look at... http://www.utteraccess.com/forums/prin...

Problem with Full Screen MDI application
Hi all, I have added full screen functionality to MDI application as per fscrn.exe sample provided by microsoft. The problem is when I minimize the application (provided a minimize button on toolbar), and after that lock the computer and log in again, and click on taskbar to show application again, then menubar associated with application shows up. It does not go even if I minimize the application and again show it back. This problem is not present when I just minimize the application without locking the computer. It does not show menubar that time. Please help me. Thank you, Sandeep Kulkarni ...

MDI with DLLs
Hi I want to create an MDI application that will have different views. It will need form views, views and listview. I can do this with no problem using just an regular exe with all the code in it, but I want to be able to put all the code and resources of the view classes and other part of the programs in dlls so if I find a problem in one part of the program I will only update the dll where the problem is. How do I do this? How do I load a child view from a dll? What is the best way to do this "Alfredo" <anonymous@discussions.microsoft.com> wrote in message news:94099A9B-...

integration MDI child views from VC i VB into one MDI App
Hey, I’d like to integrate two applications: First is MDI application written in Visual C++ 6.0. Second is dialog-based application written in Visual Basic 6.0, but I suppose that we can change the main dialogs to MDIChild forms. Both applications are in DLLs at all. Is it possible to use a MDI child forms created in visual basic 6 and in visual studio c++ together in one MDI application? I suppose that main MDI application should be written in VC++, because it’s extremely flexible and I know this environment the best, but maybe I’m wrong :). Maybe for example in C# .net it’d be easier...

MDI childframe problems
To create a maximized mdi child frame I tried this: BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) { if( !CMDIChildWnd::PreCreateWindow(cs) ) return FALSE; if (IsWindow(m_hWnd)) { ShowWindow(SW_SHOWMAXIMIZED); } return TRUE; } The window is opened maximized but the minimize/maximize/close buttons are missing. When I open a 2nd document and click on windows | tile the behaviour turns back to normal. Can someone tell what's wrong here? cs.style |= WS_MAXIMIZE didn't work either. It's opened in normal size. TIA, Hans Do this in ActivateFrame: void CChildFrame...

Newbie
Hey, all. I need to print multiple addresses I have (~75) and save them down so I do not need to enter them each time. How can I do this? -newbie Hi Chris (Chris@discussions.microsoft.com), in the newsgroups you posted: || Hey, all. I need to print multiple addresses I have (~75) and save || them down so I do not need to enter them each time. How can I do || this? 1. Which version of Publisher are you using? 2. Which printer are you using? 3. Which version of Windows are you using? 4. What size envelope are you printing to? 5. Where are your multiple addresses stored? -- Brian Kvalheim ...

HOWTO Subclass a .NET UserControl's window handle to an MDI EXE
HOWTO Subclass an AtvieX control's window handle to an MDI EXE Please help, I want to make .NET UserControl launch a VC++/MFC/MDI EXE that in turn is fed the UserControl's windows handle via the STDIN, that EXE then uses to subclass, so that its GUI appears in the UserControl's space. Getting the .NET UserControl's windows handle was easy, it was simply "this.Handle". Using the various .NET means to launch an EXE was easy, and to make the .NET UserControl let the EXE inherit the STDIN handles was easy. And I got the EXE to "see/read" the HANDLE on th...

about mdi
hi!can you have some sample code about mdi: i want to create a mdi program,it have two view,and the one view attach one document! thanks you ! there are many samples in the msdn library. also the app wizard will build you a basic mdi app automatically, that is the easiest way to get started. "land" <lfang@altigen.com.cn> wrote in message news:eT1J0aKnEHA.3756@TK2MSFTNGP11.phx.gbl... > hi!can you have some sample code about mdi: > i want to create a mdi program,it have two view,and the one view attach > one document! > > thanks you ! > > ...

Newbie probs with Excel 2007
Hi to the forum, which I am visiting for the first time. I have done a fair bit of Excel programming over the years and was still using windows 98 and excel 2003 on a machine with only 1G Ram until recently when I upgraded my computer (quad core processor, 2 G Ram ) with Windows XP and Excel 2007 I have written a program that includes a map of australia as an xy graph , using lat and lon coordinates. I have about 70,000 data pairs to plot the map, but it was just impossibly slow, so I cut down the resolution by taking only every 8th point, but it is still hopelessly slow. It takes ages even...

Newbie question: Dialog repaint fails after hiding control
I am a very experienced C++ programmer, and a very inexperienced Windows/MFC programmer. :-) I've written a dialog (actually a property page) with a checkbox and various other controls (edit areas, listboxes, statics, etc.). I map the BN_CLICKED event on the checkbox and use it to dynamically hide/show other controls by invoking ShowWindow(SW_HIDE) or ShowWindow(SW_SHOW). This works fine in a large test application; however, when the same code (same DLL) is executed from within an even larger system, repaint of the dialog box at the "hidden" control fails. (That is, a...

Newbie XSD namespace question
This is a multi-part message in MIME format. ------=_NextPart_000_0013_01C39DA2.FE3D0320 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi all, I have the following XML file: <Config> <MyFoo xmlns=3D"http://MyCompany/Foo"> </MyFoo> <MyBar xmlns=3D"http://MyCompany/Bar"> </MyBar> </Config> For a project specific reason, I need to keep <MyFoo> and <MyBar> in 2 seperate namespaces. I run XSD.exe to generate my schema. This results in the following 3=20 XSD schema files...

modeless MDI
Oh heck..., This is what I'm trying to do. What's the best way forward? I want to have a "CONTROL" panel. Which contains a list of objects. I wanto be able to click on the objects to open a window to edit its properties. I'd liike to be able to open ultiple nstances of the window. I guess this sounds like an MDI? I want also to be able to click on bits of the control panel to open up modal dialog winodws to edit other properties, e.g. add another item to the list. I have a feeling that my mouth is bigger than my stomach. I'm not even meant to be a programmer.... I...

Error in Petzold book? (MDI)
I'm using Charles Petzold's "Programming Windows 95" (copyright 1996), and I'm following his guidelines for creating an MDI (multi-doc-interface). I have copied his code from "mdidemo.c" and made a few minor and harmless changes. The problem is that this code always crashes during the CreateWindow() call that makes the "frame window". Has anybody else tried compiling this code?? I only made one small modification to the code. During the CreateWindow(), instead of using NULL as the last parameter, I used a pointer to some data. Like this : WinMa...

Newbie 'RIGHT' question
Hi all. Is there a way to tell the RIGHT function to extract all the characters in a string preceding a second capital letter? We have a data set that contains concatenated Firstnames and Lastnames. For example: JoeSmith JonathanJones JamieJensen We need to break the first names out into a separate column... I know how to use RIGHT to grab a fixed number of characters or even characters preceding a space... But in this case, I need to tell it to grab everything preceding a CAPITAL letter. Any ideas? Much appreciated!! Mouse To get the last name =MID(A1,MATCH(1,(CODE(MID(A1,ROW(INDI...

MDI
Everytime I try to save a publisher file now as a tiff file it saves it as a MDI file. I know this is basically a tiff file but to do what I want I need to save it as a true tiff. The MDI requires me to convert and for some reason I can't. Do you have Office 2003? Can you bring the file into the Document Imaging application and convert it there? Some Microsoft articles addressing MDI http://tinyurl.com/2t7vk http://tinyurl.com/32s3l -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.mvps.org/msauer/ news://msnews.microsoft.com "Gary" <anonymous@discussions.mi...

MDI newbie ?
I want to add a "reload" command that will close the current(and only) document and reload it again. Here is what I have tried so far: <code> AfxGetMainWnd()->PostMessage(WM_COMMAND, ID_FILE_NEW); while(AfxGetApp()->GetOpenDocumentCount() > 0); AfxGetApp()->OpenDocumentFile(currentFluPath); </code> This doesn't work, because, as I've learned ID_FILE_NEW create just that, a new blank document so count is still 1. I can't figure out what I should check for, how I can know when the ID_FILE_NEW is done so that I can call OpenDocumentFile() Does ...

Run Integration Quicker-Newbie
I am running an integration to import sales orders for invoicing. I use several additional query criteria in IM, but I do not think these criteria are passed to SQL Server 2000. Instead, the records are returned, then the criteria are applied. The integration is taking quite a bit of time to run. Does anyone have an idea on how to pass the criteria to SQL Server, or any other ideas to increase the performance? Thanks. use a SQL Server View "Shannon LeVert" <slevert@aviagen.com> wrote in message news:06c701c46daa$fbad4100$a501280a@phx.gbl... > I am running an in...

eConnect newbie
Hi, I've installed eConnect 7.5 and am planning to use this to read & write xml files to GP can anyone give me samples or examples of how to do this, also my company is planning to upgrade to GP 9 shortly are there major changes between each version? Thanks in advance. JimB If you've installed eConnect, then you have several samples already. They are located in the samples folder underneath the eConnect installation. The changes from 7.5 to 9.0 are fairly minimal. Mostly, there are new xml elements that can be included, but many of those are optional. It's my gue...