C# on Windows CE: minimize window to system tray and restore by click on tray icon

Posted on 2006-05-17
Last Modified: 2013-12-27

i've got a question concerning c# / windows ce  / system tray icons:

- i add a notifyicon (from OpenNETCF)
- i minimize my window
- i want to use the notifyicon's "click" to restore the window

this doesn't seem to work...
the window doesn't get restored properly, no matter what i do.

i googled and found only one relevant hit:

the developer reported he had to use the following hack:

--- begin citation ---
Private Sub NotifyIcon1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseUp
Me.FormBorderStyle = FormBorderStyle.None
Me.FormBorderStyle = FormBorderStyle.FixedSingle
End Sub

For some reason, you need to set FOrmBorderStyle to both NONE and FixedSingle. If you leave out the .none, nothing happens, if you leave out the FixedSingle, the window restores, but the minimize button in the upper-right wont work again <shrug>.
--- end citation ---

but even this hack doesn't work reliably - only every second try or so...

has anybody tried this before; is there a "proper" solution?
Question by:securityresearch
    LVL 7

    Expert Comment

    Are you able to move to compact framework 2.0 it has a built-in Microsoft notify component that may resolve issue out of box.

    If not let us know.

    Author Comment


    no, unfurtonately, that's not an option, i have to stick to the old framework.

    i managed to do this as a workaround:

    Me.FormBorderStyle = FormBorderStyle.None
    Me.FormBorderStyle = FormBorderStyle.FixedSingle

    Me.FormBorderStyle = FormBorderStyle.None
    Me.FormBorderStyle = FormBorderStyle.FixedSingle

    if i do the hack two times in a row it works most of the time (90%).
    - not the nicest "solution"...

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Progress means simplifying, not complicating. Bruno Munari Preface How to detect the name of the internal storage or an SD-card on Windows Mobile device from the desktop application? I got this question, when I was working on a PC applicati…
    Preface: This article is part of a series focused on cross platform mobile app development (specifically Android and iOS) using the Alloy framework and Titanium Studio made by Appcelerator ( This article presumes a wor…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now