Le forum (ô combien francophone) des utilisateurs de Powerbuilder.
Pages: 1
Bonjour chers PBaDonfiens,
Je suis en train de développer une application qui pourra avertir l'utilisateur de l'imminence d'un événement planifié dans le futur. J'ai pensé à un simple pop up en mode response mais cela présente deux inconvénients:
-L'utilisateur doit avoir l'application principale en avant-plan
-Si un autre fenêtre de type response est ouverte, l'ouverture d'un autre response risque de planter solide (expérience d'un collègue)
J'ai donc choisi de me tourner vers les infos bulles de la barre de tâches qui semblent si populaire pour plusieurs applications. Je suis donc dans le processus de mapper un API de windows et tout le tralala et je me demandais si certains d'entre vous ont déjà exploré cette fonction.
Jusqu'à maintenant j'ai déterminé que la fonction qui semble gérer les infos bulles est "Shell_NotifyIcon" et que les paramètres pour jouer avec les messages jaunes style BD se trouvent dans la structure "NOTIFYICONDATA".
Votre expérience serait appréciée, sinon je serai le premier à bricoler cela et je vous tiendrai au courant durant le processus!
Dernière modification par Beagle (24-01-2009 16:20:56)
Hors ligne
Salut, j'ai trouvé qqchose qui pourrait t'être utile :
Building a Systray Icon
By Ken Howe
I've been getting a lot of requests for an example of how to put an icon in the systray. The systay is that small box near the time on the task bar. The object I've described is the main work horse and you should import this object into your Powerbuilder library.
Basically there are a bunch of API calls which this object calls. The functions on the object provide a nice friendly interface to the API calls:Code: pb
//--START OF OBJECT $PBExportHeader$nca_systray.sru $PBExportComments$Systray Utilities V2.0 forward global type nca_systray from nonvisualobject end type end forward type notifyicondata from structure long cbsize long hwnd long uid long uflags long ucallbackmessage long hicon character sztip[ 64 ] end type global type nca_systray from nonvisualobject autoinstantiate end type type prototypes function long Shell_NotifyIcon ( long dwMessage, ref notifyicondata lpData ) library "shell32" function long LoadImageA ( long hInstance, string lpszName, uint uType, int a, int b, uint l ) library "user32" function long LoadIconA( long hInstance, long lpcstr ) library 'user32' end prototypes type variables Protected: notifyicondata istr_lpdata window iw_win boolean ib_SystemTrayExists CONSTANT long NIF_MESSAGE=1 CONSTANT long NIF_ICON=2 CONSTANT long NIF_TIP=4 CONSTANT long NIM_ADD=0 CONSTANT long NIM_MODIFY=1 CONSTANT long NIM_DELETE=2 end variables forward prototypes public subroutine addicon (string as_iconname, string as_tiptext, window aw_win) public subroutine delicon () public subroutine changeicon (string as_IconName) public subroutine changetip (string as_TipText) public function boolean ib_systemtrayexists () end prototypes public subroutine addicon (string as_iconname, string as_tiptext, window aw_win); IF ib_SystemTrayExists THEN RETURN iw_Win = aw_Win istr_lpData.szTip = as_TipText + Char ( 0 ) istr_lpData.uFlags = NIF_ICON + NIF_TIP + NIF_MESSAGE istr_lpData.uID = 100 istr_lpData.cbSize = 88 istr_lpData.hwnd = Handle ( iw_Win ) istr_lpData.uCallbackMessage = 1024 istr_lpData.hIcon = LoadImageA( 0, as_IconName, 1, 0, 0, 80 ) shell_notifyicon ( NIM_ADD, istr_lpData ) ib_SystemTrayExists = TRUE end subroutine public subroutine delicon (); IF NOT ib_SystemTrayExists THEN RETURN istr_lpData.uID = 100 istr_lpData.cbSize = 88 istr_lpData.hwnd = Handle ( iw_Win ) shell_notifyicon ( NIM_DELETE, istr_lpData ) ib_SystemTrayExists = FALSE end subroutine public subroutine changeicon (string as_IconName); IF NOT ib_SystemTrayExists THEN RETURN istr_lpData.hIcon = LoadImageA ( 0, as_IconName, 1, 0, 0, 80 ) istr_lpData.uFlags = NIF_ICON shell_notifyicon( NIM_MODIFY, istr_lpData ) end subroutine public subroutine changetip (string as_TipText); IF NOT ib_SystemTrayExists THEN RETURN istr_lpData.szTip = as_TipText + Char ( 0 ) istr_lpData.uFlags = NIF_TIP shell_notifyicon ( NIM_MODIFY, istr_lpData ) end subroutine public function boolean ib_systemtrayexists (); RETURN ib_systemtrayexists end function on nca_systray.create TriggerEvent( this, "constructor" ) end on on nca_systray.destroy TriggerEvent( this, "destructor" ) end on event destructor; IF ib_SystemTrayExists THEN this.DelIcon() end event //--END OF OBJECT // Then in your window you need to instantiate the object and call the addicon function. In your open event call the function like: inca_sysTray.AddIcon( 'pbbrtray.ico', 'PBBrowse V2', this ) // Then you need to add an event to your window so you can receive notification of when the user clicked your systray icon. Add an event called systray for pbm_custom01. // Then to make the following script work, add a static text called st_status to the window and add this code to the systay event: constant long WM_MOUSEMOVE=512 constant long WM_LBUTTONDOWN=513 constant long WM_LBUTTONUP=514 constant long WM_LBUTTONDBLCLK=515 constant long WM_RBUTTONDOWN=516 constant long WM_RBUTTONUP=517 constant long WM_RBUTTONDBLCLK=518 Choose case Message.LongParm case WM_MOUSEMOVE st_status.text = 'Mouse Moved' case WM_LBUTTONDOWN st_status.text = 'Left Mouse Down' case WM_LBUTTONUP st_status.text = 'Left Mouse Up (clicked)' case WM_LBUTTONDBLCLK st_status.text = 'Left Mouse Double Clicked' case WM_RBUTTONUP st_status.text = 'Right Mouse Up (clicked)' case WM_RBUTTONDOWN st_status.text = 'Right Mouse Down' case WM_RBUTTONDBLCLK st_status.text = 'Right Mouse Double Clicked' case else st_Status.text = 'something else happened' end choose
Source : http://www.inquiry.com/techtips/pb_pro/ … in0798.asp
Hors ligne
Merci bien mister erasorz, ça semble fonctionner pour l'icone dans le "system tray". Toutefois j'ai ce message d'avertissement à la compilation :
Object: nca_systray
Instance Variables
(0003): Warning C0190: Instance variables of local structure type ('notifyicondata') will be implicitly private in the next release.
Je ne sais pas si j'ai oublié un détail mais ça fonctionne quand même. Je vais maintenant essayer de jouer avec l'info bulle et je vous tiens au courant (pour les intéressés).
Hors ligne
Bonjour Beagle,
Ce message est juste un avertissement pour t'indiquer que lorsque tu migreras ton application dans une version supérieure de PB,
la stucture "notifyicondata" ne sera plus "protected", mais "private". Il faudra donc en tenir compte à ce moment là pour éviter des régressions éventuelles
dans ton application.
Hors ligne
Merci pour ton explication foon!
Pour ce qui est de la structure "NOTIFYICONDATA", l'objet que nous propose erasorz semble désuet. La structure complète actuelle est composée des éléments suivants :
typedef struct _NOTIFYICONDATAA{
DWORD cbSize;
HWND hWnd;
UINT uID;
UINT uFlags;
UINT uCallbackMessage;
HICON hIcon;
#if (NTDDI_VERSION < NTDDI_WIN2K)
TCHAR szTip[64];
#endif
#if (NTDDI_VERSION >= NTDDI_WIN2K)
TCHAR szTip[128];
DWORD dwState;
DWORD dwStateMask;
TCHAR szInfo[256];
union{
UINT uTimeout;
UINT uVersion; // Used with Shell_NotifyIcon flag NIM_SETVERSION.
} DUMMYUNIONNAME;
TCHAR szInfoTitle[64];
DWORD dwInfoFlags;
#endif
#if (NTDDI_VERSION >= NTDDI_WINXP)
GUID guidItem;
#endif
#if (NTDDI_VERSION >= NTDDI_VISTA)
HICON hBalloonIcon;
#endif
http://msdn.microsoft.com/en-us/library/bb773352.aspx
Alors que ce que j'ai actuellement est composé seulement de :
type notifyicondata from structure
long cbsize
long hwnd
long uid
long uflags
long ucallbackmessage
long hicon
character sztip[ 64 ]
end type
Je peux très bien ajouter ce qui manque, par contre je n'ai aucune idée quoi faire avec le type "union".... des idées?
Hors ligne
Bonjour,
En fait, tu trouveras la réponse à toutes tes questions avec ce lien : http://www.topwizprogramming.com/freecode_icontray.html.
C'est une application libre PB avec un nvo que tu peux incorporer dans ton application illustrant la mise en oeuvre du "system icon tray".
le nvo (n_icontray) contient la méthode (of_balloon_tip) te permettant d'afficher les infos bulles tel que tu le souhaites.
Hors ligne
buck a écrit:
Bonjour,
En fait, tu trouveras la réponse à toutes tes questions avec ce lien : http://www.topwizprogramming.com/freecode_icontray.html.
C'est une application libre PB avec un nvo que tu peux incorporer dans ton application illustrant la mise en oeuvre du "system icon tray".
le nvo (n_icontray) contient la méthode (of_balloon_tip) te permettant d'afficher les infos bulles tel que tu le souhaites.
Ah ben viarge! (expression québécoise) Merci bien buck tu viens de me sauver du temps!
Je vais le tester à fond avant de marquer "Résolu"
Hors ligne
effectivement, ne jamais oublier de regarder le topwiz...
sinon il y a également une source sur codexchange : http://downloads.sybase.com/codexchange … oonTip.zip (il faut être authentifié)
Hors ligne
Pages: 1