locked
How Maximise exe form the system tray icon on click of desktop shortcut RRS feed

  • Question

  • Hi All,
    I am working in a windows application. On Minimise my application goes to system tray...
    Now When I double click the icon of the same applciation in desktop one more form appears...
    How to make the system tray Icon to get maximise instead of opening a new form again..just like yahoo messenger and Msn ...

    thanks

    dharmendra

    Thursday, January 6, 2011 12:11 PM

Answers

  •  

    Hi  Dharmendra_Baghel,

     

    Base on your description, I think you would like the single instance as Simon Bjorstedt mentioned in his post.

     

    You also can use the following way to implement the single instance application.

     

    If so, then I think you can use the Mutex to help you to improve your application. I'm also not very familiar with this method, but it seems better than the method we had used to. So I suggest you have a try to use this class in your application.

     

    http://iridescence.no/post/CreatingaSingleInstanceApplicationinC.aspx

    The word mutex is short for mutual exclusion, and is a synchronization object that can only be owned by a single thread at any given time.

     

    Maybe you want to know how to interact with the existing instance. You can use the SendMessage function to send the file path to the existing application instance, and then override the WndProc function in Form to let the Form can receive the file path message and use this path to show the content, such as updating the current document object.

     

    You may need to know how to p/invoke the win32 function in C#. If you have not knew p/invoke and not familiar with it, you can read more from the following document.

    http://msdn.microsoft.com/en-us/magazine/cc164123.aspx

     

    If there's any concern, please feel free to let me know.

     

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 10, 2011 9:57 AM

All replies

  • hi all,

    I am working in a windows application. On Minimise my application goes to system tray...
    Now When I double click the icon of the same applciation in desktop one more form appears...
    How to make the system tray Icon to get maximise instead of opening a new form again..just like yahoo messenger and Msn ...

    • Merged by Mike Dos Zhang Monday, January 10, 2011 8:27 AM duplicated
    Thursday, January 6, 2011 12:09 PM
  • When you double-click an icon on the desktop a new instance of the application is started. If you want to show the previously opened application instead you have to create a separate launcher program. This launcher program should look if the main EXE is already running on the machine. If it is you will have to switch to it. If it isn't, you will have to launch it. That way you get the desired behavior.

     

    Regards,
    Simon

    Thursday, January 6, 2011 12:47 PM
  • You want to check the box in the Project | Properties | Application Tab | Make Single instance application

    Adam


    Ctrl+Z
    Thursday, January 6, 2011 3:28 PM
  •  

    Hi  Dharmendra_Baghel,

     

    Base on your description, I think you would like the single instance as Simon Bjorstedt mentioned in his post.

     

    You also can use the following way to implement the single instance application.

     

    If so, then I think you can use the Mutex to help you to improve your application. I'm also not very familiar with this method, but it seems better than the method we had used to. So I suggest you have a try to use this class in your application.

     

    http://iridescence.no/post/CreatingaSingleInstanceApplicationinC.aspx

    The word mutex is short for mutual exclusion, and is a synchronization object that can only be owned by a single thread at any given time.

     

    Maybe you want to know how to interact with the existing instance. You can use the SendMessage function to send the file path to the existing application instance, and then override the WndProc function in Form to let the Form can receive the file path message and use this path to show the content, such as updating the current document object.

     

    You may need to know how to p/invoke the win32 function in C#. If you have not knew p/invoke and not familiar with it, you can read more from the following document.

    http://msdn.microsoft.com/en-us/magazine/cc164123.aspx

     

    If there's any concern, please feel free to let me know.

     

    Best wishes,


    Mike [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, January 10, 2011 9:57 AM