• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6019
  • Last Modified:

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?
0
securityresearch
Asked:
securityresearch
1 Solution
 
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
 
GranModCommented:
PAQed with points refunded (500)

GranMod
Community Support Moderator
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now