请教:能否hint一个Form?
显示的hint只有一行文字,有时候需要显示一个form,而又不需要弹出窗口,又没有什么办法用hint那样显示出来?

解决方案 »

  1.   

    不一定要form,你可以用一个Frame或Panel之类的,先将其隐藏,鼠标移动时,获取鼠标所处坐标的的X和Y值,当处于你想要Hint的范围内,则将其Visible设置为True,并根据X和Y设置其Top和Left属性
      

  2.   

    源自网路的代码unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, CommCtrl, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}var
       fTipHandle : HWND;procedure PopTip(
       sText : string;      
       nIcon : Integer;     
       p : TPoint;          
       timeout : Integer=5;
       sTitle :string = '');
    const
       TTS_BALLOON = $0040;
       TTS_CLOSE = $0080;
       TTF_PARSELINKS = $1000;
       TTM_SETTITLE = WM_USER + 32;
    var
       i : Integer;
       ftoolInfo : tagToolInfoA;
       str : string;
    begin   if fTipHandle <> 0 then
       begin
         DestroyWindow(fTipHandle);
       end;
       fTipHandle := CreateWindow(TOOLTIPS_CLASS, nil,
         WS_POPUP or TTS_NOPREFIX or TTS_BALLOON or TTS_ALWAYSTIP or TTS_CLOSE,
         0, 0, 0, 0, Application.Handle,
         0, HInstance, nil);   if fTipHandle = 0 then Exit;     fToolInfo.cbSize := SizeOf(fToolInfo);
         fToolInfo.uFlags := TTF_PARSELINKS or TTF_IDISHWND or TTF_TRACK;
         fToolInfo.uId :=Application.Handle;
         fToolInfo.lpszText := PAnsiChar(sText);
         SendMessage(fTipHandle, TTM_ADDTOOL, 0, Integer(@fToolInfo));
         SendMessage(fTipHandle, TTM_SETTOOLINFO, 0, Integer(@fToolInfo));     str :=      sTitle;
         if str = '' then str := Application.Title;
         SendMessage(fTipHandle, TTM_SETTITLE, 1, Integer(str));
         SendMessage(fTipHandle, TTM_TRACKPOSITION, 0, MAKELONG(p.X , p.Y));
         SendMessage(fTipHandle, TTM_TRACKACTIVATE, Integer(True), Integer(@fToolInfo));     for i := 0 to timeout * 50 do
         begin
           Sleep(20);
           Application.ProcessMessages;
         end;     DestroyWindow(fTipHandle);
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
      p: tpoint;
    begin
      p.x:=400;p.Y:=400;
      if true then
        PopTip('提示XXX',0,p,3,'');
    end;end.
      

  3.   

    谢谢楼上的各位朋友。
    我测试时发现一个问题,就是如果需要判断是否有鼠标点下,在Form上点鼠标,有WM_LBUTTONDOWN消息产生,但是在Form上的控件上点鼠标,却没有WM_LBUTTONDOWN消息产生,有什么好办法能够判断Form上是否有鼠标按下吗?