Sending Window Messages from an MFC app to a Windows Firm tray application

Hello,

I have an MFC MDI application and a Windows Forms (2.0) Tray Icon 
application.
I want to run a command on the tray application via my MFC application.
There is a "Register" context menu command on the tray icon application.
I want to call the Register command from my MFC MDI application.

I thought of a windows message.
How do I do it?
Is there any other better mechanism to do so?
Thanks,
Janiv Ratson.


0
Janiv
7/4/2006 11:50:37 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
807 Views

Similar Articles

[PageSpeed] 2

If you know the class of the window on the tray application you can use 
FindWindow() to get the window for the class.  Then you can use either 
PostMessage() or SendMessage() to send a message to that window.  You should 
be able to use the same message ID that is generated when you select the 
functionality from the menu in the application.  Basically, the tray 
application will not know the difference between the message that came from 
the outside or the one from its own menu.

Tom

"Janiv Ratson" <janivr@gmailcom> wrote in message 
news:eCMp%23e1nGHA.3532@TK2MSFTNGP04.phx.gbl...
> Hello,
>
> I have an MFC MDI application and a Windows Forms (2.0) Tray Icon 
> application.
> I want to run a command on the tray application via my MFC application.
> There is a "Register" context menu command on the tray icon application.
> I want to call the Register command from my MFC MDI application.
>
> I thought of a windows message.
> How do I do it?
> Is there any other better mechanism to do so?
> Thanks,
> Janiv Ratson.
>
> 


0
tserface (3860)
7/4/2006 3:01:35 PM
What I tend to do in these situations is the following:

an app that wants to establish communication sends a user-defined message 
	::PostMessage(HWND_BROADCAST, UWM_ARE_YOU_THERE, (WPARAM)m_hWnd);

The m_hWnd is the window that expects to get a response.  The receiving task has a message
handler

ON_REGISTERED_MESSAGE(UWM_ARE_YOU_THERE, OnAreYouThere)

LRESULT CWhatever::OnAreYouThere(WPARAM wParam, LPARAM)
    {
     HWND target = (HWND)wParam;
     ::PostMessage(target, UWM_I_AM_HERE, (WPARAM)m_hWnd);
     return 0;
    }

now each window has exchanged its ID with the other one.  They are now free to engage in
whatever dialog they would like.  This assumes you are writing both applications.
Otherwise, Tom's solution is the one you have to use, and this can have problems if the
window class is not unique.
				joe

On Tue, 4 Jul 2006 08:01:35 -0700, "Tom Serface" <tserface@msn.com> wrote:

>If you know the class of the window on the tray application you can use 
>FindWindow() to get the window for the class.  Then you can use either 
>PostMessage() or SendMessage() to send a message to that window.  You should 
>be able to use the same message ID that is generated when you select the 
>functionality from the menu in the application.  Basically, the tray 
>application will not know the difference between the message that came from 
>the outside or the one from its own menu.
>
>Tom
>
>"Janiv Ratson" <janivr@gmailcom> wrote in message 
>news:eCMp%23e1nGHA.3532@TK2MSFTNGP04.phx.gbl...
>> Hello,
>>
>> I have an MFC MDI application and a Windows Forms (2.0) Tray Icon 
>> application.
>> I want to run a command on the tray application via my MFC application.
>> There is a "Register" context menu command on the tray icon application.
>> I want to call the Register command from my MFC MDI application.
>>
>> I thought of a windows message.
>> How do I do it?
>> Is there any other better mechanism to do so?
>> Thanks,
>> Janiv Ratson.
>>
>> 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15973)
7/4/2006 8:39:49 PM
Reply:

Similar Artilces:

How do I send copies emails without sending attachments?
I send emails with attachments to our bank. My boss wants a copy of the email but not a copy of the attachment. How do I do that? Steve Bramblett wrote: > I send emails with attachments to our bank. My boss wants a copy of the > email but not a copy of the attachment. How do I do that? Each recipient gets the SAME copy of the e-mail. If you want different recipients to get different versions of your e-mail, you have to send different e-mails. ...

No message in outbox
I tried to send a message with 1Mb attachment to 40 recipients in the bcc field. It gave me an error message from the isp's server, the message was NOT sent (I've checked), it did NOT arrive in Sent Items, but neither is it in the Outbox any more. I can send and receive email successfully. Problem is, every few minutes Outlook tells me it's sending message 1 of 1, it fails and gives me the same error message. Yet there is no message in the Outbox. But what happened to the original message when it first failed to send? I guess it's 'stuck' somewhere but I can...

Converting an MFC 6.0 App to .net problem
I have recompiled an existing MFC 6.0 application in VS .net 2003. Now about every 13th time I run it in debug mode I get a "Unhandled exception at 0x7c901230" error. When I run it using the WinDbg program I get: DBGHELP: ntdll.pdb - file not found *** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll - DBGHELP: ntdll - export symbols ntdll!DbgBreakPoint: 7c901230 cc int 3 When I run a release version of the application everything runs fine. Any Ideas? Larry The information you posted regarding symbol files is irrelevant to ...

