Overriding default menu message handlers

Hi ,

I want to override the default message handlers for my app's menu items
that have been provided by the MFC app wizard. e.g I want to execute my
own code when File>New is clicked as well as call the default message
handler for the File>New. How do I achieve it?

Thanks in advance.

0
9/12/2006 8:19:35 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
589 Views

Similar Articles

[PageSpeed] 33

Hi,

when u create a mdi/sdi using mfc wizards by defaut for file->new
cwinapps handler is called,u can see something like this
"ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileNew)" in the cpp file of the
class derived from CWinApp.Just modify this line and call ur own
handler.

ON_COMMAND(ID_FILE_NEW, OnMyFileNew) // Put this in message map

// this is handler called when file new is clicked
void CTestApp::OnMyFileNew()
{
    // Add ur code here
    CWinApp::OnFileNew();
}

You can do the same for other messages also.

/Kiran

Adrian wrote:
> Hi ,
>
> I want to override the default message handlers for my app's menu items
> that have been provided by the MFC app wizard. e.g I want to execute my
> own code when File>New is clicked as well as call the default message
> handler for the File>New. How do I achieve it?
> 
> Thanks in advance.

0
9/12/2006 9:10:53 AM
You may find this article interesting in addition to Kiran's response. There 
are lots of clever things you can do with file handling.

http://www.codeproject.com/cpp/MDI_MultipleExtension.asp?df=100&forumid=130002&exp=0&select=1290554

Tom

"Adrian" <richard.the.lionheart@gmail.com> wrote in message 
news:1158049162.100460.37180@d34g2000cwd.googlegroups.com...
> Hi ,
>
> I want to override the default message handlers for my app's menu items
> that have been provided by the MFC app wizard. e.g I want to execute my
> own code when File>New is clicked as well as call the default message
> handler for the File>New. How do I achieve it?
>
> Thanks in advance.
> 


0
tserface (3860)
9/12/2006 5:06:35 PM
Tom Serface wrote:
> You may find this article interesting in addition to Kiran's response. There
> are lots of clever things you can do with file handling.
>
> http://www.codeproject.com/cpp/MDI_MultipleExtension.asp?df=100&forumid=130002&exp=0&select=1290554
>
> Tom
>
> "Adrian" <richard.the.lionheart@gmail.com> wrote in message
> news:1158049162.100460.37180@d34g2000cwd.googlegroups.com...
> > Hi ,
> >
> > I want to override the default message handlers for my app's menu items
> > that have been provided by the MFC app wizard. e.g I want to execute my
> > own code when File>New is clicked as well as call the default message
> > handler for the File>New. How do I achieve it?
> >
> > Thanks in advance.

Thanks guys, that is what I want, thanks a lot.

0
9/15/2006 9:58:58 AM
Reply:

Similar Artilces:

Overloading/Overriding Dialog Constructor
I have an application where i want 2 dialogs to share the same class. I will pass in a value to the constructor to distinguish what dialog is using the class as there is some processing that is different for each dialog, a little but not a lot.. I have tried to overload the contructor but when that failed i tried to override it but that also gave me plenty of errors. Can anyone tell me the best way to overload / override a dialog constructor? Cheers Macca Hello try follow code fragements. And remember you must call the CDialiog constructor. regards p3p3 ..h ....8<......8<......8...

xlb default
Is there a way to change the default for the Tools|options|view|Pag breaks to have the page breaks show on all sheets on all workbooks? have tried changing a xlt workbook buy going into every sheet an checking the box to show the page breaks and saving it. When I open new workbook from the template it does not show the page breaks. Opening the xlb does not give the option to change it. JAV -- JAV ----------------------------------------------------------------------- JAVB's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=2930 View this thread: http://www.exce...

Message Size Limits #6
Exchange 2003 SP2 / Outlook 2003 SP2. We have imposed size limits on the sending and receiving of mails - limit is 10MB. Approx once a month I need to send an email that is 10.1MB (must go by email) - so I raise the limits on my mailbox and send it. Yesterday, I changed the limits but still could not send the mail - error 5.2.3 'Message is larger than current limits'. I can send the mail internally to myself and I can send the mail from my personal email address (external) to my Exchange email address. I have checked the ; - Global settings for Message delivery - My user prop...

