1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
HWND hwndToolTips;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
// le lien
// <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/bb760250(v=vs.85).aspx" target="_blank">http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx</a>
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
// gestion affichage Balloon
hwndToolTips = CreateWindow(TOOLTIPS_CLASS, NULL,
WS_POPUP | TTS_NOPREFIX | TTS_BALLOON,
0, 0, 0, 0, Handle, NULL, HInstance, NULL);
if (hwndToolTips != NULL)
{
TOOLINFO ti;
ti.cbSize = sizeof(ti);
ti.uFlags = TTF_SUBCLASS | TTF_TRANSPARENT | TTF_CENTERTIP;
ti.hinst = NULL;
ti.rect = Edit1->ClientRect;
ti.hwnd = Edit1->Handle;
ti.lpszText = "texte qui s'affiche";
CopyRect( &ti.rect, &(Edit1->ClientRect));
SendMessage(hwndToolTips, TTM_ADDTOOL, 0, (LPARAM) &ti);
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Edit1Change(TObject *Sender)
{
POINT cursor;
int l = Edit1->Text.Length();
if (l > 0)
if (isupper(Edit1->Text[l]))
{
// on active l'affichage
SendMessage(hwndToolTips, TTM_ACTIVATE, true, 0);
// on acquier la position du curseur
GetCursorPos(&cursor);
// on simule un deplacement
SetCursorPos(cursor.x + 1, cursor.y);
}
if(islower(Edit1->Text[l]))
{
// on desactive l'affichage
SendMessage(hwndToolTips, TTM_ACTIVATE, false, 0);
}
}
//--------------------------------------------------------------------------- |