Balloon tooltips voor tray icons in VB

Pagina: 1
Acties:
  • 136 views sinds 30-01-2008
  • Reageer

  • Mateyo
  • Registratie: Juli 2001
  • Niet online
Ik ben bezig om een klein programmaatje te schrijven in Visual Basic waarin een tray icon wordt gebruikt. Nu wil ik dus als tooltip zo'n Win2k/WinXp 'balloon tooltip' (ik heb WinXP), maar dit werkt dus niet.

Even een voorbeeldje voor zo'n tooltip:

Afbeeldingslocatie: http://home.planet.nl/~loos0062/tooltip.jpg

Dit is mijn code:

Form1:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Private Sub Form_Load()

Dim nid As NOTIFYICONDATA  ' icon information
Dim retval As Long  ' return value
With nid
 .cbSize = Len(nid)
 .hWnd = Me.hWnd
 .uID = 1
 .uFlags = NIF_ICON Or NIF_INFO
 .hIcon = Me.Icon
 .szInfo = "test" + vbNullChar
 .uTimeoutOrVersion = 15000
 .szInfoTitle = "test" + vbNullChar
 .dwInfoFlags = NIIF_INFO
End With

retval = Shell_NotifyIcon(NIM_ADD, nid)

End Sub

Module1:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Public Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Long

Public Const NIM_ADD = &H0
Public Const NIM_DELETE = &H2
Public Const NIM_MODIFY = &H1
Public Const NIM_SETFOCUS = &H4
Public Const NIM_SETVERSION = &H8

Public Const NIF_ICON = &H2
Public Const NIF_MESSAGE = &H1
Public Const NIF_TIP = &H4
Public Const NIF_STATE = &H8
Public Const NIF_INFO = &H10
Public Const NIS_HIDDEN = &H1
Public Const NIS_SHAREDICON = &H2
Public Const NOTIFYICON_VERSION = &H1
Public Const NIIF_WARNING = &H30
Public Const NIIF_ERROR = &H10
Public Const NIIF_INFO = &H40

Public Type NOTIFYICONDATA
  cbSize As Long
  hWnd As Long
  uID As Long
  uFlags As Long
  uCallbackMessage As Long
  hIcon As Long
  szTip As String * 128
  dwState As Long
  dwStateMask As Long
  szInfo As String * 256
  uTimeoutOrVersion As Long
  szInfoTitle As String * 64
  dwInfoFlags As Long
End Type

Zou iemand hieraan kunnen zien wat er fout is?

  • tus
  • Registratie: November 2000
  • Laatst online: 05-07-2012

tus

Ik weet niet of dit precies is wat je bedoelt. Heb hier geen WIn2k of WinXP namelijk.

Maar ik denk dat je dit bedoelt.
code:
1
2
nid.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
nid.szTip = "Is Dit de Tekst die je bedoelt?" & vbNullChar

  • Mateyo
  • Registratie: Juli 2001
  • Niet online
nid.szTip is, volgens mij, gewoon voor de standaard tooltip en hoeft dus niet ingevuld te worden.

  • BOOTZ
  • Registratie: Maart 2001
  • Laatst online: 10-09 09:46
probeer es zoiets:

tooltiptekst = "bla " & vbnewline & "bla regel 2" & vbnullchar


die vbnewline geeft een nieuwe regel maar ik heb geen idee of dat hier ook werkt...

Maak je eigen poll


  • tus
  • Registratie: November 2000
  • Laatst online: 05-07-2012

tus

Je hebt gelijk die NIF_TIP is alleen voor een tooltip in de tray bar. Je moet dus idd de NIF_INFO hebben. Die presenteert zo'n ballonnetje.

ik kan echter hier niet testen hoe je het pcies moet gebruiken, want nogmaal geen 2K of XP hier. Maar misschien heb je hier wat aan heb ik van www.vbapi.com
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Type NOTIFYICONDATA
  cbSize As Long
  hWnd As Long
  uID As Long
  uFlags As Long
  uCallbackMessage As Long
  hIcon As Long
  szTip As String * 64  ' Windows 2000: make this String * 128
  ' The following data members are only valid in Windows 2000!
  ' (uncomment the following lines to use them)
  'dwState As Long
  'dwStateMask As Long
  'szInfo As String * 256
  'uTimeoutOrVersion As Long
  'szInfoTitle As String * 64
  'dwInfoFlags As Long
End Type
  

NIF_INFO
Windows 2000: Use a balloon-style tooltip instead of the regular pop-up tooltip. The szInfo, szTimeOut, szInfoTitle, and dwInfoFlags data members are used. 

szInfo
Windows 2000: The null-terminated string to use for the icon's balloon-style tooltip. 

uTimeoutOrVersion
Windows 2000: The timeout value, in milliseconds, for the display of the balloon-style tooltip. If outside of Windows's allowable range, the timeout value will be "pushed" into the range of valid timeout periods.

Or, if Shell_NotifyIcon had been called with the NIM_VERSION flag, this instead specifies whether to use Windows 95 or Windows 2000 behavior. By default, Windows 2000 will use different messages in some cases to communicate with the owning window. For backward compatibility, you should use the older behavior. This is one of the following flags: 
0
Use the Windows 95-style behavior. 
NOTIFYICON_VERSION
Use the Windows 2000-style behavior. 

szInfoTitle
The null-terminated string to use as the title of the balloon tooltip. This will appear in boldface above the regular text. 

dwInfoFlags
If desired, one of the following flags specifying the icon to display to the left of the balloon tooltip text. Set this as 0 to not use an icon. 
NIIF_WARNING
A warning icon. 
NIIF_ERROR
An error icon. 
NIIF_INFO
An information icon.

Suc6

  • Mateyo
  • Registratie: Juli 2001
  • Niet online
Mijn code heb ik dus ook van vbapi.com, maar dat werkte dus niet helemaal

  • Mateyo
  • Registratie: Juli 2001
  • Niet online
Even een trapje omhoog :)
Pagina: 1