begin process at 2012 02 09 13:44:56
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Astuces

 > CRÉER UN TOOLTIP EN FORME DE BULLE SOUS WINDOWS AVEC UNE IMAGE DANS LA BULLE

CRÉER UN TOOLTIP EN FORME DE BULLE SOUS WINDOWS AVEC UNE IMAGE DANS LA BULLE


 Information sur la source

Note :
6 / 10 - par 1 personne
6,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Astuces Niveau :Débutant Date de création :27/04/2005 Vu :8 739

Auteur : Papy67

Ecrire un message privé
Commentaire sur cette source (5)
Ajouter un commentaire et/ou une note

 Description

astuce simple
pour mettre un Bitmap dans un tooltip en le personalisant
fond,couleur du texte ,police du texte avec ajout d'un titre

Source

  • void CreateMyTooltip (HWND hDlg,char *ToolTipTitre){
  • unsigned int uid = 0;
  • LPTSTR lptstr = ToolTipTitre;
  • iccex.dwICC = ICC_WIN95_CLASSES|ICC_ANIMATE_CLASS|ICC_TAB_CLASSES;
  • iccex.dwSize = sizeof(iccex);
  • InitCommonControlsEx(&iccex);
  • hwndTT = CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW ,TOOLTIPS_CLASS,NULL,WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP| TTS_BALLOON,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hmain,NULL,wc.hInstance,NULL);
  • HBITMAP bmp=LoadBitmap(wc.hInstance,(LPCSTR)204);
  • SIZE sz;
  • sz.cx=20;
  • sz.cy=20;
  • hlg=CreateWindowEx(0, "STATIC", NULL, WS_VISIBLE|WS_CHILD|SS_BITMAP,2, 2,sz.cx, sz.cy, hwndTT, NULL, wc.hInstance, NULL);
  • SetBitmapDimensionEx(bmp,3,3,&sz);
  • SendMessage(hlg, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bmp);
  • SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
  • GetClientRect (hDlg, &rect);
  • ti.cbSize = sizeof(ti);
  • ti.uFlags = TTF_SUBCLASS;
  • ti.hwnd = hDlg;
  • ti.hinst = wc.hInstance;
  • ti.uId = uid;
  • ti.lpszText = lptstr;
  • ti.rect.left = rect.left;
  • ti.rect.top = rect.top;
  • ti.rect.right = rect.right;
  • ti.rect.bottom = rect.bottom;
  • SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
  • SendMessage(hwndTT, TTM_SETTIPTEXTCOLOR, (WPARAM) RGB(0,255,0),0);
  • SendMessage(hwndTT, WM_SETFONT, (WPARAM)GetStockObject(0x0E), MAKELPARAM(TRUE, 0));
  • SendMessage(hwndTT, TTM_SETTITLE, (WPARAM) (int) 1, (LPARAM)(LPCTSTR) titre);
  • SendMessage(hwndTT, TTM_SETTIPBKCOLOR,(WPARAM)RGB(204,51,153),0 );
  • SendMessage(hwndTT, CCM_SETWINDOWTHEME,0,(LPARAM) (LPWSTR) "BUTTON");
  • }
