Ver Mensaje Individual
  #2  
Antiguo 01-11-2007
Avatar de jhonny
jhonny jhonny is offline
Jhonny Suárez
 
Registrado: may 2003
Ubicación: Colombia
Posts: 7.058
Reputación: 30
jhonny Va camino a la famajhonny Va camino a la fama
Según el truco 135 de Trucomania (Quizá haya algo mejor), necesitas dos metodos basicos y un atributo global para la unidad:

Código Delphi [-]
  private
    mango:THintWindow;
    function RevealHint(Control: TControl): THintWindow;
    procedure RemoveHint(var Hint: THintWindow);


Código Delphi [-]
function TForm1.RevealHint (Control: TControl): THintWindow;
var
   ShortHint: string;
   AShortHint: array[0..255] of Char;
   HintPos: TPoint;
   HintBox: TRect;
begin
   { Create the window: }
   Result := THintWindow.Create(Control);

   { Get first half of hint up to '|': }
   ShortHint := GetShortHint(Control.Hint);

   { Calculate Hint Window position & size: }
   HintPos := Control.ClientOrigin;
   Inc(HintPos.Y, Control.Height + 6);
   HintBox := Bounds(0, 0, Screen.Width, 0);
   DrawText(Result.Canvas.Handle,
       StrPCopy(AShortHint, ShortHint), -1, HintBox,
       DT_CALCRECT or DT_LEFT or DT_WORDBREAK or DT_NOPREFIX);
   OffsetRect(HintBox, HintPos.X, HintPos.Y);
   Inc(HintBox.Right, 6);
   Inc(HintBox.Bottom, 2);

   { Now show the window: }
   Result.ActivateHint(HintBox, ShortHint);
end; {RevealHint}

Código Delphi [-]
procedure TForm1.RemoveHint (var Hint: THintWindow);
begin
   Hint.ReleaseHandle;
   Hint.Free;
   Hint := nil;
end;

Para llamarlos podrias hacerlo por ejemplo en el OnEnter del Edit:

Código Delphi [-]
procedure TForm1.Edit1Enter(Sender: TObject);
begin
   mango := RevealHint(Edit1);
end;

Y en el OnExit para hacerlo desaparecer:

Código Delphi [-]
procedure TForm1.Edit1Exit(Sender: TObject);
begin
  RemoveHint(mango);
end;

Y Listo , espero te sirva el truco 135 de TrucoMania .
__________________
Lecciones de mi Madre. Tema: modificación del comportamiento, "Pará de actuar como tu padre!"

http://www.purodelphi.com/
http://www.nosolodelphi.com/
Responder Con Cita