Results 1 to 33 of 33

Thread: Windows XP Balloons

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    70

    Windows XP Balloons

    I don't know if that is the correct name for them, but does anyone know how to create those (yellow) XP balloons that pop up when new hardware is installed, etc.?


    Thanks,
    JoshK

  2. #2
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    Umm, they're called ToolTips
    I knew how to do it in VB6. check the tooltip thingie on msdn for vb.net, maybe there is a way to do it with the tooltip control
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    bump bump bump, someone answer plz. I like to know how
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    hellswraith
    Guest
    There is a ToolTip control in my toolbox. Don't know if it will work, but it is there.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2001
    Posts
    70

    Solution

    I found some help on the Microsoft NGs. Here is the post:

    I asked this questiona couple months ago, received the
    same answers, try this, check this, wel, all of this gave
    me a good idea on how to do it and where to start, so
    here is the code for you.... it works fine,it is on some
    app I'm developing right now, if you have anything,
    please contact me at [email protected],
    remember, put the imports declaration before the class or
    module declaration
    Regards

    Code:
    Imports System.Runtime.InteropServices
    ' This claas provides some usefull shell extentions to 
    use with Windows systems
    
    Public Result As Boolean
    <StructLayout(LayoutKind.Sequential)> Public Structure 
    NOTIFYICONDATA
        Dim cbSize As Int32
        Dim hwnd As IntPtr
        Dim uID As Int32
        Dim uFlags As Int32
        Dim uCallbackMessage As IntPtr
        Dim hIcon As IntPtr
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> 
    Dim szTip As String
        Dim dwState As Int32
        Dim dwStateMask As Int32
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> 
    Dim szInfo As String
        Dim uVersion As Int32
        <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> 
    Dim szInfoTitle As String
        Dim dwInfoFlags As Int32
    End Structure
    
    Public Const NIF_MESSAGE As Int32 = &H1
    Public Const NIF_ICON As Int32 = &H2
    Public Const NIF_STATE As Int32 = &H8
    Public Const NIF_INFO As Int32 = &H10
    Public Const NIF_TIP As Int32 = &H4
    Public Const NIM_ADD As Int32 = &H0
    Public Const NIM_MODIFY As Int32 = &H1
    Public Const NIM_DELETE As Int32 = &H2
    Public Const NIM_SETVERSION As Int32 = &H4
    Public Const NOTIFYICON_VERSION As Int32 = &H5
    Public Const NIS_HIDDEN = &H1
    Public Const NIS_SHAREDICON = &H2
    Public Const NIIF_ERROR = &H3
    Public Const NIIF_INFO = &H1
    Public Const NIIF_NONE = &H0
    Public Const NIIF_WARNING = &H2
    Public Const NIM_SETFOCUS = &H4
    Public Const NIIF_GUID = &H5
    Public Declare Function Shell_NotifyIcon 
    Lib "shell32.dll" _
        Alias "Shell_NotifyIconA" (ByVal dwMessage As Int32, _
        ByRef lpData As NOTIFYICONDATA) As Boolean
        Public uNIF As NOTIFYICONDATA
    
    ' Displays a balloon info notification
    
    Public Sub SendBalloonInfoNotification(ByVal strInfo As 
    String)
    With uNIF
       .uFlags = NIF_INFO
       .uVersion = 2000
       .szInfoTitle = "Info"
       .szInfo = strInfo
       .dwInfoFlags = NIIF_INFO
    End With
    Result = Shell_NotifyIcon(NIM_MODIFY, uNIF)
    End Sub
    
    ' Displays a balloon warning notification
    
    Public Sub SendBalloonWarningNotification(ByVal 
    strWarning As String)
    With uNIF
       .uFlags = NIF_INFO
       .uVersion = 2000
       .szInfoTitle = "Warning"
       .szInfo = strWarning
       .dwInfoFlags = NIIF_WARNING
    End With
    Result = Shell_NotifyIcon(NIM_MODIFY, uNIF)
    End Sub
    
    ' Displays a balloon error notification
    
    Public Sub SendBalloonErrorNotification(ByVal strError As 
    String)
    With uNIF
       .uFlags = NIF_INFO
       .uVersion = 2000
       .szInfoTitle = "Error"
       .szInfo = strError
       .dwInfoFlags = NIIF_ERROR
    End With
    Result = Shell_NotifyIcon(NIM_MODIFY, uNIF)
    End Sub
    
    ' Removes the application icon from the system tray
    
    Public Sub RemoveIconFromTray(ByRef frmForm As 
    System.Windows.Forms.Form)
    With uNIF
       .cbSize = Marshal.SizeOf(uNIF)
       .hwnd = frmForm.Handle()
       .uID = 1
    End With
    With Shell_NotifyIcon(NIM_DELETE, uNIF)
    End With
    End Sub
    ' Adds a application icon to system tray
    
    Public Sub AddIconToTray(ByRef frmForm As 
    System.Windows.Forms.Form)
    With uNIF
       .cbSize = Marshal.SizeOf(uNIF)
       .hwnd = frmForm.Handle
       .uID = 1
       .uFlags = NIF_MESSAGE Or NIF_ICON Or NIF_TIP
       .uCallbackMessage = New IntPtr(&H500)
       .uVersion = NOTIFYICON_VERSION
       .hIcon = frmForm.Icon.Handle
    End With
    Result = Shell_NotifyIcon(NIM_ADD, uNIF)
    End Sub
    ___________
    JoshK
    MSN Messenger:
    [email protected]

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428
    umm since you're using APIs it's called unmanaged code?
    I think there should be a way to do the whole thing with the framework
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  7. #7
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    yeah

    you write a managed c++ assembly that uses the unmanged api and it's ok to use the api then

    the framework has problems. namely as usual Microsoft forgot to include full access to the windows programming model. you would think that after all the work they putt into it the would have provided at least a limetted WIN32 API wrapper assembly.... but sometimes vb6 is just better or you have to make wrapper classes with managged c++
    Magiaus

    If I helped give me some points.

  8. #8
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Cool oh

    the ballon tips are supports in win 2k as well. it just isn't used all over the place.
    Magiaus

    If I helped give me some points.

  9. #9
    Frenzied Member MrGTI's Avatar
    Join Date
    Oct 2000
    Location
    Ontario, Canada
    Posts
    1,277

    Post

    I've never seen a way to invoke the factory built in OS balloon tooltips, but i have seen quite a few code samples of ways to make it happen.

    Try this example: Balloon Window
    ~Peter


  10. #10
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Really, all you need to do is:

    1) inherit a form
    2) In its onpaint event, create a graphics path that draws an outline of a balloon, fills it, and then clips the form region by setting its region property to a new region that encompasses only the graphics path.

    3) put a timer on the form, and Me.Dispose in timer_tick event
    4) set the form border style = none

    5) almost forgot : set the backcolor of the form to some odd color, and use that color for the transparency key.

  11. #11
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    i tried the code from above. it dosnt do anything at all, not even give me an error. any ideas?
    i copied the code into a new module. then i made a form with a button and this code: SendBalloonInfoNotification("test")
    ...?

    can someone verify that the code above actually works?

    thanks.

  12. #12
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    I just ran the demo project but that works fine on my machine.

  13. #13
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    by demo project, you mean that you implemented the code posted by joshK? that is what i'm interested in.

  14. #14
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    No I meant the code in the link from MrGTI.

  15. #15
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    can you check the other one?

  16. #16
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    i've posted the balloon tooltip that i made in the vb.net section of the codebank Full Color Balloon ToolTips with Icon / Title
    enjoy
    this is the kind of thing to expect...
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  17. #17
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    thats cool. i like it...

    but what i really want is to use the notify balloons included in windows XP that pop up from the tray icons, like when a network connection or new hardware is found.

    thanks...

  18. #18
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    ah , you mean like this then ...

    i've been busy trying to work it out most of the day ( between feeding / changing babies )
    first add a reference to Imports System.Runtime.InteropServices at the top of your form , then bung this code in your form ....
    VB Code:
    1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    2.         With NotifyIcon1
    3.             .Icon = DirectCast(Me.Icon, Icon)
    4.             .Visible = True
    5.         End With
    6.     End Sub
    7.  
    8.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    9.         Dim notifyballoon As New ClsNotifyBalloon()
    10.         notifyballoon.DisplayBalloon(Me.Text, "the tooltip text", NotifyIcon1, ClsNotifyBalloon.ToolTipIcon.TTI_INFO)
    11.     End Sub
    12.  
    13. '/// in either a seperate Class , or below your form's End Class statement .....
    14.  
    15. Public Class ClsNotifyBalloon
    16.  
    17.     <StructLayout(LayoutKind.Sequential)> _
    18.     Public Structure NOTIFYICONDATA
    19.         Public cbSize As Integer
    20.         Public hwnd As IntPtr
    21.         Public uID As Integer
    22.         Public uFlags As Integer
    23.         Public uCallbackMessage As Integer
    24.         Public hIcon As IntPtr
    25.         <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
    26.         Public szTip As String
    27.         Public dwState As Integer
    28.         Public dwStateMask As Integer
    29.         <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
    30.         Public szInfo As String
    31.         Public uTimeout As Integer
    32.         <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> _
    33.         Public szInfoTitle As String
    34.         Public dwInfoFlags As Integer
    35.     End Structure
    36.  
    37.     <DllImport("Shell32")> _
    38.     Private Shared Function Shell_NotifyIconA(ByVal Msg As Integer, ByRef Nd As NOTIFYICONDATA) As IntPtr
    39.     End Function
    40.  
    41.     Public Enum ToolTipIcon
    42.         TTI_INFO = 1
    43.         TTI_WARNING = 2
    44.         TTI_ERROR = 3
    45.     End Enum
    46.  
    47.     Public Sub DisplayBalloon(ByVal Caption As String, ByVal strText As String, ByVal Ni As NotifyIcon, ByVal ico As ToolTipIcon, Optional ByVal timeout As Integer = 1000)
    48.         Dim notifystruct As NOTIFYICONDATA
    49.         Dim nWindow As NativeWindow = DirectCast(Ni.GetType.GetField("window", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance).GetValue(Ni), NativeWindow)
    50.  
    51.         With notifystruct
    52.             .cbSize = 0
    53.             .dwInfoFlags = 0
    54.             .dwState = 0
    55.             .dwStateMask = 0
    56.             .hIcon = New IntPtr(0)
    57.             .szTip = String.Empty
    58.             .uCallbackMessage = &H200
    59.             .szInfoTitle = Caption
    60.             .uTimeout = timeout
    61.             .hwnd = nWindow.Handle
    62.             .uID = Convert.ToInt32(Ni.GetType.GetField("id", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance).GetValue(Ni))
    63.             .dwInfoFlags = Convert.ToInt32(ico)
    64.             .uTimeout = Environment.OSVersion.Version.Major
    65.             .szInfo = strText
    66.             .uFlags = &H10
    67.             .cbSize = Marshal.SizeOf(notifystruct)
    68.             Shell_NotifyIconA(&H1, notifystruct)
    69.         End With
    70.  
    71.     End Sub
    72.  
    73. End Class
    that should get you started
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  19. #19
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339
    Thats some good stuff dynamic_sysop!

  20. #20
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    awsome

    And there is nothing wrong with using the api either. It's only a mistake to use api if it is limeted to one version of windows and most api works on everything but win95 and there are only a few that don't work 95. Now if you were going to try to run it on a mac.....

    very cool
    Magiaus

    If I helped give me some points.

  21. #21
    Registered User
    Join Date
    Jul 2001
    Posts
    283
    very very nice. thanks so much dynamic_sysop.

  22. #22
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    no problem
    cheers btw Ed
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  23. #23
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: Windows XP Balloons

    dynamic_sysop

    I have used your code in a project of mine and it works great. Thanks! I do have a few XP clients however that for one reason or another it doesn't work on.

    Is there a setting somewhere that can be set to disable or enable them?

    Thanks in advance.
    In life you can be sure of only two things... death and taxes. I'll take death.

  24. #24
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Windows XP Balloons

    Do you know what difference in these machines are from the machines that it does work on?

  25. #25
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Windows XP Balloons

    Quote Originally Posted by cpatzer
    dynamic_sysop

    I have used your code in a project of mine and it works great. Thanks! I do have a few XP clients however that for one reason or another it doesn't work on.

    Is there a setting somewhere that can be set to disable or enable them?

    Thanks in advance.
    I don't think there is any place to specifically disable them. A good test would be to unplug the NIC cable or something that you know causes a balloon tip to popup, and see if it does on the machine that is having the issue. If it does, you know it can be isolated to your code. If it doesn't then it could be isolated to the machines themselves.

    Is this project a .NET 1.1 project? If it is 2.0, then (you probably know) but balloon tips are build right in to the tooltip class in 2.0.

    Also just as a side test, I had a .NET 1.1 project that I used this free balloon tip component on. Might be worth giving it a shot.

    http://www.gotdotnet.com/Community/U...5-C9F36B18A8FC

  26. #26
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: Windows XP Balloons

    Well, I just figured it out. VS 2003 in setup project told me exclude Shell32.dll because it was under Windows file protection. That file was needed on those XP Pro machines in order to show the popup as it is called from the API. I still get an error however the first time it pops up.

    "The procedure entry point _ftol2_see could not be located in the dynamic link library msvcrt.dll"

    Probably a different version of the file will fix the problem. I will keep you updated.
    In life you can be sure of only two things... death and taxes. I'll take death.

  27. #27
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Windows XP Balloons

    you certainly should NOT be distributing Shell32.dll....

    that is a main windows dll (since maybe as far back as windows 3.11), and there is no way these machines are running without it...

    So there is no possible way those XP machines do not have shell32 on them

  28. #28
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: Windows XP Balloons

    Well for some reason when I distribute it with the application, it starts working on those machines. I didn't have time to check for the file first as they are busy at work and I can only disturb them so much. I have other XP pro machines that the application runs perfectly on, just not those unless I include that file. ???
    In life you can be sure of only two things... death and taxes. I'll take death.

  29. #29
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: Windows XP Balloons

    BTW I have had this occur on XP more than one with .NET 1.1 files. I am not sure exactly what causes it, but the applications start working when I include the files VS tells me not to.
    In life you can be sure of only two things... death and taxes. I'll take death.

  30. #30
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: Windows XP Balloons

    Okay, so I have a little more information for the puzzle.

    If Shell32.dll is in the install directory, the application works, minus the error mentioned above. If it is just left in the system32 directory, it doesn't.

    Could it be that I need to patch their .NET 1.1 framework? Maybe it isn't looking in the correct paths for these files on those machines? But then if you include the problem of the error above, something more sinister seems to be at work on those CPUs.
    In life you can be sure of only two things... death and taxes. I'll take death.

  31. #31
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Windows XP Balloons

    Change your API dec to this and see if it has any different result?

    Code:
            <DllImport("shell32.dll")> _
            Shared Function Shell_NotifyIcon(ByVal dwMessage As Integer, ByRef pnid As NOTIFYICONDATA) As Boolean
            End Function
    where you actually call this function, you will have to take the A off the end...

  32. #32
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: Windows XP Balloons

    kleinma,

    As always, you are a fricken genius! Thank you!!! That worked perfectly.
    In life you can be sure of only two things... death and taxes. I'll take death.

  33. #33
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: Windows XP Balloons

    sounds good. I bet not specifying Shell32.dll, and only specifying shell32 was causing the problem.

    I also bet it may be an issue on some machines, but not others based on a few factors (environment variables, specifically the path varaible). That is just a guess, but I can't really think of any other reason why it would map correctly to the API function on some but not on others.

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