3rd party apps fail when trying to send via default outlook profil
I have installed 2 different photo software applications (Olympus Master2 and Picasa 3) and have selected to use my default outlook profile when sending pictures. The outlook email form never opens in either app. Sendto mail recipient also doesn't work when I try to send from my desktop. I have upgraded from office 97 to office enterprise 2007. Outlook 2007 opens fine so it could be something with my profile. One error I get when trying to send via Olympus Master2 software is "Cannot find mapidll". I uninstalled Office 97 because I thought maybe there was something ...

Default User Defined Functions
I have some user defined functions that I use quite often. I want to have all my user defined functions accessable by any workbook that I start at any time. I do not want to have to open a module that contains the functions and copy and paste then inside the new workbook. How con I make all my user defined functions show up in the user defined function section by default? Thanks, Eric Save them as *.xla (save as>add-in), then check them under tools>add-ins Regards, Peo sjoblom "flycast" wrote: > I have some user defined functions that I use quite often. I want to ...

Auto Responder messages to select domains
I am removing a bunch of aliases from several old domains that we have. I'd like to setup an autoresponder for all emails addressed to those domains. Currently all emails for the old domains are coming in on a separate SMTP relay which is filtering and virus checking all messages. Those messages are then forwarded to the Exchange server. Is there anything I can configure in the SMTP server of Exchange that will send out a message of my choice to only emails addressed to these domains? You would probably need to have an Event Sink developed. There is now way to do this out-of-t...

Older messages are missing from WLM Desktop Client
Just started using WLM Desktop client on my WinXp home PC. I found the other day that about 1/2 of my messages - all about 1 week old or older - are "missing". I dug around and found in c:\Documents and Settings\<name>\Local Settings\App Data\Microsoft\Windows Mail\ a folder titled Backup with a folder underneath it named New, with 3 files in it. One is a Mailbox store. I suspect the client is auto-archiving "old" messages, but can't find where to view them or recover them. Any ideas?? Mike There's no option in WLM to automatically b...

CPrintDialog changing default printer
I would like to change the default printer when CFileDialog is displayed. The only information that I have is the 'Printer Name'. I have found out that I need to supply DEVMODE and DEVNAMES (in m_pd structure) for the printer. I can get the DEVMODE for the 'Printer Name', but how can I get the DEVNAMES for the 'PrinterName'???? Or am I going about this the wrong way?? -- Hank Williams Quantum Technologies, Inc. HaWilliams(at)spamcop.net Hank, Cut-and-paste day for me :-) http://www.codeguru.com/Cpp/W-P/printing/ and http://www.codeproject.com/printing/ cont...

Book1
C:\Program Files\Microsoft Office\Office10\XLStart\Book1.xl -- mdalb ----------------------------------------------------------------------- mdalby's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=705 View this thread: http://www.excelforum.com/showthread.php?threadid=26311 The template should be named Book.xlt, not Book1.xlt. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "mdalby" <mdalby.1d31an@excelforum-nospam.com> wrote in message news:mdalby.1d31an@excelforum-nospam.com... > >...

Default Unit Cost in POP #2
Would like the ability to setup POP so that it will use the item's current cost as a default for trx entry rather than the OIC field from the vendor item maintenance. Would like to have this ability without having to purchase an addon fix. -- Christopher L. Mast, MBA Echelbarger, Himebaugh, Tamm & Co., P.C. 5136 Cascade Rd., S.E., Ste. 2A Grand Rapids, MI 49546-3728 phone 616.575.3482 fax 616.575.3481 ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree&qu...

Change the default for customer look up to be by name
It would be helpful to have the DEFAULT (or option to make it the default) for Customer ID Search to search by Customer Name, not ID number. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/Community/NewsGroups/dgbrowser/en-us...

Paste options default
Is there a way to change the default paste method from HTML to unformatted text? I always use keyboard shortcuts if at all possible when working. I often copy data around and never like it to be preformatted, but Ctrl-V always ends up copying the format, when all I want is the data. Is there an option or registry key which would allow me to change the default accordingly? Thanks MKS -- View my blog: http://madkingsoup.blogspot.com Cheaper than "What's On TV", and it tells you want you want to watch: http://getdigiguide.com/?p=1&r=63387 Hi AFAIK you can't change t...

Delete Corrupted Mail Message
My backup started failing a while ago. After looking at the log I've started noticing that the item on which it was failing was a mail message in one of the mailboxes that were backed up. It had a very long subject line made up of Japanese characters. I tried to search for this message by opening mailbox in outlook but couldn't find it. Another person suggested backing up entire Store instead of individual mailboxes. That worked and the backup went through successfully. However, today I needed to export the box above to a pst file and the process started failing with "Unknown Erro...

