Ctrl+S not received in CMainFrame 
Author Message
 Ctrl+S not received in CMainFrame

In an MDI application I have a CMainFrame and a CChildFrame
From the filemenu I can click on 'File | Save\tCTRL+S' and my OnSave
function will be called (correct behaviour).
But if I use Ctrl+S my OnSave function will NOT be called but the standard
SaveAs dialog shows up .
Any idea why this happens and how to correct it?


Sat, 10 Sep 2005 22:05:01 GMT  
 Ctrl+S not received in CMainFrame
Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your mainframe
window?

--
Ajay Kalra [MVP - VC++]


Quote:
> In an MDI application I have a CMainFrame and a CChildFrame
> From the filemenu I can click on 'File | Save\tCTRL+S' and my OnSave
> function will be called (correct behaviour).
> But if I use Ctrl+S my OnSave function will NOT be called but the standard
> SaveAs dialog shows up .
> Any idea why this happens and how to correct it?



Sat, 10 Sep 2005 22:26:17 GMT  
 Ctrl+S not received in CMainFrame
I put
 ON_COMMAND(ID_SAVE,       OnSave)
in the messagemap(of course)


Quote:
> Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your mainframe
> window?

> --
> Ajay Kalra [MVP - VC++]



> > In an MDI application I have a CMainFrame and a CChildFrame
> > From the filemenu I can click on 'File | Save\tCTRL+S' and my OnSave
> > function will be called (correct behaviour).
> > But if I use Ctrl+S my OnSave function will NOT be called but the
standard
> > SaveAs dialog shows up .
> > Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 08:30:09 GMT  
 Ctrl+S not received in CMainFrame
It should be ID_FILE_SAVE.

--
Ajay Kalra [MVP - VC++]


Quote:
> I put
>  ON_COMMAND(ID_SAVE,       OnSave)
> in the messagemap(of course)



> > Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your mainframe
> > window?

> > --
> > Ajay Kalra [MVP - VC++]



> > > In an MDI application I have a CMainFrame and a CChildFrame
> > > From the filemenu I can click on 'File | Save\tCTRL+S' and my OnSave
> > > function will be called (correct behaviour).
> > > But if I use Ctrl+S my OnSave function will NOT be called but the
> standard
> > > SaveAs dialog shows up .
> > > Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 09:04:26 GMT  
 Ctrl+S not received in CMainFrame
I changed ID_SAVE into ID_FILE_SAVE everywhere (RC-file, resource.h,
CMainFrame) but still the same result. Than I removed ID_FILE_SAVE from the
resource.h and (again) recompiled everything : same result.


Quote:
> It should be ID_FILE_SAVE.

> --
> Ajay Kalra [MVP - VC++]



> > I put
> >  ON_COMMAND(ID_SAVE,       OnSave)
> > in the messagemap(of course)



> > > Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your
mainframe
> > > window?

> > > --
> > > Ajay Kalra [MVP - VC++]



> > > > In an MDI application I have a CMainFrame and a CChildFrame
> > > > From the filemenu I can click on 'File | Save\tCTRL+S' and my OnSave
> > > > function will be called (correct behaviour).
> > > > But if I use Ctrl+S my OnSave function will NOT be called but the
> > standard
> > > > SaveAs dialog shows up .
> > > > Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 09:25:32 GMT  
 Ctrl+S not received in CMainFrame
You are right. I get the same thing. Let me get back to you after I figure
this out.

--
Ajay Kalra [MVP - VC++]


Quote:
> I changed ID_SAVE into ID_FILE_SAVE everywhere (RC-file, resource.h,
> CMainFrame) but still the same result. Than I removed ID_FILE_SAVE from
the
> resource.h and (again) recompiled everything : same result.



> > It should be ID_FILE_SAVE.

> > --
> > Ajay Kalra [MVP - VC++]



> > > I put
> > >  ON_COMMAND(ID_SAVE,       OnSave)
> > > in the messagemap(of course)



> > > > Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your
> mainframe
> > > > window?

