|
-
Sep 16th, 2003, 02:13 PM
#1
Thread Starter
Frenzied Member
raise events
Is it possible to raise events in a class from a nested class within it?
I haven't started this yet but what I am doing is making a code only NotifyIcon. In other words it can be used with out a form. To do that I have to have an internal window to provide a handle and to catch messages. What I tried first was just inheriting the System.Windows.Forms.Native window but I don't want the class to expose all the NativeWindow members because well a tray icon doesn't need to create a window or anything like that it should all be hidden. So what I am thinking is make a imple nested class that is a window class with a WindowProc and raise the needed events for the tray class from inside the window class. I just don't know how to do it.
I am also adding Balloon tips for supported os because ms always jips us some how....
I am considering using c++ but I come to the same basic problem....
Magiaus
If I helped give me some points.
-
Sep 16th, 2003, 02:34 PM
#2
You can already do this with the .NET NotifyIcon object.
VB Code:
Module Module1
Public Sub test(ByVal v As Boolean)
Static ni As NotifyIcon
If ni Is Nothing Then ni = New NotifyIcon
ni.Text = "Test"
ni.Icon = System.Drawing.Icon.FromHandle(CType(Image.FromFile("E:\Code\NET\Tracker\Resources\del16.ico"), System.Drawing.Bitmap).GetHicon())
ni.Visible = v
End Sub
End Module
'syntax
Module1.test(True)
-
Sep 16th, 2003, 02:37 PM
#3
Thread Starter
Frenzied Member
okay. I know I tried doing that. I'll just have to try it again. It gave me an error about cannot create without a form.
Magiaus
If I helped give me some points.
-
Sep 16th, 2003, 02:53 PM
#4
Thread Starter
Frenzied Member
thanks
your right it works fine. I wonder why I couldn't get it to work the first time i tried it..... well now i just need to build the context menu and set it up...
VB Code:
Module mMain
Public Sub Main()
Dim I As Integer = 0
TrayIcon(True)
For I = 0 To 500
'tick
Next
TrayIcon(False)
End Sub
Public Sub TrayIcon(ByVal ShowIcon As Boolean)
Dim ni As System.Windows.Forms.NotifyIcon
If ni Is Nothing Then ni = New System.Windows.Forms.NotifyIcon()
ni.Icon = System.Drawing.Icon.FromHandle(CType(System.Drawing.Image.FromFile("C:\Program Files\Microsoft Visual Studio\Common\Graphics\Icons\Misc\MISC03.ICO"), System.Drawing.Bitmap).GetHicon())
ni.Visible = ShowIcon
End Sub
End Module
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|