Results 1 to 4 of 4

Thread: raise events

  1. #1

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Lightbulb 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.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    You can already do this with the .NET NotifyIcon object.
    VB Code:
    1. Module Module1
    2.  
    3.     Public Sub test(ByVal v As Boolean)
    4.         Static ni As NotifyIcon
    5.         If ni Is Nothing Then ni = New NotifyIcon
    6.         ni.Text = "Test"
    7.         ni.Icon = System.Drawing.Icon.FromHandle(CType(Image.FromFile("E:\Code\NET\Tracker\Resources\del16.ico"), System.Drawing.Bitmap).GetHicon())
    8.         ni.Visible = v
    9.     End Sub
    10.  
    11. End Module
    12.  
    13. 'syntax
    14. Module1.test(True)

  3. #3

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267
    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.

  4. #4

    Thread Starter
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    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:
    1. Module mMain
    2.     Public Sub Main()
    3.         Dim I As Integer = 0
    4.         TrayIcon(True)
    5.         For I = 0 To 500
    6.             'tick
    7.         Next
    8.         TrayIcon(False)
    9.     End Sub
    10.  
    11.     Public Sub TrayIcon(ByVal ShowIcon As Boolean)
    12.         Dim ni As System.Windows.Forms.NotifyIcon
    13.         If ni Is Nothing Then ni = New System.Windows.Forms.NotifyIcon()
    14.         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())
    15.         ni.Visible = ShowIcon
    16.     End Sub
    17. 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
  •  



Click Here to Expand Forum to Full Width