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

hello,

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:
http://opennetcf.org/forums/topic.asp?TOPIC_ID=3418

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
Me.BringToFront()
Me.Show()
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?
securityresearchAsked:
Who is Participating?
 
GranModConnect With a Mentor Commented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0
 
CJCraftCommented:
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.
0
 
securityresearchAuthor Commented:
hello,

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.BringToFront()
Me.Show()

Me.FormBorderStyle = FormBorderStyle.None
Me.FormBorderStyle = FormBorderStyle.FixedSingle
Me.BringToFront()
Me.Show()

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

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.