Ir al contenido


Foto

Crear tu propio Balloon Tips


  • Por favor identifícate para responder
No hay respuestas en este tema

#1 enecumene

enecumene

    Webmaster

  • Administrador
  • 7.419 mensajes
  • LocationRepública Dominicana

Escrito 14 noviembre 2008 - 04:24

Este truco nos enseña como crear nuestro propio Balloon Tips (Globo de Notas), está probado en Delphi 7.

Colocar en el Uses lo siguiente:



delphi
  1. uses
  2.   Commctrl;



Debajo del Implementation:



delphi
  1. procedure ShowBalloonTip(Control: TWinControl; Icon: integer; Title: pchar; Text: PWideChar;
  2. BackCL, TextCL: TColor);
  3. const
  4.   TOOLTIPS_CLASS = 'tooltips_class32';
  5.   TTS_ALWAYSTIP = $01;
  6.   TTS_NOPREFIX = $02;
  7.   TTS_BALLOON = $40;
  8.   TTF_SUBCLASS = $0010;
  9.   TTF_TRANSPARENT = $0100;
  10.   TTF_CENTERTIP = $0002;
  11.   TTM_ADDTOOL = $0400 + 50;
  12.   TTM_SETTITLE = (WM_USER + 32);
  13.   ICC_WIN95_CLASSES = $000000FF;
  14. type
  15.   TOOLINFO = packed record
  16.     cbSize: Integer;
  17.     uFlags: Integer;
  18.     hwnd: THandle;
  19.     uId: Integer;
  20.     rect: TRect;
  21.     hinst: THandle;
  22.     lpszText: PWideChar;
  23.     lParam: Integer;
  24.   end;
  25. var
  26.   hWndTip: THandle;
  27.   ti: TOOLINFO;
  28.   hWnd: THandle;
  29. begin
  30.   hWnd    := Control.Handle;
  31.   hWndTip := CreateWindow(TOOLTIPS_CLASS, nil,
  32.     WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP,
  33.     0, 0, 0, 0, hWnd, 0, HInstance, nil);
  34.   if hWndTip <> 0 then
  35.   begin
  36.     SetWindowPos(hWndTip, HWND_TOPMOST, 0, 0, 0, 0,
  37.       SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOSIZE);
  38.     ti.cbSize := SizeOf(ti);
  39.     ti.uFlags := TTF_CENTERTIP or TTF_TRANSPARENT or TTF_SUBCLASS;
  40.     ti.hwnd := hWnd;
  41.     ti.lpszText := Text;
  42.     Windows.GetClientRect(hWnd, ti.rect);
  43.     SendMessage(hWndTip, TTM_SETTIPBKCOLOR, BackCL, 0);
  44.     SendMessage(hWndTip, TTM_SETTIPTEXTCOLOR, TextCL, 0);
  45.     SendMessage(hWndTip, TTM_ADDTOOL, 1, Integer(@ti));
  46.     SendMessage(hWndTip, TTM_SETTITLE, Icon mod 4, Integer(Title));
  47.   end;
  48. end;



Forma de Uso:



delphi
  1. procedure TForm1.Button1Click(Sender: TObject);
  2. begin
  3.   ShowBalloonTip(Button1, 1, 'Titulo',
  4.   'Texto', clCream, clBlack);
  5. end;



Resultado:

Imagen Enviada

Saludos.

Si tenéis alguna duda por favor haced un hilo con gusto os ayudamos.

Edito para arreglas etiquetas de código
  • 0




IP.Board spam blocked by CleanTalk.