Preventing an application exit from the task bar's right click Close menu

Hello gentlemen,

I am developping an application that uses the system tray (I want it to 
behave like MSN Messenger)

That being said, I am almost there.

There is one issue I could not solve and it is how to distinguish and 
prevent my application to quit when the user right-clicks on the 
application's entry on the task bar and selects close when the UI is 
visible. I want the application to only minimize when this action is 
performed.  I was able to prevent this in a way but it is not the proper 
way I beleive because when I try to kill the application from the Task 
Manager, the "Application not responding" window appears.

I prevented my application to quit from the taskbar's close menu by 
overriding the WindowProc method from the main frame.

LRESULT TMainFrame::WindowProc(UINT Message, WPARAM wparam, LPARAM lparam)
{
     if(Message == WM_QUERYENDSESSION )
         canClose = TRUE;
	return CFrameWnd::WindowProc(Message, wparam, lparam);
}

and in the OnClose() method I only close if canClose is TRUE otherwise I 
hide the window ShowWindow(SW_HIDE);

Is there a parameter in wparam or lparam of the WindowProc that allows 
me to find out if the WM_CLOSE message received is from the task bar?

MSN Messenger can handle all those situation very well.

Thank you for any suggestions.

Simon
0
sguertin (27)
6/15/2006 8:36:30 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
638 Views

Similar Articles

[PageSpeed] 41

>There is one issue I could not solve and it is how to distinguish and 
>prevent my application to quit when the user right-clicks on the 
>application's entry on the task bar and selects close when the UI is 
>visible. I want the application to only minimize when this action is 
>performed.

Simon,

Use Spy++ and see if this operation is actually giving rise to a
WM_SYSCOMMAND SC_CLOSE message (and then WM_CLOSE). If it is, try
handling that rather than WM_CLOSE.

Dave
0
davidl7375 (2060)
6/15/2006 9:36:43 PM
Thank you a lot it worked!

David Lowndes wrote:
>>There is one issue I could not solve and it is how to distinguish and 
>>prevent my application to quit when the user right-clicks on the 
>>application's entry on the task bar and selects close when the UI is 
>>visible. I want the application to only minimize when this action is 
>>performed.
> 
> 
> Simon,
> 
> Use Spy++ and see if this operation is actually giving rise to a
> WM_SYSCOMMAND SC_CLOSE message (and then WM_CLOSE). If it is, try
> handling that rather than WM_CLOSE.
> 
> Dave
0
sguertin (27)
6/16/2006 1:56:16 PM
Reply:

Similar Artilces:

