NotifyIcon :-(

taximania

Well-Known Member
Licensed User
Longtime User
This is PSUEDO code:
B4X:
Imports System.some.stuff.here


Namespace MyNotify
   

Public Class MyNotify
   
   Implements IDisposable
   
   private withevents noti as System.Windows.Forms.NotifyIcon


    Public Sub New()
    End Sub
    
    
     Public Property Visible() as Boolean
       Get
          return noti.Visible
       End Get
       Set
          noti.Visible = value
       End Set
    End Property
    
    Public Property Text() As String
       Get
          Return noti.Text
       End Get
       Set
          noti.Text = Value
       End Set
    End Property
    
    Public ReadOnly Property About() As String
       Get
          return "By Taximania"
       End Get
    End Property

    Public Property Icon() As String
       Get
          return noti.IconPath
       End Get
       Set
          noti.IconPath = Value
       End Set
    End Property
    
      Public ReadOnly Property DllVer() As String
       Get
          return "Ver 1.00"
       End Get
    End Property  
    
      
   Public Sub Dispose() Implements System.IDisposable.Dispose
       If Not noti Is Nothing Then
           noti.Dispose()
       End If
    End Sub
   End Class

End Namespace



Icon.Text should be Icon.ContextMenu etc.
Icon.Click (not shown above) toggle's the icon image.

I want to have an app running in the background and toggle it's
on/off status by clicking the NotifyIcon.
(Don't we all)

I've googled and looked into this for the past 2 weeks but
can't get a compiled dll to work :sign0137:


Anyone :sign0085:
 

agraham

Expert
Licensed User
Longtime User
Tke a look at this little app http://www.b4x.com/forum/code-samples-tips/1222-reminder-utility.html written in Basic4ppc which uses NotifyIcon from my ControlsExDesktop to run in the background and pop-up at set times.

Look at the .cs source file for ControlsExDesktop http://www.b4x.com/forum/additional...top-controlsexdesktop-libraries.html#post8248 to see how to implement NotifyIcon in a library. It's in C# but hopefully you will get the idea. Basically you need to hook into at least the NotifyIcon Click event, there are others as well, to know when the user interacts with the NotifyIcon. Ignore the Form Resize event code in the source, it is there for convenience for use with a FormEx and is not necessary to use a NotifyIcon although it is useful to be able to know when a forms state changes.

For VB code that shows how to catch a ScrollBar control event and pass it to Basic4ppc see post #3 here http://www.b4x.com/forum/code-samples-tips/35-how-create-basic4ppc-library.html. There is a C# version in post #1 so if you compare the ScrollBar VB and C# code you should be able to understand my NotifyIcon C# code for the Click event. Essentially the difference is that VB declares a control "WithEvents" then uses "Handles" to attach the event procedures. C# has no equivalen to "WithEvents", you add each individual event to the required event property of the control.
 

taximania

Well-Known Member
Licensed User
Longtime User
I can't get Visual studio 2005 Pro to accept that NotifyIcon
is a member of System.Windows.Forms it's just not there :sign0137:

SharpDevelop 'C# Build finished successfully. .dll's' won't work on my device.
File or assembly bla bla bla Sys Wins Forms Ver 2.0.0.0 not found etc

I've attached my C# SharpDevelop project.
Anyone want to have a look and see if it works, ha ha ha, for them.
If it does, post the .dll please.

Other people's .dll's 'DO' work on my system.

TIA :sign0085:
 

Attachments

  • noti.zip
    8 KB · Views: 130

taximania

Well-Known Member
Licensed User
Longtime User
That's because NotifyIcon is a desktop only control and doesn't exist on the device. The somewhat limited device "equivalent" (it's not really) is Notifier.

Mmm, that sort of explains me wasting my time :sign0148:

But, due to no work today, 'snowed in' :(

I've managed to knock up a proper system notification popup window .dll written with C# and Vis Studio 2005 pro ;)
I'm impressed with myself :) and will post it on a new thread when I've
sorted a couple of bugs.

Cheers Agraham :sign0188:
 

taximania

Well-Known Member
Licensed User
Longtime User
I've managed to knock up a proper system notification popup window .dll written with C# and Vis Studio 2005 pro ;)
I'm impressed with myself :) and will post it on a new thread when I've
sorted a couple of bugs.

Cheers Agraham :sign0188:

It also means I've just spent the last week trying to do something
that has already been done by Agraham. :signOops:

I wasn't aware the notification bubble was already available in B4ppc.

I think, the next time I have an idea, I'll ask Agraham first,
before I start spending time on it :cool:

Thankyou Agraham, I now see where I was going wrong :sign0188:
 
Top