Sending mail from selected email address
Hi All, As I have 4 email accounts set up in Outlook, I understand that I can send mail from each or any account. The accounts are listed under tools / Send and Receive / then each of the accounts. How can I choose which account to send from so that the recipient see's who I want it to be from?? Hope that explains it. Regards Alan On Sat, 16 Apr 2005 21:10:48 -1000, The Fatman <albaxter@optushome.com.au> wrote: > Hi All, > > As I have 4 email accounts set up in Outlook, I understand that I can > send > mail from each or any account. > > The acco...

Sending mail from remote location
my mail works great while at home. when I go on the road I can receive ail but not send. I get the following error message: Subject 'SKIDOO MACH Z 800LT (long track / long tunnel) (Jackson)', Account: 'Jeff', Server: 'smtp.charter.net', Protocol: SMTP, Server Response: '571 imp11 smtp.charter.net OTcuMTQ3LjE2LjIzMA== You must connect from Charter IP space. E1110', Port: 25, Secure(SSL): No, Server Error: 571, Error Number: 0x800CCC61 It worked on my last laptop and I have not been able to figure it out on this one. I can't remember what I...

introducion to windows
it baisicly stinks you have to right click left click use funny spinny thing along eith that it is compuletly out wiereding it is bug prone and not very plessent to it is horibly expensive i wich i was curently sitting un a mac the folder structure makes no sense un a windows computer you can find all the files but it just dossent make sense all in all windows stinks oh and ps msn messanger isent all that great iether its no better if not wourse than yohoo messanger and from what i have seen from yahoo there better than microsoft in everything they do yet stink in everything they do and pc lap...

Sending a macro to another PC-how?
How do you send a macro you've written to another PC so that they can save it in their Personal.xls file (at Program Files\Microsoft Office\Office\XLStart)? You can export a macro and save it, to do this from your workbook, right-click the workbook's icon and pick View Code. This icon is to the left of the "File" menu this will open the VBA editor, click on the module you want to save and go to file and export file, then save it to a floppy or what ever you backup to, then import it to the new workbook. -- Paul B Always backup your data before trying something new Using ...

cannot move messages
Sometimes when I attempt to move a message from the inbox to a storage folder I receive the following error message - "An unknown error has occured. The selected message(s) could not be moved." Why am I receiving this message and how can this problem be corrected? Any suggestions would be appreciated. Thanks What kind of mail account is it? POP3, IMAP or HTTP? Both IMAP and HTTP accounts synchronize with the mail server, so moving a message from the mail account to the storage folder requires that WLM tell the mail server to delete the message from the server ma...

Send and Recieve Fix
For a long time I had a problem with my Send/Recieve function in Outlook. This happended in both Outlook 2000 and my current version - 2007. I found I had to re-boot my computer to perform a Send/Recieve in Outlook. Otherwise the sequence would start then stop and say it could not perform due to an error. After extensive Internet and News Group research I decided it was time to run a check on disk errors. This Windows XP facility seemed to have fixed my Outlook problem. I did this about a few months ago now and I have since had no problems with my send and recieve. Unfortunately I do have ...

windows xp logon with personal application
hey cn ne 1 help me to start my application before login in windows xp ,and want my application to logon to user account i want to use. ...

Unable to send?
Hi, I've got MOOL, and i"m usign ti with outlook. The emails that I'm sending are just "stuck" in the outbox? Can anyone give me an idea of what's going on? Rex Did it ever work? Are you able to receive? -- Aloha, -Ben- Ben M. Schorr, OneNote-MVP Roland Schorr & Tower http://www.rolandschorr.com Microsoft OneNote FAQ: http://www.factplace.com/onenotefaq.htm **I apologize but I am unable to respond to direct requests for assistance. Please post questions and replies here in the newsgroup. Mahalo! "Rekks" <rex_flynn@hotmail.com> wrote ...

Sending messages in Outlook
We have a user that everytime that she sends an email she will get booted out of Outlook. The email does go through, but she will have to get out of Outlook. When she goes back into Outlook, everything is fine until she sends another message. Any help would be appreciated. ...

No Permission to Send/Receive Email???
I just replaced our server hardware, upgraded to WS 2k3 Enterprise and created a new domain. I transferred the client files and desktop on our desk/laptop computers over to the new domain. We do NOT have Exchange installed yet, but use Outlook 2002 with the email etc. saved on the client. One one client machine (mine), the email, calendar, etc are there, but when I hit the Send/Receive button, I get a message saying that I don't have permission to perform this operation. Also when I try and change the automatic check for email option it tells me I don't have permission. ...

urgent (high importance) messages #2
Is there a way to remove the high importance flag from messages sent through Exchange 2003? We have a number of users that always set this flag even though the subject matter of the message is not important at all. Thanks Might be, in one of the policies that are Outlook/Office based? Sorry can't be more specific than that... JeffG On Thu, 10 Feb 2005 04:53:03 -0800, "Scott" <Scott@discussions.microsoft.com> wrote: >Is there a way to remove the high importance flag from messages sent through >Exchange 2003? > >We have a number of users that always set ...

