|
-
Jun 4th, 2002, 07:34 PM
#1
Thread Starter
Lively Member
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
-
Jun 4th, 2002, 10:43 PM
#2
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!!
-
Jun 6th, 2002, 05:12 PM
#3
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!!
-
Jun 6th, 2002, 06:20 PM
#4
There is a ToolTip control in my toolbox. Don't know if it will work, but it is there.
-
Jun 7th, 2002, 04:54 PM
#5
Thread Starter
Lively Member
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
-
Jun 7th, 2002, 07:25 PM
#6
-
Oct 25th, 2003, 02:34 PM
#7
Frenzied Member
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.
-
Oct 25th, 2003, 02:36 PM
#8
Frenzied Member
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.
-
Oct 27th, 2003, 10:01 AM
#9
Frenzied Member
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

-
Oct 27th, 2003, 10:47 PM
#10
I wonder how many charact
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.
-
Jan 31st, 2004, 08:07 PM
#11
Registered User
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.
-
Jan 31st, 2004, 08:20 PM
#12
I just ran the demo project but that works fine on my machine.
-
Feb 1st, 2004, 10:11 AM
#13
Registered User
by demo project, you mean that you implemented the code posted by joshK? that is what i'm interested in.
-
Feb 1st, 2004, 02:24 PM
#14
No I meant the code in the link from MrGTI.
-
Feb 1st, 2004, 02:25 PM
#15
Registered User
can you check the other one?
-
Feb 2nd, 2004, 09:08 AM
#16
-
Feb 2nd, 2004, 09:16 AM
#17
Registered User
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...
-
Feb 2nd, 2004, 06:47 PM
#18
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:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With NotifyIcon1
.Icon = DirectCast(Me.Icon, Icon)
.Visible = True
End With
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim notifyballoon As New ClsNotifyBalloon()
notifyballoon.DisplayBalloon(Me.Text, "the tooltip text", NotifyIcon1, ClsNotifyBalloon.ToolTipIcon.TTI_INFO)
End Sub
'/// in either a seperate Class , or below your form's End Class statement .....
Public Class ClsNotifyBalloon
<StructLayout(LayoutKind.Sequential)> _
Public Structure NOTIFYICONDATA
Public cbSize As Integer
Public hwnd As IntPtr
Public uID As Integer
Public uFlags As Integer
Public uCallbackMessage As Integer
Public hIcon As IntPtr
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)> _
Public szTip As String
Public dwState As Integer
Public dwStateMask As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> _
Public szInfo As String
Public uTimeout As Integer
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=64)> _
Public szInfoTitle As String
Public dwInfoFlags As Integer
End Structure
<DllImport("Shell32")> _
Private Shared Function Shell_NotifyIconA(ByVal Msg As Integer, ByRef Nd As NOTIFYICONDATA) As IntPtr
End Function
Public Enum ToolTipIcon
TTI_INFO = 1
TTI_WARNING = 2
TTI_ERROR = 3
End Enum
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)
Dim notifystruct As NOTIFYICONDATA
Dim nWindow As NativeWindow = DirectCast(Ni.GetType.GetField("window", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance).GetValue(Ni), NativeWindow)
With notifystruct
.cbSize = 0
.dwInfoFlags = 0
.dwState = 0
.dwStateMask = 0
.hIcon = New IntPtr(0)
.szTip = String.Empty
.uCallbackMessage = &H200
.szInfoTitle = Caption
.uTimeout = timeout
.hwnd = nWindow.Handle
.uID = Convert.ToInt32(Ni.GetType.GetField("id", Reflection.BindingFlags.NonPublic Or Reflection.BindingFlags.Instance).GetValue(Ni))
.dwInfoFlags = Convert.ToInt32(ico)
.uTimeout = Environment.OSVersion.Version.Major
.szInfo = strText
.uFlags = &H10
.cbSize = Marshal.SizeOf(notifystruct)
Shell_NotifyIconA(&H1, notifystruct)
End With
End Sub
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]
-
Feb 2nd, 2004, 07:01 PM
#19
Thats some good stuff dynamic_sysop!
-
Feb 2nd, 2004, 07:37 PM
#20
Frenzied Member
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.
-
Feb 3rd, 2004, 07:11 AM
#21
Registered User
very very nice. thanks so much dynamic_sysop.
-
Feb 3rd, 2004, 07:13 AM
#22
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]
-
Oct 3rd, 2007, 12:47 PM
#23
Fanatic Member
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.
-
Oct 3rd, 2007, 12:50 PM
#24
Re: Windows XP Balloons
Do you know what difference in these machines are from the machines that it does work on?
-
Oct 3rd, 2007, 12:57 PM
#25
Re: Windows XP Balloons
 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
-
Oct 3rd, 2007, 01:20 PM
#26
Fanatic Member
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.
-
Oct 3rd, 2007, 01:24 PM
#27
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
-
Oct 3rd, 2007, 01:41 PM
#28
Fanatic Member
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.
-
Oct 3rd, 2007, 01:42 PM
#29
Fanatic Member
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.
-
Oct 3rd, 2007, 01:51 PM
#30
Fanatic Member
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.
-
Oct 3rd, 2007, 02:10 PM
#31
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...
-
Oct 3rd, 2007, 03:03 PM
#32
Fanatic Member
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.
-
Oct 3rd, 2007, 03:37 PM
#33
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|