preventing date from changing
I have an If condition that sets the date to "today()" true or "today() + 1" if false. My question is how do I prevent the date from changing? If the date is set for today, then tomorrow I don't want to "update". How can this be done? thanks You could copy the cell, and paste as values, before you close the file. (Edit>Paste Special, Values) Or, you could enter today's date in a cell in the row (Ctrl+; ), then refer to that cell in the formula. For example, instead of: =IF(A2="Local",TODAY(),TODAY()+1) enter: =IF(A2="Local...

If this newsgroup closes June 1, which forum covers .NET Framework
If this newsgroup closes June 1, which forum covers .NET Framework? b11_ wrote: > If this newsgroup closes June 1, which forum covers .NET Framework? You can just switch to a real NNTP server, other than Microsoft's. Microsoft has no way to actually "close" a newsgroup. All they can do is stop hosting it on their own servers. Pete I can hear the folow-on questions already - what is an NNTP server and how do I find one that also has these newsgroups? "Peter Duniho" <no.peted.spam@no.nwlink.spam.com> wrote in message news:OfYnyi3$KHA.4308@T...

outlook feature to prevent forgetting attachments
Often people forget to send attachments with emails. Very often they will write something along the lines of "I have attached the minutes from our meeting" and then forget to atcually attach a file. Is there a way therefore that outlook can check the text of an email for words like attach, attached, attachment and query the user before sending if there does not appear to be an attachment? ---------------- 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"...

time stamp upon closed
Hi Everyone, I am trying to have a time stamp mark my date_completed field when an operator changes the status field to closed. Closed is in my tblstatus table along with submitted, pending, postponed, ect. I am guessing that the code would be in the afterupdate event of the status field on my form but not sure? Iwould rather the system date the field rather than an operator. Any suggestions? I would suggest that you use a combo box for the status field. That way, the correct codes will always be entered. Then to update the date_completed field in your table, put a text box on y...

show menu and bars
Hi, I have an excel sheet where all bars and excel menu are hidden. How can i make everything back to visible using only Key combinaison ? thanks a lot, Maileen if menu bar is available click view(menu)-toolbars and check whether the standard and formatting are checked if menu bar is not avilable it must be hidden somewhere. take the cursor to the top line and try to pull it down or try to reduce i.e. click central icon on the extreme right. =================== On Sun, 24 Oct 2004 12:09:56 +0200, Maileen <nospan@email.com> wrote: > Hi, > > I have an excel sheet where ...

CrmSecurityService.exe
The following error is happening at the end of the install process for CRM: The instruction at "0x77fc8fe3" referenced memory at "0x00746e69". The memory could not be "written". Followed by: Failed to install Microsoft Customer Relationship Management Server. Failed to install MSI part of CRM Server setup. Unspecified error: (80004005) =================== I have searched all the forums and tried all the tricks posted for this message....no good! Any help would do. At this point, I am ready to go buy a copy of ACT and let that be it. I am so tired of the qua...

Adding Menu Options on Right Mouse Button in Outlook 2003?
I am using outlook 2003 and I want to put some additional menus on right mouse context menu of Unread Mail Folder, is it possible ? Best Regards, Luqman Outlook does not directly expose the right-click context menu in its CommandBars collection. You will, however, see a new right-click command is when the item selected is using a custom form that includes one or more custom actions. You can also add a custom action without using a custom form, as demonstrated at http://www.outlookcode.com/codedetail.aspx?id=526 Richard Kagerer has posted a code sample at http://www.outlookcode.com/...

How can I make an application transparent?
Can anyone help me with an ideea how can I find a code that makes aplications transparent?I need it at work and I m not allouded to install any kind of software (like Glass2k) therefore I'm thinking of a VB Script to run under Excel. I'm using a personalized application that I need to put on top of maps.google.com to draw streets. I'll appreciate any kind of suggestion! Dan Tabla <DanTa...@discussions.microsoft.com> wrote... >Can anyone help me with an ideea how can I find a code that makes aplications >transparent?I need it at work and I m not allouded t...

how do I exit working offline I use outlook
mike <mike@discussions.microsoft.com> wrote: <nothing> Ask in the body of the message, not the subject. Click File and uncheck Work Offline. -- Brian Tillman ...

Prevent the sales from Tendering when another Item is Scan at POS
Hello, We have serveral items that our Retail does have price assign to them. The cashier will scan the next item. They will not notice the last item they did not enter a price. Now the 2nd item is the price for the 1st item. Then the cashier will tender out the sales without noticing they have an incorrect total for this transaction. Then the store manager have to performed a post void for this transaction, which hold up the customer awaiting to check out. Have anyone else encounter this and know a way to limited sale from being total out of an acceptable sales amount...

Tasks
Hi, I have a user who has quite approx 300 tasks in his folder, some of these tasks have people listed in the Update List, the users are constantly receiving messages saying that the task has been updated, this is really starting to annoy people. The update list of names is greyed out so cannot be altered, where can this be altered from? Thanks, -- Regards, Darryl Please remove NOSPAM from email address to reply to me. ...

Outlook 2000 error upon Exit
HI I am stumped where this error is coming from and how to fix it. I tried searching google but I was not successful finding a resolution. Anyone ever seen this error before ? (See attachment) "Dave Warren" <profpsycho@me2u2me.com> wrote in message news:u6j1o1diaaq45r8m0f2j512ssnbf7oiuvg@4ax.com... > HI > > I am stumped where this error is coming from and how to fix it. I > tried searching google but I was not successful finding a resolution. > > Anyone ever seen this error before ? > > (See attachment) Try a detect and repair (from the help me...

Recurring Tasks & Reminders
I have setup several recurring reminders with reminder alarms, however when I 'complete' one of these tasks, the reminder for all future occurances is removed. Is there a setting or method to prevent this from happening in Outlook 2007? Is there a better approach? Cindy Mikeworth <cindy@tas-in.com> wrote: > I have setup several recurring reminders with reminder alarms, > however when I 'complete' one of these tasks, the reminder for all > future occurances is removed. If the task is complete, then it is over and you have no need of further reminders. I...

prevent user from deleting a tab prevent running macro from menu
how can one prevent a user from 1. deleting a specific tab in a workbook? 2. prevent a user from running a macro from the tools menu (where user can only run a macro from a command button)? thanks! #1. Protect the workbook's structure. In xl2003 menus: tools|protection|protect workbook|check structure #2. Make the sub private: Sub Testme() becomes Private Sub testme() This will stop the user from seeing that subroutine--but if they know the name, they can still type it and run it. joemeshuggah wrote: > > how can one prevent a user from...

Re: preventing distribution lists from printing
I work for a large corporation and I often get outlook mail with ver long distribution lists. Is there any way to prohibit these lenght list from printing so that I only get the message? Thank - buddy ----------------------------------------------------------------------- Posted via http://www.mcse.m ----------------------------------------------------------------------- View this thread: http://www.mcse.ms/message548641.htm ...

Bar Graph #2
I have a bar graph and woulld like to have one of the bars change colou depending on the value of a cell (1 - Green, 2 - Orange, 3 - Red). dont have a lot of experiance when it comes to coding graphs. Please can you help -- ceem ----------------------------------------------------------------------- ceemo's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1065 View this thread: http://www.excelforum.com/showthread.php?threadid=55115 Hi, No need for code if you use some worksheet formula and multiple series. http://peltiertech.com/Excel/Charts/ConditionalChart1...

CRM task button not working???
I can't even open the form in the Personal Forms Library. Is there any way for me to reinstall this form? ...

Prevent Forwarding #2
Hi. I need to know how to make an email message unable to be forwarded to a third party. For example if I sent an email to John, John couldn't then forward that message to someone else. Thanks!! Shannon <anonymous@discussions.microsoft.com> wrote: > Hi. I need to know how to make an email message unable to > be forwarded to a third party. For example if I sent an > email to John, John couldn't then forward that message to > someone else. Can't be done, in general. -- Brian Tillman You'd need to use a service such as those listed at http://www.slipst...

use a WCF in a unmanaged MFC application
I have an application developed using MFC and unmanaged code. Now I need to create a view that would have a Windows Control Form created using .NET and managed code. How can I put this two pieces of code comunicating? Thanks in advance. Is it possible to do that? Is it possible to create an ActiveX control that wraps the funcionality of the Windows control Form? How we can embed .net controls on an MFC project? "Jaqueline" <jaqueline@no-answer.com> escreveu na mensagem news:eH4%235ha9KHA.3592@TK2MSFTNGP05.phx.gbl... >I have an application developed u...

cells not right when save as html
When I save my workbook as an html page the formatting on my 45 degree cells at the top of the page are no longer at a 45 degree angle. Is it possible for this formatting? ...

Outlook set up for calendar, contacts and tasks ONLY
How can I set up my outlook to display ONLY the calendar, contacts and tasks options? I used another e-mail sysem not outlook. sotero <sotero@discussions.microsoft.com> wrote: > How can I set up my outlook to display ONLY the calendar, contacts > and tasks options? I used another e-mail sysem not outlook. Try not defining a mail account in the mail profile. -- Brian Tillman ...

Prevent calculation of fields in split view
Hi all! I have following problem: Most of my forms are displayed in split view, within some of them i am doing different calculations, displaying the calculated values in text boxes. Since some of those calculations are quite time-consuming, i dont want Access to calc. the values for _each_ record in the split-view (which it is doing right now). I want it to just calc the values for the record currently viewed, is there any way to do this? best regards, --Michael ...

Macro needed to Paste Values and prevent Macro operation #2
Sub Macro1() ' ' Dim myBk As Workbook Set myBk = Workbooks.Open(Application.GetOpenFilename(, , "Select the File")) Range("To_Database").Copy ThisWorkbook.Worksheets(1).Range("A65536").End(xlUp)(1).Offset(2, 1) myBk.Close False End Sub In the above macro I need to prevent macros operating in the External File when it opens. I also need the Named Range ("To_Database") from the External File to be copied into the file from which this macro operates as PasteValues. At the moment the Formula in the Named Range is coming across, so that I'm ...

Moving Office applications around
When installing Mac Office 2004, it installs everything in a seperate folder /Applications/Microsoft Office 2004/ ... I personally like a clean apps folder and no subfolders, since I don't have a million applications installed. Most likely (can anyone confirm this? it is, after all, still microsoft) moving the Word/Excel/Powerpoint.app files to a different location will not effect it's operation. However, I'm left with all those other files like Clipart and Shared Applications ... can I move those somewhere else too? Any help regarding the moving of (parts of) Mac Office 2004 aft...

how to exit
hi, how to trace the user intervention when i am in a while or for loop if user click the cancel button i have to stop the process in while loop. here is my code m_show is a edit control member variable of mydialog and m_progress is a progress bar ctrl variable. void Cmydialog::OnSearch() { //TO DO Add your code.. m_mShow.EnableWindow(1); m_myShow.SetWindowText("Processing..."); m_progress.Enable Window(1); UpdateData(false); while(condition) { //some statements this loop runs for more than 6000 times m_progress.StepIt(); } UpdateData(false); } above function is a handler...