> > > > --
> > > > Ajay Kalra [MVP - VC++]



> > > > > In an MDI application I have a CMainFrame and a CChildFrame
> > > > > From the filemenu I can click on 'File | Save\tCTRL+S' and my
OnSave
> > > > > function will be called (correct behaviour).
> > > > > But if I use Ctrl+S my OnSave function will NOT be called but the
> > > standard
> > > > > SaveAs dialog shows up .
> > > > > Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 19:22:48 GMT  
 Ctrl+S not received in CMainFrame
Actually it makes sense. MFC command routing works as follows:

MDIFramewnd(mainframe) gets the call first. Before it handles it, it passes
it on to the view. View attempts to handle the command, if not, it passes it
to the document. So, if view and document dont handle it, only then
mainframe window gets a chance to handle it. And finally, if mainframe
cannot handle it, app gets a shot at it.

In MFC, Document is handling ID_FILE_SAVE, which makes sense. So if you want
to override the default behavior, you should override it in the document
class. That would preserve OO nature as well.

--
Ajay Kalra [MVP - VC++]


Quote:
> I changed ID_SAVE into ID_FILE_SAVE everywhere (RC-file, resource.h,
> CMainFrame) but still the same result. Than I removed ID_FILE_SAVE from
the
> resource.h and (again) recompiled everything : same result.



> > It should be ID_FILE_SAVE.

> > --
> > Ajay Kalra [MVP - VC++]



> > > I put
> > >  ON_COMMAND(ID_SAVE,       OnSave)
> > > in the messagemap(of course)



> > > > Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your
> mainframe
> > > > window?

> > > > --
> > > > Ajay Kalra [MVP - VC++]



> > > > > In an MDI application I have a CMainFrame and a CChildFrame
> > > > > From the filemenu I can click on 'File | Save\tCTRL+S' and my
OnSave
> > > > > function will be called (correct behaviour).
> > > > > But if I use Ctrl+S my OnSave function will NOT be called but the
> > > standard
> > > > > SaveAs dialog shows up .
> > > > > Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 19:30:08 GMT  
 Ctrl+S not received in CMainFrame
Check that the accelerator for Ctrl+S is set to ID_FILE_SAVE


Quote:
> In an MDI application I have a CMainFrame and a CChildFrame
> From the filemenu I can click on 'File | Save\tCTRL+S' and my OnSave
> function will be called (correct behaviour).
> But if I use Ctrl+S my OnSave function will NOT be called but the standard
> SaveAs dialog shows up .
> Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 19:33:58 GMT  
 Ctrl+S not received in CMainFrame
Thanks, if I handle it in the document it works.

Although this solution is perfectly valid for me, I wonder if it means that
I CAN'T handle messages handled by MFC (=the document in this case; i.e.
Ctrl+X) at the level I would like to (CMainFrame in this case)

Quote:
----- Original Message -----

Newsgroups: microsoft.public.vc.mfc
Sent: 26 March, 2003 19:30
Subject: Re: Ctrl+S not received in CMainFrame

> Actually it makes sense. MFC command routing works as follows:

> MDIFramewnd(mainframe) gets the call first. Before it handles it, it
passes
> it on to the view. View attempts to handle the command, if not, it passes
it
> to the document. So, if view and document dont handle it, only then
> mainframe window gets a chance to handle it. And finally, if mainframe
> cannot handle it, app gets a shot at it.

> In MFC, Document is handling ID_FILE_SAVE, which makes sense. So if you
want
> to override the default behavior, you should override it in the document
> class. That would preserve OO nature as well.

> --
> Ajay Kalra [MVP - VC++]



> > I changed ID_SAVE into ID_FILE_SAVE everywhere (RC-file, resource.h,
> > CMainFrame) but still the same result. Than I removed ID_FILE_SAVE from
> the
> > resource.h and (again) recompiled everything : same result.



> > > It should be ID_FILE_SAVE.

> > > --
> > > Ajay Kalra [MVP - VC++]



> > > > I put
> > > >  ON_COMMAND(ID_SAVE,       OnSave)
> > > > in the messagemap(of course)



> > > > > Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your
> > mainframe
> > > > > window?

> > > > > --
> > > > > Ajay Kalra [MVP - VC++]



> > > > > > In an MDI application I have a CMainFrame and a CChildFrame
> > > > > > From the filemenu I can click on 'File | Save\tCTRL+S' and my
> OnSave
> > > > > > function will be called (correct behaviour).
> > > > > > But if I use Ctrl+S my OnSave function will NOT be called but
the
> > > > standard
> > > > > > SaveAs dialog shows up .
> > > > > > Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 22:44:42 GMT  
 Ctrl+S not received in CMainFrame
Of course, you can. Simply override OnCmdMsg etc where the routing orignates
in your mainframe window.

--
Ajay Kalra [MVP - VC++]


Quote:
> Thanks, if I handle it in the document it works.

> Although this solution is perfectly valid for me, I wonder if it means
that
> I CAN'T handle messages handled by MFC (=the document in this case; i.e.
> Ctrl+X) at the level I would like to (CMainFrame in this case)

> ----- Original Message -----

> Newsgroups: microsoft.public.vc.mfc
> Sent: 26 March, 2003 19:30
> Subject: Re: Ctrl+S not received in CMainFrame

> > Actually it makes sense. MFC command routing works as follows:

> > MDIFramewnd(mainframe) gets the call first. Before it handles it, it
> passes
> > it on to the view. View attempts to handle the command, if not, it
passes
> it
> > to the document. So, if view and document dont handle it, only then
> > mainframe window gets a chance to handle it. And finally, if mainframe
> > cannot handle it, app gets a shot at it.

> > In MFC, Document is handling ID_FILE_SAVE, which makes sense. So if you
> want
> > to override the default behavior, you should override it in the document
> > class. That would preserve OO nature as well.

> > --
> > Ajay Kalra [MVP - VC++]



> > > I changed ID_SAVE into ID_FILE_SAVE everywhere (RC-file, resource.h,
> > > CMainFrame) but still the same result. Than I removed ID_FILE_SAVE
from
> > the
> > > resource.h and (again) recompiled everything : same result.



> > > > It should be ID_FILE_SAVE.

> > > > --
> > > > Ajay Kalra [MVP - VC++]



> > > > > I put
> > > > >  ON_COMMAND(ID_SAVE,       OnSave)
> > > > > in the messagemap(of course)



> > > > > > Did you put the appropriate entry in BEGIN_MESSAGE_MAP of your
> > > mainframe
> > > > > > window?

> > > > > > --
> > > > > > Ajay Kalra [MVP - VC++]



> > > > > > > In an MDI application I have a CMainFrame and a CChildFrame
> > > > > > > From the filemenu I can click on 'File | Save\tCTRL+S' and my
> > OnSave
> > > > > > > function will be called (correct behaviour).
> > > > > > > But if I use Ctrl+S my OnSave function will NOT be called but
> the
> > > > > standard
> > > > > > > SaveAs dialog shows up .
> > > > > > > Any idea why this happens and how to correct it?



Sun, 11 Sep 2005 23:24:26 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. DS==SS vs DS!=SS in a DLL

2. Copy/Paste using Ctrl+C/Ctrl+V does not work in CHtmlView Class

3. Trapping Ctrl+Alt+Del / Ctrl+Esc / Ctrl+Alt+Esc

4. CMainFrame which isn't a CMainFrame..

5. Getting pointer to CMainFrame with AfxGetMainWnd not working ?

6. Want Toolbar messages to go to a dialog not CMainFrame

7. AfxGetMainWnd returns CSplashWnd not CMainFrame during app startup

8. Dis/Enable buttons in CToolBarCtrl-not owned by CMainframe

9. Hidden Window in Unmanaged DLL not receiving messages.

10. NotifyIcon handler not receiving mouse events

11. write()'s to network stream are sent but not received

12. Receiving keyboard events, even if app does not have focus

 

 
Powered by phpBB® Forum Software