Credit to AGraham for his Notification and Icon code.
Also to DZT for the link to the NotifyIcon code.
This lib allows you to toggle the notifyIcon Icon in the system tray.
I'll post the class.cs files tomorrow because there's still some
work to be done on this one !
This works on my WM6 device un-compiled, BUT, throws wobblies when
I try to compile it on the desktop 'for' the device.
Instead of the notification bubble in the example, I've got it to turn my
autoanswer and BlueTooth on/off. It works fine, as long as you don't try to
run another b4ppc program (device, code).
@Erel, why do I need to add a desktop reference to a lib to compile for the device, especially when the lib is designed for the device ?
The desktop doesn't like my lib. Won't compile optimized.
Does compile non-optimized, without a reference, but doesn't work on the device.
__________________
.
.
. Don't ask, I'm fine, honest. !!
.
.
. Just a little crazy at times
O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80
The desktop compiler can't (always) read the device libraries. Therefore you need to supply a "dummy" library which will have methods (and namespace) with the same signature.
It will also help other developers write code with the desktop IDE.
I've tried to comment out the lines of code that I think the 'dummy' desktop dll won't like but i've achieved nothing.
Here's my un-edited class.cs code. Based on the example posted by DZT.
I've altered the original Add and Modify methods to convert the icon to a
handle, as used in Agrahams Icon routine. Is this the problem ?
The dll compiles and runs on my device.
What bit's do I need to comment out for a dummy dll so I can compile programs on the desktop using this dll ?
This is really 'bugging' me. All my other dll's have never needed this !
Code:
using System; using System.Collections; using System.Text; using System.Windows.Forms; using System.Drawing; using System.IO; using Microsoft.VisualBasic; using Microsoft.WindowsCE.Forms; using System.Runtime.InteropServices;
namespace NotifyIconNS {
public class NotifyIcon : IDisposable { public event EventHandler Click; private object[] eventObject;
public string IconText { get { return iconText; } set { iconText = value; } }
private String iconText;
private WS ws; private int uID = 5000;
public NotifyIcon() { eventObject = new object[] { this, "Click" };
ws = new WS(this); ws.uID = uID; }
public double DLLVersion { get { return1; } }
public void Add(Icon ike) { IntPtr hIcon; hIcon = ike.Handle;
My example works one day, then doesn't work the day after ???
The icon stays green !! , sometimes !!
Thanks for the help Agraham, perhaps you can sort a work round for this.
I admit defeat, and am done with this.
Google thinks I'm a family member of it
MSDN doesn't
Not quitting the forum, perhaps some of the 'newbies' may
need more essential little questions answered.
If the 'OLD TIMERS' can help, then I'm sat watching
__________________
.
.
. Don't ask, I'm fine, honest. !!
.
.
. Just a little crazy at times
O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80
Finally got my, 'Device IDE', coded programs to work as expected, (on the device).
Yes it was a coding thing on my behalf, very confusing, but 'hey'.
What with the forum being down, i haven't the time to post everything I wanted too. I will do it tomorrow.
@Agraham, i've tried numerous variations for a desktop dummy lib,
the ones that do allow compilation of source code on the desktop, still don't work on the device when the exe is copied to it.
If you can upload the file you mentioned previously, I'll try it.
__________________
.
.
. Don't ask, I'm fine, honest. !!
.
.
. Just a little crazy at times
O2 XDA, GW Evo 2.1 UC WWE Rom, WM6.1
Radio Ver 03.34.90
With Basic4ppc V6.80
Here you are, try this. The name of the desktop assembly doesn't matter but the namespace (I think) and class name of the object and all the public method and property signatures must be identical to those of the device library.
? If you don't show form1 in a compiled device.exe from the desktop it fails to show the icon on the device at start-up.
I think I understand why. The NotifyIcon needs an associated application to send messages to. Without a main form there is no message loop for your application and so nowhere to send messages to so I suspect that in this case the icon addition is cancelled.
Quote:
If you run the device sbp, it works fine.
That's because the device IDE (unlike the desktop) is single threaded and runs your program on the IDE main thread so the NotifyIcon sees, and uses, the message loop of the IDE main window.