begin process at 2012 05 27 14:33:33
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

API

 > CLASSE TOOLTIP

CLASSE TOOLTIP


 Information sur la source

Note :
10 / 10 - par 5 personnes
10,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :API Niveau :Débutant Date de création :24/04/2002 Date de mise à jour :24/04/2002 23:02:44 Vu :4 603

Auteur : wood51

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

 Description

Juste une petite classe pour l'utilisation du controle ToolTip plus facilement. c'est pas grand chose mais si çà peut dépanner

Source

  • // Dans vôtre projet ajouter ToolTip.cpp
  • // Dans vôtre code principal incluer TooTip.h
  • // modifier WM_INITDIALOG
  • //*****************//
  • //Variable Globales//
  • //*****************//
  • ToolTip TT; // Construction du controle nommé TT
  • //******************//
  • // Fichier ToolTip.h//
  • //******************//
  • #ifndef __TOOLTIP_H
  • #define __TOOLTIP_H
  • #include <windows.h>
  • #include <commctrl.h>
  • class ToolTip
  • {
  • private:
  • HWND ToolTipHwnd;
  • HWND ParentHwnd;
  • HINSTANCE AppHinstance;
  • TOOLINFO ToolTipStruct;
  • public:
  • BOOL TTInit(HWND hWind); //Initialise le controle
  • BOOL TTAddTool(LPSTR Text,UINT Control); //Ajout un ToolTip au Controle
  • };
  • #endif
  • //********************//
  • // Fichier ToolTip.cpp//
  • //********************//
  • #include "ToolTip.h"
  • BOOL ToolTip::TTInit(HWND hWind) //Initialise le controle
  • {
  • if (!InitCommonControls)
  • {
  • return FALSE;
  • }
  • ParentHwnd=hWind;
  • AppHinstance=(HINSTANCE)GetWindowLong(hWind,GWL_HINSTANCE);
  • ToolTipHwnd = CreateWindowEx(0L, TOOLTIPS_CLASS, NULL,
  • WS_POPUP,
  • CW_USEDEFAULT, CW_USEDEFAULT,
  • CW_USEDEFAULT, CW_USEDEFAULT,
  • ParentHwnd, NULL, AppHinstance,
  • NULL);
  • if (ToolTipHwnd==NULL)
  • {
  • return FALSE;
  • }
  • if(!SetWindowPos(ToolTipHwnd, HWND_TOPMOST,0, 0, 0, 0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE))
  • {
  • return FALSE;
  • }
  • if(!SendMessage(ToolTipHwnd, TTM_ACTIVATE, TRUE, 0L))
  • {
  • return FALSE;
  • }
  • return TRUE;
  • }
  • BOOL ToolTip::TTAddTool(LPSTR Text,UINT Control) //Ajout un ToolTip au Controle
  • {
  • memset(&ToolTipStruct, 0x0, sizeof(ToolTipStruct));
  • ToolTipStruct.cbSize = sizeof(ToolTipStruct);
  • ToolTipStruct.uFlags = TTF_SUBCLASS|TTF_IDISHWND;
  • ToolTipStruct.hwnd = (HWND)GetDlgItem(ParentHwnd, Control);
  • ToolTipStruct.uId = (WPARAM)ToolTipStruct.hwnd;
  • ToolTipStruct.lpszText = Text;
  • ToolTipStruct.hinst = AppHinstance;
  • if(!SendMessage(ToolTipHwnd, TTM_ADDTOOL, 0, (LPARAM)&ToolTipStruct))
  • {
  • return FALSE;
  • }
  • return TRUE;
  • }
  • //******************//
  • //Dans WM_INITDIALOG//
  • //******************//
  • TT.TTInit(hwnd); // Initialisation du controle
  • TT.TTAddTool("ToolTip1",BUTTON_OK); // Ajout du ToolTip "ToolTip1" au controle (Boutton dans ce cas) BUTTON_OK
// Dans vôtre projet ajouter ToolTip.cpp
// Dans vôtre code principal incluer TooTip.h
// modifier WM_INITDIALOG

//*****************//
//Variable Globales//
//*****************//

ToolTip TT; // Construction du controle nommé TT

//******************//
// Fichier ToolTip.h//
//******************//

#ifndef __TOOLTIP_H
#define __TOOLTIP_H

#include <windows.h>
#include <commctrl.h>

class ToolTip
{
private:
HWND ToolTipHwnd;
HWND ParentHwnd;
HINSTANCE AppHinstance;
TOOLINFO ToolTipStruct;
public:
BOOL TTInit(HWND hWind); //Initialise le controle
BOOL TTAddTool(LPSTR Text,UINT Control); //Ajout un ToolTip au Controle
};
#endif

//********************//
// Fichier ToolTip.cpp//
//********************//

#include "ToolTip.h"

BOOL ToolTip::TTInit(HWND hWind) //Initialise le controle
{
if (!InitCommonControls)
   {
      return FALSE;
   }

ParentHwnd=hWind;
AppHinstance=(HINSTANCE)GetWindowLong(hWind,GWL_HINSTANCE);

ToolTipHwnd = CreateWindowEx(0L, TOOLTIPS_CLASS, NULL,
                            WS_POPUP,
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            CW_USEDEFAULT, CW_USEDEFAULT,
                            ParentHwnd, NULL, AppHinstance,
                            NULL);
if (ToolTipHwnd==NULL) 
   {
      return FALSE;
   }

if(!SetWindowPos(ToolTipHwnd, HWND_TOPMOST,0, 0, 0, 0,SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE))
   {
      return FALSE;
   }
if(!SendMessage(ToolTipHwnd, TTM_ACTIVATE, TRUE, 0L))
   {
      return FALSE;
   }
return TRUE;
}

BOOL ToolTip::TTAddTool(LPSTR Text,UINT Control) //Ajout un ToolTip au Controle
{
            memset(&ToolTipStruct, 0x0, sizeof(ToolTipStruct));
            ToolTipStruct.cbSize = sizeof(ToolTipStruct);
            ToolTipStruct.uFlags = TTF_SUBCLASS|TTF_IDISHWND;
            ToolTipStruct.hwnd = (HWND)GetDlgItem(ParentHwnd, Control);
            ToolTipStruct.uId = (WPARAM)ToolTipStruct.hwnd;
            ToolTipStruct.lpszText = Text;
            ToolTipStruct.hinst = AppHinstance;

if(!SendMessage(ToolTipHwnd, TTM_ADDTOOL, 0, (LPARAM)&ToolTipStruct))
   {
      return FALSE;
   }
return TRUE;
}

//******************//
//Dans WM_INITDIALOG//
//******************//

TT.TTInit(hwnd); // Initialisation du controle
TT.TTAddTool("ToolTip1",BUTTON_OK); // Ajout du ToolTip "ToolTip1" au controle (Boutton dans ce cas) BUTTON_OK 



 Sources du même auteur

CLASSE PROGRESSBAR

 Sources de la même categorie

Source avec Zip WIN32 TLS LENT par dguilmain
Source avec Zip VIDER ELEMENTS DE CORBEILLE WINDOWS7 (WIN64) par BruNews
Source avec Zip Source avec une capture FIND TEXT (WIN64) par BruNews
Source avec Zip DELETE DIRECTORY (WIN64) par BruNews
Source avec Zip ENUM DIRECTORY (WIN64) par BruNews

Commentaires et avis

Aucun commentaire pour le moment.

 Ajouter un commentaire




Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Mai 2012
LMMJVSD
 123456
78910111213
14151617181920
21222324252627
28293031   

Consulter la suite du CalendriCode

A découvrir



 
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 : 0,390 sec (4)

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