How to make the default view the Web Layout in Outlook 2002 Message Reply window?
Hello How to make the default view the Web Layout in Outlook 2002 Message Reply window? The Word is used as the e-mail editor. ...

Outlook 2007 boots up by itself anytime a new message is received
Hello, A few days ago, outlook 2007 started booting up all by itself seemingly whenever a new message was received. I dont want outlook to run all the time and would like to stop this from happening. I have not found any help so far for this. Can someone please help me with this? I'm currently running vista. Thanks, Jerry Jerry & Robin <jerrobin@comcast.net> wrote: > A few days ago, outlook 2007 started booting up all by itself > seemingly whenever a new message was received. Not possible. If Outlook isn't running, it can't receive messages to begin ...

eudora default
Is there some way I can make Eudora my default server instead of Outlook? I changed my ISP and am now getting mail in one or the other. ...

Default program for.PPS files
I receive an eMail with a .PPS file attachment. If I click on the .PPS, I get an error message; "No program associated with this file type" I cannot find the Windows Live Menu that "hooks .PPS files to the Power Point Viewer. BTW; If I click on a ( stored ) .PPS file, it displays just fine. ( so the Viewer is in there, and working ) ??? -- DesertBob 1: Create a file association. 1. Download and save the attachment on the desktop. 2. Right click on the saved file. 3. Select: Open With from the pop-up menu. 4. Click: Choose [def...

new email message
Is there any way to get outlook to display a new email message if it's closed? Okay, I can't help be a bit of a smart alec. Can your VCR record programs when it's unplugged? No, but depending on the version of Outlook you're using, you can minimize it to the system tray if that's any consolation. http://www.ntfaq.com/Articles/Index.cfm?ArticleID=22494 Also, take a look at some of the items here. http://www.slipstick.com/addins/notify.htm Ray at work "none" <emailalias@company.com> wrote in message news:0ae001c39288$de9f3850$a001280a@phx.gbl... > I...

Moving Messages
I have got both Outlook and Outlook Express on my computer, can I move messages from Outlook to Outlook Express or vice versa? How? Jeff -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- ...

Automatic Reply to update message
Hi Is there a way to automatic reply to the update message you get when updating your records?? -- bg Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200707/1 Thanks.... scubadiver wrote: >If it is the warning message you are referring to you can turn it off. > >docmd.setwarnings false > >> Hi >> Is there a way to automatic reply to the update message you get when >> updating your records?? -- bg Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-queries/200707/1 ...

Default Priority for email?
How do i set the default priory for email messages (i can change on mail by mail basis) no problem - i found it "JethroUK�" <reply@the.board> wrote in message news:_BtCb.2204$526.14670@newsfep4-glfd.server.ntli.net... > How do i set the default priory for email messages (i can change on mail by > mail basis) > > Please, please, post your version of Outlook!!! For Outlook 2003, Tools->Options->Email Options->Advanced email options. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. After searching goo...

created new company, now need to add it to the log in menu
Hi everyone, I have created a new company behind the scenes in SQL Server. When I log into GP 7.5, the new company does not show up in the list of available companies to log into... Does anyone have any ideas as to how I can add the new company. Is there a table in SQL where I can add the new company? thanks, Sandy Companies should be create from within Great Plains utilities. All the necessary tables are created and the all the systems tables are updated with the new company information. If you create or copy a company in SQL Server, the DYNAMICS database will not be updated with...

How to set default formatting for pictures
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel When I drop a screen capture into Word, it always puts it where I drop it. I guess it is automatically anchoring it. What I would like it to do it put it in at the insertion point, left justified, under the previous line. To get it to do this, I have to double-click each picture, select "Layout", choose Wrapping Style "In line with text" then choose radio "Horizontal Alignment Left", then click button "Advanced", and select Radio "Alignment" in the "Vertical" ...

User's problem with sending BIG email messages
I have a user who needs to email the monthly financial statements to the company's accountant. She keeps getting an error message that the message she's sending is too big. I've increased her emailbox limits to the maximum and I've increased the message limits in the Exchange Management Console to the maximum. On Mon, 11 Jul 2005 15:33:03 -0700, "Brian" <Brian@discussions.microsoft.com> wrote: >I have a user who needs to email the monthly financial statements to the >company's accountant. She keeps getting an error message that the message ...

new message in outlook
seems like it would be simple but I do not know how to freeze the outlook shortcut bar as well as the folder list when i create a "new message" it opens a new window and don't want it to. thx ...