void CreateMyTooltip (HWND hDlg,char *ToolTipTitre){
    unsigned int uid = 0;
     LPTSTR lptstr = ToolTipTitre;
    iccex.dwICC = ICC_WIN95_CLASSES|ICC_ANIMATE_CLASS|ICC_TAB_CLASSES;
    iccex.dwSize = sizeof(iccex);
    InitCommonControlsEx(&iccex);
    hwndTT = CreateWindowEx(WS_EX_TOPMOST|WS_EX_TOOLWINDOW ,TOOLTIPS_CLASS,NULL,WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP| TTS_BALLOON,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hmain,NULL,wc.hInstance,NULL);
	HBITMAP bmp=LoadBitmap(wc.hInstance,(LPCSTR)204);
	SIZE sz;
	sz.cx=20;
	sz.cy=20;
    hlg=CreateWindowEx(0, "STATIC", NULL, WS_VISIBLE|WS_CHILD|SS_BITMAP,2, 2,sz.cx, sz.cy, hwndTT, NULL, wc.hInstance, NULL);
	SetBitmapDimensionEx(bmp,3,3,&sz);
	SendMessage(hlg, STM_SETIMAGE, IMAGE_BITMAP, (LPARAM)bmp);
	SetWindowPos(hwndTT,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
    GetClientRect (hDlg, &rect);
    ti.cbSize = sizeof(ti);
    ti.uFlags = TTF_SUBCLASS;
    ti.hwnd = hDlg;
    ti.hinst = wc.hInstance;
    ti.uId = uid;
    ti.lpszText = lptstr;
    ti.rect.left = rect.left;    
    ti.rect.top = rect.top;
    ti.rect.right = rect.right;
    ti.rect.bottom = rect.bottom;
   SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);
   SendMessage(hwndTT, TTM_SETTIPTEXTCOLOR, (WPARAM) RGB(0,255,0),0);  
   SendMessage(hwndTT, WM_SETFONT, (WPARAM)GetStockObject(0x0E), MAKELPARAM(TRUE, 0));
   SendMessage(hwndTT, TTM_SETTITLE,  (WPARAM) (int) 1, (LPARAM)(LPCTSTR) titre);  
   SendMessage(hwndTT, TTM_SETTIPBKCOLOR,(WPARAM)RGB(204,51,153),0 );
   SendMessage(hwndTT, CCM_SETWINDOWTHEME,0,(LPARAM) (LPWSTR) "BUTTON"); 
  } 



 Sources du même auteur

Source avec Zip EXEMPLE COMPLET RELATIF A MON EXEMPLE DE TOOLTIP PERSONALISÉ...
LISTEUR DE FICHIER DOS
Source avec une capture TEXTE DE COULEUR EN CONSOLE DOS ( VC6)
Source avec Zip Source avec une capture CRÉATION D'UN RACOURCI POUR WINDOWS AVEC INTERFACE SIMPLIFIÉ...
Source avec Zip Source avec une capture EX METTRE UNE ICONE SUR UN BOUTON AVEC MFC

 Sources de la même categorie

Source avec Zip SCHEDULER RR FIFO par yvesB87
Source avec Zip ALGORITHMES RÉCURSIFS VS ALGORITHMES ITÉRATIFS par yvesB87
Source avec Zip Source avec une capture C++ FORMAT D'IMAGE AVEC QT par pop70
Source avec une capture EXEMPLE DE POINTEURS DE FONCTION par pop70
Source avec Zip Source avec une capture [C++] CLASS REGISTER par Miwik

Commentaires et avis

Commentaire de darkman2 le 07/05/2005 09:15:51

t'as fait un bon boullo
ca va me servir e rendre le + optimal ....

Commentaire de victorcoasne le 08/10/2005 10:22:32

Bien mais j'ai l'impression qu'il manque du code car il y a des variables non déclarés.
Je me trompe ou pas en disant que tu l'as pris d'un de tes programmes ?

Commentaire de Papy67 le 08/10/2005 14:10:59

absolument pas victorcoasne cela vient effectivement d'un de mes programmes .
bien vu et je dirais meme que cela vien du squelete principal de mon appli.

Commentaire de victorcoasne le 08/10/2005 22:20:29

Essaye de faire une fenetre avec ton code et corrige ce qui manque ou poste un zip car je n'arrive pas à compiler sous Dev !

Merci

Commentaire de Papy67 le 27/11/2006 12:47:11

les amis je viens de deposer un exemple complet montrant comment faire :)
voici le lien : http://www.cppfrance.com/code.aspx?ID=40488

bye bonne prog a tous

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 2,746 sec (3)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales