TrayIcon avec Balloon anlegen et abfragen de Andreas Miethe:[CODE]Ab Profan 7.0
#######################
Thema : Tray-Icon
Balloon-Tips
#######################
Andreas Miethe
août 2003
#######################
Balloon-Tips sommes seulement disponible si dans qui Registry sous
HKEY_CURENT_USER SoftwareMicrosoftWindowsCurrentVersionExplorerAdvanced
qui Wert EnableBalloonTips sur 1 steht.
Möglicherweise muss qui Schlüssel seulement angelegt volonté.
#######################
DEF HiWord(1) And(&(1)>>16,$FFFF)
DEF LoWord(1) And(&(1),$FFFF)
DEF GetFileVersionInfoSize(2) ! Version,GetFileVersionInfoSizeA
DEF GetFileVersionInfo(4) ! Version,GetFileVersionInfoA
DEF VerQueryValue(4) ! Version,VerQueryValueA
DEF GetSysColor(1) ! user32,GetSysColor
DEF SetWindowPos(7) ! User32,SetWindowPos
DEF LoadIcon(2) ! User32,LoadIconA
DEF Shell_NotifyIcon(2) ! shell32,Shell_NotifyIconA
DEF RegisterWindowMessage(1) ! user32,RegisterWindowMessageA
DEF SetForegroundWindow(1) ! user32,SetForegroundWindow
DEF GetCursorPos(1) ! user32,GetCursorPos
DEF MapWindowPoints(4) ! user32,MapWindowPoints
DEF XSetTimer(4) ! user32,SetTimer
DEF &WM_USER $0400
DEF &COLOR_BTNFACE 15
DEF &SWP_NOACTIVATE $10
DEF &SWP_NOREDRAW $8
DEF &NIF_ICON $2
DEF &NIF_TIP $4
DEF &NIF_MESSAGE $1
DEF &NIF_INFO $10
DEF &NIM_ADD $0
DEF &NIM_DELETE $2
DEF &NIM_MODIFY $1
DEF &NIM_SETVERSION $4
DEF &NIM_SETFOCUS $3
Icônes
DEF &NIIF_ERROR $3
DEF &NIIF_INFO $1
DEF &NIIF_NONE $0
DEF &NIIF_WARNING $2
DEF &NIF_STATE $8
DEF &NIS_HIDDEN $1
DEF &NIS_SHAREDICON $2
DEF &NIN_BALLOONSHOW $0402
DEF &NIN_BALLOONHIDE $0403
DEF &NIN_BALLOONTIMEOUT $0404
DEF &NIN_BALLOONUSERCLICK $0405
DEF &WM_CLOSE $10
DEF &WM_LBUTTONDOWN $0201
DEF &WM_RBUTTONDOWN $0204
DEF &WM_SYSCOMMAND $0112
DEF &SC_RESTORE $F120
DEF &WM_SHELLNOTIFY $0405 &WM_USER + 5 shell notify message
DEF &uID 7777
DEF &NOTIFYICONDATA_V1_SIZE 88 pre-5.0 structure size
DEF &NOTIFYICONDATA_V2_SIZE 488 pre-6.0 structure size
DEF &NOTIFYICONDATA_V3_SIZE 504 6.0+ structure size
Déclarer NOTIFYICONDATASIZE&
Proc IsShellVersion
Déclarer Retval&,K$
Déclarer nBufferSize&,nUnUsed&
Déclarer sDLLFile$
Déclarer lpBuffer#,lplpBuffer&,lpBufferLenght&
sDLLFile$ = Shell32
nBufferSize& = GetFileVersionInfoSize(addr(sDLLFile$), addr(nUnused&))
Faible lpBuffer#,nBufferSize&
GetFileVersionInfo(addr(sDLLFile$),0,nBufferSize&,lpBuffer#)
k$ = \
VerQueryValue(lpBuffer#,addr(k$),addr(lplpBuffer&),Addr(lpBufferLenght&))
RetVal& = Word(lplpBuffer&,10)
Dispose lpBuffer#
Retour RetVal&
ENDPROC
qui Grösse qui NotifyIcon- Struktur ist dépendant de qui Version qui
Shell32.dll, daher muss seulement qui Version geprüft volonté.
IsShellVersion
Si @&(0) = 5 Version = 5
NOTIFYICONDATASIZE& = &NOTIFYICONDATA_V2_SIZE
ElseIf @&(0) = 6 Version = 6
NOTIFYICONDATASIZE& = &NOTIFYICONDATA_V3_SIZE
D'autre Version = avant 5
NOTIFYICONDATASIZE& = &NOTIFYICONDATA_V1_SIZE
Endif
Déclarer Point#,TB_CREATED&
Déclarer InfoText$,InfoTitle$,Tip$,Icon$,RegMessage$
Tip$ = Balloon-Tips © Andreas Miethe * août 2003
InfoText$ = cet Tray-Icon reagiert sur qui rechte comment aussi sur qui linke Bouton de la souris
InfoText$ = InfoText$ +
+Tip$+chr$(0)
InfoTitle$ = INFO MAX 255 marque
Icon$ =A
RegMessage$ = IconCreated
Struct Point = x&, y&
Struct Note = cbSize&,hWnd&,uID&,uFlags&,uCallbackMessage&,hIcon&,szTip#(128),
dwState&,dwStateMask&,szInfo#(256),uTimeoutAndVersion&,szInfoTitle#(64),
dwInfoFlags&,guidItem#(16)
Déclarer Ende&,Note#
SetTrueColor 1
SetErrorlevel 0
Fenêtre -1000,0 - 0,0la fenêtre près de den Bildschirm
CLS GetSysColor(&COLOR_BTNFACE)
ShowWindow(%hwnd,0)la fenêtre cacher
SetWindowPos(%hwnd,0,0,0,640,480,OU(&SWP_NOREDRAW,&SWP_NOACTIVATE))neue Position
Faible Note#,Note
Claire Note#
Note#.cbSize& = NOTIFYICONDATASIZE&
Note#.hWnd& = %hwnd
Note#.uID& = &uID
Note#.hIcon& = LoadIcon(%hInstance,ADDR(Icon$))
Note#.uFlags& = Or(Or(Or(&NIF_ICON,&NIF_TIP),&NIF_MESSAGE),&NIF_STATE)
Note#.uCallbackMessage& = &WM_SHELLNOTIFY
Note#.szTip# = Tip$
Note#.dwState& = &NIS_SHAREDICON
Note#.dwStateMask& = Or(&NIS_HIDDEN,&NIS_SHAREDICON)
Note#.uTimeoutAndVersion& = 50$3
normales Icon insérer
Shell_NotifyIcon(&NIM_ADD, Note#)
Shell_NotifyIcon(&NIM_SETVERSION, Note#)
modifizieren pour Balloon-Tips
Note#.uFlags& = &NIF_INFO
Note#.szInfo# = InfoText$
Note#.szInfoTitle# = InfoTitle$
Note#.dwInfoFlags& = &NIIF_INFO
Note#.uTimeoutAndVersion& = 16000TimeOut
Shell_NotifyIcon(&NIM_MODIFY,Note#)
TB_CREATED& = RegisterWindowMessage(ADDR(RegMessage$))
Utilisateur Messages &WM_SHELLNOTIFY,TB_CREATED&,&WM_CLOSE
ShowWindow(%hwnd,0)
settimer 15000
Whilenot Ende&
Waitinput
Si %wmtimer
le détour si MinTimeOut größer comme 15 sekunden ist
Killtimer
Note#.szInfo# = chr$(0)
Note#.szInfoTitle# = chr$(0)
Shell_NotifyIcon(&NIM_MODIFY,Note#)
MessageBox(Zeit abgelaufen,,0)
Imprimer Zeit abgelaufen
Endif
Si %UMessage = &WM_CLOSE
Shell_NotifyIcon(&NIM_DELETE,Note#)
Ende& = 1
Endif
Si %UMessage = TB_CREATED&Explorer-Crash. Icon récente anlegen
Shell_NotifyIcon(&NIM_ADD,Note#)
Endif
Si %UMessage = &WM_SHELLNOTIFY
Si &ULParam = &NIN_BALLOONTIMEOUT
Killtimer
MessageBox(Zeit abgelaufen,,0)
Imprimer Zeit abgelaufen
Endif
Si &ULParam = &NIN_BALLOONUSERCLICK
MessageBox(Klick,,0)
Imprimer Klick
Endif
Si &ULParam = &NIN_BALLOONHIDE
MessageBox(weg,,0)
Imprimer weg
Endif
Si &ULParam = &WM_RBUTTONDOWNrechter Mausbutton
SetForegroundWindow(%hWnd)
Faible Point#,Point
CreateMenu
AppendMenu 100,la fenêtre cacher
AppendMenu 101,la fenêtre montrer
Séparateur
AppendMenu 102,Ende
GetCursorPos(Point#)
MapWindowPoints(%Desktop,%hwnd,Point#,1)
Trackmenu Point#.x&,Point#.y&
Dispose Point#
Endif
Si &ULParam = &WM_LBUTTONDOWNlinker Mausbutton
SetForegroundWindow(%hWnd)
Faible Point#,Point
CreateMenu
AppendMenu 200,Linker Button 1
AppendMenu 201,Linker Button 2
Séparateur
AppendMenu 202,Linker Button 3
GetCursorPos(Point#)
MapWindowPoints(%Desktop,%hwnd,Point#,1)
Trackmenu Point#.x&,Point#.y&
Dispose Point#
Endif
Endif
Si MenuItem(100)
ShowWindow(%hwnd,0)
ElseIf Menuitem(101)
SendMessage(%hwnd,&WM_SYSCOMMAND,&SC_RESTORE,0)
ElseIf Menuitem(102)
Shell_NotifyIcon(&NIM_DELETE,Note#)
Ende& = 1
ElseIf Menuitem(200)
settimer 15000
Shell_NotifyIcon(&NIM_MODIFY,Note#)Balloontip Montrer
Endif
Wend
Salve, iF.