system tray icon application

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

Im developing a pocket pc app ind vb dot net and basically when the
application
starts i would like a icon to appear on the pocket pc toolbar.
Which when I mouse click on it displays a menu

Any links,sample code is appreciated

TIA

Stu
 
When you say toolbar, you mean the titlebar at the top of the screen? If so
you need the SHNotification* APIs which you'll find neatly wrapped in the
OpenNETCF.WindowsCE.Forms.Notification class in the SDF. There isn't a
sample included on how to use it, but it's designed to follow the .NETCF
v2.0 equivalent, and there is a sample for that here:-
http://msdn2.microsoft.com/en-us/library/7ctk0s42(en-us,vs.80).aspx

It should allow you to do almost everything the v2.0 control does.

Peter
 
No at the bottom of the screen

Ive created both 16x16 and 32x32 ico files
and ive tried including as content in the project and compile
assign it as a solutions icon absolutley nothing!!
Im using vis studio 2003 and vb dot net

Basically i want an image to be displayed on the system toolbar at the bottom.
Ive based my form load code on Mr Feinmans article (Thanks alex very useful)
But nothing comes up in the emulator!!

Pray tell me how are you expected to develop apps for the pocket PC when
trying to display an Icon appears to be a mamoth task!!!

An ideas please!!!




' Extract icon from the application's exe
' This requires that app icon were set in the project properties
Dim szPath As String =
Path.GetDirectoryName([Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName)
Dim szAssemb =
[Assembly].GetExecutingAssembly().GetModules(0).FullyQualifiedName

Dim resources As System.Resources.ResourceManager = New
System.Resources.ResourceManager(GetType(Form1))

Me.Icon = CType(resources.GetObject("$this.Icon"),
System.Drawing.Icon)


Me.mainMenu1 = New System.Windows.Forms.MainMenu
Me.Menu = Me.mainMenu1
Me.Text = "Form1"

ExtractIconEx(szAssemb, 0, 0, hIcon, 1)

' Fill NOTIFYICONDATA with data
Dim nid As New NOTIFYICONDATA
' In our struct definition we have omitted emebedded wchar array
size 64 - we need to account for it
Dim cbSize As Integer = Marshal.SizeOf(nid) + 64 *
Marshal.SystemDefaultCharSize
' Allocate memory
Dim pData As IntPtr = LocalAlloc(LPTR, cbSize)
Dim ltemp As IntPtr
' Set fields of the NOTIFYICONDATA (see SDK documentation)
nid.cbSize = cbSize
nid.hIcon = hIcon
nid.hWnd = msgWnd.Hwnd
nid.uCallbackMessage = msg
nid.uID = 1
nid.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
Marshal.StructureToPtr(nid, pData, False)

' Add tooltip
Dim arrTooltip As Char() = "My tooltip".ToCharArray()
ltemp = LocalAlloc(LPTR, pData.ToInt32() + Marshal.SizeOf(nid))

Marshal.Copy(arrTooltip, 0, ltemp, arrTooltip.Length)

' Register with shell
Dim ret As Boolean = Shell_NotifyIcon(NIM_ADD, pData)
LocalFree(pData)

' Set up event handler to handle incoming messages
AddHandler msgWnd.AfterMessageEvent, AddressOf
msgwnd_AfterMessageEvent
 
Back
Top