Tray Icon, comment ca fonctionne ??

zadounet Messages postés 14 Date d'inscription lundi 11 avril 2005 Statut Membre Dernière intervention 8 juin 2005 - 25 mai 2005 à 13:12
PsYk0PaT Messages postés 10 Date d'inscription lundi 30 décembre 2002 Statut Membre Dernière intervention 12 juillet 2005 - 31 mai 2005 à 22:52
Quelqu'un sait par hasard comment programmer en Vc++ 6.0
pour faire une icone dans la bar (Tray Mode) et pour faire changer
cette icone.

Un peu comme fait MSN.



Merki

3 réponses

simtiers Messages postés 207 Date d'inscription jeudi 3 avril 2003 Statut Membre Dernière intervention 2 novembre 2006
25 mai 2005 à 13:18
J'ai une classe qui s'en charge (en Win32 API)

J'ai recopié ça sur un site qui, maintenant, n'existe plus.



Je crois que tu peux trouver ton bonheur sur CodeGuru.com (C++ / Com / ShellProgramming)

Mais, là, c'est du MFC le plus souvent
0
vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
26 mai 2005 à 00:20
Ici même il y a plusieurs sources la dessus, la plupart sans MFC cette
fois. Pour faire des trucs animés comme MSN, j'imagine qu'on utilise un
timer pour changer d'icone tous les x ms.
0
PsYk0PaT Messages postés 10 Date d'inscription lundi 30 décembre 2002 Statut Membre Dernière intervention 12 juillet 2005
31 mai 2005 à 22:52
Si ca peut t'aider, j'ai ce petit bout de code qui fonctionne avec Builder C++ 6



void __fastcall TForm2::CreateIcon(void)

{

if(_icon_data.hWnd == NULL)

{

//afficher un icone dans la system tray

_icon_data.cbSize = sizeof (_icon_data);

_icon_data.hWnd = Handle;

HINSTANCE hinst = GetModuleHandle(NULL);

_icon_data.hIcon = LoadIcon(hinst, "ICONE");

_icon_data.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;

_icon_data.uID = NULL;

_icon_data.uCallbackMessage = WM_ICONMESSAGE;

strcpy(_icon_data.szTip, Application->Title.c_str());

Shell_NotifyIcon(NIM_ADD,&_icon_data);

}

}



void __fastcall TForm2::DestroyIcon(void)

{

if(_icon_data.hWnd != NULL)

{

//supprimer l'icone

Shell_NotifyIcon(NIM_DELETE, &_icon_data);

_icon_data.hWnd = NULL;

}

}



void __fastcall TForm2::WMIconMessage(TMessage &Message)

{

//vérifier le type de message de la souris

switch(Message.LParam)

{

case WM_RBUTTONUP:

//le bouton droit à été cliqué. faire apparaitre le menu

POINT WinPoint;

GetCursorPos(&WinPoint);

SetForegroundWindow(Handle);

PPMenu->Popup(WinPoint.x,WinPoint.y);

PostMessage(Handle, WM_NULL, 0,0);

break;

}

}


Ensuite j'utilise ShowWindow(_icon_data.hWnd, SW_HIDE); pour cacher
l'application et ShowWindow(_icon_data.hWnd, SW_SHOW); pour la
réafficher.



Il y a aussi ces variables que j'ai placer dans le .h fichier:



NOTIFYICONDATA _icon_data;



BEGIN_MESSAGE_MAP

VCL_MESSAGE_HANDLER(WM_ICONMESSAGE, TMessage, WMIconMessage)

END_MESSAGE_MAP(TForm)




Il suffit d'adapter le code pour l'IDE/compilo que tu utilises.

Bonne chance!
0
Rejoignez-nous