Bubble Notification

T

Thomas Hall

I'm using OpenNETCF.WindowsCE.Forms.Notification (SDF v.1.4) to provide
notification bubbles for certain app events. For some reason, the
notification icon is not being displayed in the system tray
notification area. I haven't specified one, so I expected the
application's 16x16 icon to be used.

Here's my code:

Private Sub StartNotifyEngine()
m_objNotifyBubble = New OpenNETCF.WindowsCE.Forms.Notification
End Sub

Private Sub StopNotifyEngine()
If Not (m_objNotifyBubble Is Nothing) Then
' Remove previous notification.
m_objNotifyBubble.Visible = False
m_objNotifyBubble = Nothing
End If
End Sub

Public Sub ShowNotifyBubble(ByVal strNotifyText As String, _
Optional ByVal strBubbleTitle As String = "New Message Received")
' Check for previous unanswered notification.
If m_objNotifyBubble.Visible Then
m_objNotifyBubble.Visible = False
End If

Dim sbHTML As New StringBuilder

With sbHTML
' Build HTML for bubble notification.
.Append("<html><body>")
.Append("<h3>")
.Append(strNotifyText)
.Append("</h3>")
.Append("<hr />")
.Append("<h4>")
.Append("Received at ")
.Append(Now.ToString)
.Append("</h4>")
.Append("<br><form method='POST'><input type=button
value='Close' name='cmdClose'></form>")
.Append("</body></html>")
End With

With m_objNotifyBubble
.Caption = strBubbleTitle
.Critical = False
.InitialDuration = 3600
.Text = sbHTML.ToString
.Visible = True
End With
End Sub

Private Sub OnBalloonChanged(ByVal sender As Object, _
ByVal e As OpenNETCF.WindowsCE.Forms.BalloonChangedEventArgs)
Handles m_objNotifyBubble.BalloonChanged
If Not e.Visible Then
m_objNotifyBubble.Visible = False
End If
End Sub

Private Sub OnResponseSubmitted(ByVal sender As Object, _
ByVal e As OpenNETCF.WindowsCE.Forms.ResponseSubmittedEventArgs)
Handles m_objNotifyBubble.ResponseSubmitted
m_objNotifyBubble.Visible = False
End Sub

Thanks in advance,
Thomas Hall
 
P

Peter Foot [MVP]

You are right that it should use your exe main icon for display - the .NETCF
v2.0 class is alot more flexible in this regard -
Microsoft.WindowsCE.Forms.Notification. Make sure the icon you use for your
application has a 16x16 2bit b/w version.

Peter
 
T

Thomas Hall

Peter,

Thanks for your reply. I'm no graphics person but if I understand
where you're going with this, the rendering of my color 16x16 program
icon is causing it not to be displayed in the tray?

Since I want the pretty color icon displayed in 'Programs', should I
create a native DLL (e.g. AppIcons.dll) with the 2 bit 16x16 and use
LoadIcon to get the handle for it? If I did this, could I embed the
dll into managed exe and still access the icon?

In other words, can I get there from here? ;-)
 
P

Peter Foot [MVP]

A single icon file can contain multiple sizes and colour depths. It's normal
to provide 32x32 and 16x16 in 256 for your app icon. You can add a
monochrome 16x16 too for best presentation with the Notification tray. How
you do this depends on your icon editor of choice, you can do this with
Visual Studio or any number of third-party tools.

Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top