Este es un truquillo general para poner
hints o globos de texto individuales a cada panel de una barra de estado, en Delphi 3 (hay que añadir
commctrl a la línea
uses):
Código Delphi
[-]
Const
TTS_BALLOON = $40;
TTM_SETTITLE = (WM_USER + 32);
hints: Array[0..7] Of String= ('', 'Jamón',
'Lentejas',
'Salmón ahumado',
'Pato a la naranja',
'Fabada',
'Cocido madrileño',
'Ropavieja');
var
Form1: TForm1;
...
...
hTooltip: Cardinal;
ti: TToolInfo;
buffer : array[0..255] of char;
phoz: Array[0..2048] Of Byte;
implementation
{$R *.DFM}
procedure CreateToolTips(hWnd: Cardinal);
begin
hToolTip := CreateWindowEx(0, 'Tooltips_Class32', nil, TTS_ALWAYSTIP or TTS_BALLOON,
Integer(CW_USEDEFAULT), Integer(CW_USEDEFAULT),Integer(CW_USEDEFAULT),
Integer(CW_USEDEFAULT), hWnd, 0, hInstance, nil);
if hToolTip <> 0 then
begin
SetWindowPos(hToolTip, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE or
SWP_NOSIZE or SWP_NOACTIVATE);
SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_INITIAL, 40); SendMessage(hTooltip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 10000); ti.cbSize := SizeOf(TToolInfo);
ti.uFlags := TTF_SUBCLASS;
ti.hInst := hInstance;
end;
end;
procedure AddToolTip(hwnd: dword; lpti: PToolInfo; IconType: Integer; Text, Title: PChar);
var
Item: THandle;
Rect: TRect;
begin
Item := hWnd;
if (Item <> 0) AND (GetClientRect(Item, Rect)) then
begin
lpti.hwnd := Item;
lpti.Rect := Rect;
lpti.lpszText := Text;
SendMessage(hToolTip, TTM_ADDTOOL, 0, Integer(lpti));
FillChar(buffer, sizeof(buffer), #0);
lstrcpy(buffer, Title);
if (IconType > 3) or (IconType < 0) then IconType := 0;
SendMessage(hToolTip, TTM_SETTITLE, IconType, Integer(@buffer));
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var p, pc, pw, spc: Integer;
begin
pc:= -3; spc:= StatusBar1.Panels.Count;
FillChar(phoz[0], SizeOf(phoz), 0);
For p:= 1 To spc Do
Begin
pw:= StatusBar1.Panels[p-1].Width;
If p=spc Then pw:= SizeOf(phoz)-pc+10;
FillChar(phoz[pc+10], pw-10, p);
Inc(pc, pw);
End;
CreateToolTips(Form1.Handle);
End;
procedure TForm1.StatusBar1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
If pz=phoz[x] Then Exit;SendMessage(hToolTip, TTM_DELTOOL, 0, Integer(@ti));AddToolTip(Statusbar1.Handle, @ti, 0, Pchar(hints[phoz[x]]), '');
pz:= phoz[x];
end;