Inserer des bitmaps dans le context menu de mon icon tray

drkns Messages postés 22 Date d'inscription mardi 20 janvier 2004 Statut Membre Dernière intervention 10 mars 2009 - 7 juin 2006 à 18:25
drkns Messages postés 22 Date d'inscription mardi 20 janvier 2004 Statut Membre Dernière intervention 10 mars 2009 - 7 juin 2006 à 20:54
Salut,

Je cherche à inserer des bitmaps dans le context menu de mon icon tray.

Voici le bout de code que j'utilise, je dois certainement passer à coté de qq chose mais quoi ?
Est ce que quelqu'un peux m'aider la dessus ?

                         hMenu = CreatePopupMenu();
                         AppendMenu(hMenu, MF_BITMAP and MF_STRING, IDM_SHOW, TEXT("Show Balloon"));
                         AppendMenu(hMenu, MF_STRING, IDM_ABOUT, TEXT("about..."));
                         AppendMenu(hMenu,MF_SEPARATOR,0,0);
                         AppendMenu(hMenu, MF_STRING, IDM_EXIT, TEXT("close"));
                         SetForegroundWindow(hwnd);
                         GetCursorPos(&pt);
                        
      // Load the bitmaps from the resource files into the memory                        
                         HBITMAP bmpClose = LoadBitmap ( GetModuleHandle ( NULL ), "close.bmp" );
       HBITMAP bmpAbout = LoadBitmap ( GetModuleHandle ( NULL ), "about.bmp" );


      // Add the bitmaps to the menuitems
      SetMenuItemBitmaps ( hMenu, IDM_EXIT, MF_BYCOMMAND, bmpClose, bmpClose );
      SetMenuItemBitmaps ( hMenu, IDM_ABOUT, MF_BYCOMMAND, bmpAbout, bmpAbout );


                         TrackPopupMenu(hMenu,TPM_LEFTALIGN,pt.x,pt.y,0,hwnd,0);

Merci

Drkns

2 réponses

vecchio56 Messages postés 6535 Date d'inscription lundi 16 décembre 2002 Statut Membre Dernière intervention 22 août 2010 14
7 juin 2006 à 18:43
0
drkns Messages postés 22 Date d'inscription mardi 20 janvier 2004 Statut Membre Dernière intervention 10 mars 2009
7 juin 2006 à 20:54
Merci beaucoup 19734 vecchio56,

Pourtant sans vouloir chipoter en faite je souhaiterais savoir s'il existe un exemple plus simple pour la getion des par DC.

Mon but est d'utiliser le myen le plus simple sans passer par un fichier ressource.
En effet, par l'utilisation d'un ressource cette exemple fonctionne :

*************************************
      case WM_RBUTTONUP:
    {
                    // Load the menu
                         hMenu = CreatePopupMenu();
                         AppendMenu(hMenu, MF_STRING, IDM_SHOW, TEXT("Show Balloon"));
                         AppendMenu(hMenu, MF_STRING, IDM_ABOUT, TEXT("about..."));
                         AppendMenu(hMenu,MF_SEPARATOR,0,0);
                         AppendMenu(hMenu, MF_STRING, IDM_EXIT, TEXT("close"));
                         SetForegroundWindow(hwnd);
                         GetCursorPos(&pt);
                        
      // Load the bitmaps from the resource files into the memory                         
      HBITMAP bmpClose = LoadBitmap ( GetModuleHandle ( NULL ), MAKEINTRESOURCE ( ID_BMP_CLOSE ) );
       HBITMAP bmpAbout = LoadBitmap ( GetModuleHandle ( NULL ), MAKEINTRESOURCE ( ID_BMP_ABOUT ) );


      // Add the bitmaps to the menuitems
      SetMenuItemBitmaps ( hMenu, IDM_EXIT, MF_BYCOMMAND, bmpClose, bmpClose );
      SetMenuItemBitmaps ( hMenu, IDM_ABOUT, MF_BYCOMMAND, bmpAbout, bmpClose );


                         TrackPopupMenu(hMenu,TPM_LEFTALIGN,pt.x,pt.y,0,hwnd,0);
                        
                         //DeleteObject(Image);
                         DestroyMenu(hMenu);
                         PostMessage(hwnd,WM_NULL,0,0);
     }
                    break;
*************************************

Exemple :

Existe-il un moyen simple d'arriver a ce resultat sans utiliser un fihier de ressouce ?

Merci

Drkns
0
Rejoignez-nous