Send Do Not Send
When I attempt to email via a print server - OutLook Express displays the message "A program is attempting to email on your behalf" Send or Do Not Send - How do you prevent this from happening? And just automatically send? ...

Exchange 2003, Windows Server 2003, Data Centre Environment
Interesting title to a somewhat uninteresting post. I've just signed up for this, using the Windows Live Mila desktop beta, and just want to test things are working ok! Hello! Adam Laslett wrote: > Interesting title to a somewhat uninteresting post. > I've just signed up for this, using the Windows Live Mila desktop beta, > and just want to test things are working ok! > > Hello! > SOB. ...

Wizard Application
Hi All, I have a Wizard Application which has three Property Sheet and Each of Different size and 1st page has only 3 radio button and so I need the fonts of this page to be much bigger but second & third page has lot of contents so i cannot use the same font in all page & will be using default fonts size. How Dyamically changing the font on a Wizard Application. 1) Is it Possible to Resize the window for each page with respect to its size in wizard appln. 2) How to dymanically create a font and write the static text in wiz app. Appriciate you to come back to me at the earliest and ...

Sending on behalf... Exchange 2003
Hi everyone, Is there a better way to give a few users the ability to send mails also from the info@domain.com mailbox without having them logout and login to a different Outlook 2003 profile... Or without the text sending on behalf of... So my question is, Is there an easy way that a user can select another e-mail address and send mails out...? Thanks a lot in advance!! Regards, BY On Thu, 05 Oct 2006 12:57:12 GMT, "BY" <nospam@mail.com> wrote: >Hi everyone, > >Is there a better way to give a few users the ability to send mails also >from the info@dom...

What was Outlook sending?
Hi, I downloaded my messages using the option "send and receive all". However, the "Show Progress" box indicates that I was also 'sending something'. But I had nothing to send! I look in the "Sent items' folder and nothing was sent at this time. What was Outlook 2003 doing? Santista The usual response here is, "You have a virus". It could be that a virus program is using your Outlook to send spam and/or a copy of itself to people in your address book. I hope this is not the case, but please have the foresight (aftersight?) to look into ...

opening Windows Excel 2003 files with my Mac Excel 2008
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: intel I cannot open the Windows Excel 2003 files sent to me by my accountant. I have Mac Excel 2008. It defaults to the Numbers program, part of Iworks. I need the full functions of Excel to work on the files...not Numbers. thanks I suspect that this is the same problem I have found with Keynote/ PowerPoint. Hold the control key down while you press the mouse on the file you are trying to open. Then pick "Open with" and choose Excel. If you have a two (or more button mouse you can also use "right click" ...

'SEND' just sends it to the OUTBOX
Outlook 2007 on WinXP Home SP3. When I click 'SEND' when replying to an email it does not SEND but puts it in the OUTBOX. I have to click SEND/RECEIVE from the main page to actually SEND the email. Is there a setting I am missing? Thank you. "Peter" <lysdexic@hotmail.com> wrote in message news:eoOd1BM$KHA.5536@TK2MSFTNGP02.phx.gbl... > Outlook 2007 on WinXP Home SP3. When I click 'SEND' when replying to an > email it does not SEND but puts it in the OUTBOX. I have to click > SEND/RECEIVE from the main page to actually SEND the emai...

Outlook Can't Send Messages
This morning I fired up Outlook 2007 (running under Windows 7). It retrieved all new emails. I then tried to post a new email, (not a reply). However, the nano-second that I clicked on "Send" I received a reply from "System Administrator". It said this: Your message did not reach some or all of the intended recipients. Subject: The Train Meltdown Sent: 27-Jul-10 1:18 PM The following recipient(s) cannot be reached: xxxxx@xxxxx.com.au on 27-Jul-10 1:18 PM None of your e-mail accounts could send to this recipient. I have 3 active email ac...

Rules Wizard and Send/Receive error
A couple of days ago, I received an alert from Norton Antivirus software that the file "belt.cab" was corrupted but could not be deleted. Fearing the worst, I manually deleted the file. Since then, Outlook appears to be completely disabled, with the symptoms being that several commands have disappeared from the Tools menu including Send/Receive (both), Rules Wizard, Out of Office Assistant. I can compose an email, but it will not send. I have checked my email accounts and all appears to be in order. Even after a complete reinstall, I cannot send/receive email. The on...

sending Access files
Is there a quick and easy way to send access files without Outlook blocking them. I exchange files with a limited selection of people so am happy that what I am sending and receiving is OK. I know that I can use WizZip but the knowledge database also suggests changing the .mdb extension. I don't know how to do this. Do I just right click over the file and choose open with Word? Or maybe there is a simpler way. Thanks When you send a file type that on Microsoft's potentially dangerous list, you get a message informing you that the recipient may not be able to access the file on...

Multiple Send to
Dear Experts, In any Document Library you have a Send To drop down option. This can only be configured once that is only one entry. I have to have 7 Custom Send To options. Does anyone know how to create more than 1 Sent To? Best Regards, -- Girish J Bhatia MOSS Certified, SharePoint Certified, MCSE2003, MCDBA, CCNA, CCNP, CCSA ...