想实现类似于QQ天气预报那种鼠标移动到天气图标显示出窗体form1移出则消失 如题 。我菜鸟,请高手们给小的指点下下。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 新建一个透明窗体显示png图标在窗体的deactive 事件中hide 或destroy 掉。 另:可用gdi+ 显示半透窗体。 THintWindowunit wdHintWnd2;interfaceuses Windows, Classes, Controls, Graphics, Forms, SysUtils, ExtCtrls;type TwdHintWnd = class(THintWindow) private FHintBmp: TBitmap; //提示信息位图 protected procedure CreateParams(var Params: TCreateParams); override; procedure Paint; override; procedure NCPaint(DC: HDC); override;{画提示的图象} procedure DrawHintImg(Bmp: TBitmap; AHint: string); public constructor Create(Aowner: TComponent); override; destructor Destroy; override; procedure ActivateHint(Rect: TRect; const AHint: string); override; end;implementation{ TwdHintWnd }procedure TwdHintWnd.ActivateHint(Rect: TRect; const AHint: string);var P: TPoint;begin//在这里取得一个适当的尺寸显示文字 {FHintBmp.Width := Rect.Right - Rect.Left; FHintBmp.Height := Rect.Bottom - Rect.Top + 4; DrawHintImg(FHintBmp, AHint); Inc(Rect.Right, 23); Inc(Rect.Bottom, 27);} if length(AHint) > 100 then //如果 AHint地长度大于100,则将AHint显示在400*300的矩形框中!!! begin Rect.Right := Rect.Left + 386; Rect.Bottom := Rect.Top + 168; end; FHintBmp.Width := Rect.Right - Rect.Left; FHintBmp.Height := Rect.Bottom - Rect.Top; DrawHintImg(FHintBmp, AHint); BoundsRect := Rect; if Left < Screen.DesktopLeft then Left := Screen.DesktopLeft; if Top < Screen.DesktopTop then Top := Screen.DesktopTop; if Left + Width > Screen.DesktopWidth then Left := Screen.DesktopWidth - Width; if Top + Height > Screen.DesktopHeight then Top := Screen.DesktopHeight - Height; Frame3D(FHintBmp.Canvas, Rect, clMedGray, clBtnShadow, 1); P := ClientToScreen(Point(0, 0)); SetWindowPos(Handle, HWND_TOPMOST, P.X, P.Y, 0, 0, SWP_SHOWWINDOW or SWP_NOACTIVATE or SWP_NOSIZE);end;constructor TwdHintWnd.Create(Aowner: TComponent);begin inherited; FHintBmp := TBitmap.Create;end;procedure TwdHintWnd.CreateParams(var Params: TCreateParams);begin inherited;//去掉窗口边框 Params.Style := Params.Style and not WS_BORDER;end;destructor TwdHintWnd.Destroy;begin FHintBmp.Free; inherited;end;procedure TwdHintWnd.NCPaint;begin//重载不让画边框end;procedure TwdHintWnd.Paint;begin Canvas.CopyRect(ClientRect, FHintBmp.Canvas, ClientRect);end;procedure TwdHintWnd.DrawHintImg(Bmp: TBitmap; AHint: string);var R: TRect; slLine: TStrings; iLineNo, iLineH: Integer;begin Bmp.Canvas.Brush.Color := Application.HintColor; Bmp.Canvas.Pen.Color := Application.HintColor; Bmp.Canvas.Rectangle(0, 0, Bmp.Width, Bmp.Height); Bmp.Canvas.Font.Color := Screen.HintFont.Color; //Bmp.Canvas.Font. R := Rect(0, 0, Bmp.Width, Bmp.Height); Inc(R.Left, 2); Inc(R.Top, 2); slLine := TStringList.Create; slLine.Text := StringReplace(AHint, #$0A#$0D, #$0D#$0A, [rfReplaceAll]); iLineH := 0; for iLineNo := 0 to slLine.Count - 1 do begin if (iLineNo mod 3) = 0 then Bmp.Canvas.Font.Style := [fsBold]; //标题 if (iLineNo mod 3) = 1 then Bmp.Canvas.Font.Style := []; //正文 if (iLineNo mod 3) = 2 then ; //分段(换行符) //DrawText(Bmp.Canvas.Handle, PChar(AHint), -1, R, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK or DrawTextBiDiModeFlagsReadingOnly); R.Top := R.Top + iLineH; iLineH := DrawText(Bmp.Canvas.Handle, PChar(slLine.Strings[iLineNo]), -1, R, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK or DrawTextBiDiModeFlagsReadingOnly); if iLineH < 10 then iLineH := 13; end; slLine.Free;end;initialization Application.ShowHint := False; HintWindowClass := TwdHintWnd; //THintWindow Application.ShowHint := True; Application.HintHidePause := -1;end. 控件YearPlanner在哪里可以下载 网络文件传输的问题. 三层问题 怎么用Tudpsocket来告诉局域网内的所有上线的计算机:我上线了?就象QQ似的。 DBEdit无法编辑输入 急求局域网内点对点的文件传输代码,,(socket) Delphi的设置问题,解决之后马上给分 模仿别人的程序,还是没能解决问题,又是密码登陆。。分都耗光了。。来看看吧 谁有二十四点游戏的代码 纯属胡说八道 delphi 求助,等待高手。。。 IdTCPServer 的OnExecute 用 普通过程(procedure)赋值 IDHTTP使用代理的话POST出现Socket error 10054错误
Windows, Classes, Controls, Graphics, Forms, SysUtils, ExtCtrls;type
TwdHintWnd = class(THintWindow)
private
FHintBmp: TBitmap; //提示信息位图
protected
procedure CreateParams(var Params: TCreateParams); override;
procedure Paint; override;
procedure NCPaint(DC: HDC); override;
{画提示的图象}
procedure DrawHintImg(Bmp: TBitmap; AHint: string);
public
constructor Create(Aowner: TComponent); override;
destructor Destroy; override;
procedure ActivateHint(Rect: TRect; const AHint: string); override;
end;implementation
{ TwdHintWnd }
procedure TwdHintWnd.ActivateHint(Rect: TRect; const AHint: string);
var
P: TPoint;
begin
//在这里取得一个适当的尺寸显示文字
{FHintBmp.Width := Rect.Right - Rect.Left;
FHintBmp.Height := Rect.Bottom - Rect.Top + 4;
DrawHintImg(FHintBmp, AHint);
Inc(Rect.Right, 23);
Inc(Rect.Bottom, 27);} if length(AHint) > 100 then //如果 AHint地长度大于100,则将AHint显示在400*300的矩形框中!!!
begin
Rect.Right := Rect.Left + 386;
Rect.Bottom := Rect.Top + 168;
end; FHintBmp.Width := Rect.Right - Rect.Left;
FHintBmp.Height := Rect.Bottom - Rect.Top;
DrawHintImg(FHintBmp, AHint); BoundsRect := Rect;
if Left < Screen.DesktopLeft then Left := Screen.DesktopLeft;
if Top < Screen.DesktopTop then Top := Screen.DesktopTop;
if Left + Width > Screen.DesktopWidth then Left := Screen.DesktopWidth - Width;
if Top + Height > Screen.DesktopHeight then Top := Screen.DesktopHeight - Height;
Frame3D(FHintBmp.Canvas, Rect, clMedGray, clBtnShadow, 1); P := ClientToScreen(Point(0, 0));
SetWindowPos(Handle, HWND_TOPMOST, P.X, P.Y, 0, 0, SWP_SHOWWINDOW or SWP_NOACTIVATE or SWP_NOSIZE);
end;constructor TwdHintWnd.Create(Aowner: TComponent);
begin
inherited;
FHintBmp := TBitmap.Create;
end;procedure TwdHintWnd.CreateParams(var Params: TCreateParams);
begin
inherited;
//去掉窗口边框
Params.Style := Params.Style and not WS_BORDER;
end;destructor TwdHintWnd.Destroy;
begin
FHintBmp.Free;
inherited;
end;procedure TwdHintWnd.NCPaint;
begin
//重载不让画边框
end;
procedure TwdHintWnd.Paint;
begin
Canvas.CopyRect(ClientRect, FHintBmp.Canvas, ClientRect);
end;
procedure TwdHintWnd.DrawHintImg(Bmp: TBitmap; AHint: string);
var
R: TRect;
slLine: TStrings;
iLineNo, iLineH: Integer;
begin
Bmp.Canvas.Brush.Color := Application.HintColor;
Bmp.Canvas.Pen.Color := Application.HintColor;
Bmp.Canvas.Rectangle(0, 0, Bmp.Width, Bmp.Height);
Bmp.Canvas.Font.Color := Screen.HintFont.Color;
//Bmp.Canvas.Font.
R := Rect(0, 0, Bmp.Width, Bmp.Height);
Inc(R.Left, 2);
Inc(R.Top, 2); slLine := TStringList.Create;
slLine.Text := StringReplace(AHint, #$0A#$0D, #$0D#$0A, [rfReplaceAll]); iLineH := 0;
for iLineNo := 0 to slLine.Count - 1 do
begin
if (iLineNo mod 3) = 0 then Bmp.Canvas.Font.Style := [fsBold]; //标题
if (iLineNo mod 3) = 1 then Bmp.Canvas.Font.Style := []; //正文
if (iLineNo mod 3) = 2 then ; //分段(换行符) //DrawText(Bmp.Canvas.Handle, PChar(AHint), -1, R, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK or DrawTextBiDiModeFlagsReadingOnly);
R.Top := R.Top + iLineH;
iLineH := DrawText(Bmp.Canvas.Handle, PChar(slLine.Strings[iLineNo]), -1, R, DT_LEFT or DT_NOPREFIX or DT_WORDBREAK or DrawTextBiDiModeFlagsReadingOnly);
if iLineH < 10 then iLineH := 13;
end; slLine.Free;
end;initialization
Application.ShowHint := False;
HintWindowClass := TwdHintWnd; //THintWindow
Application.ShowHint := True;
Application.HintHidePause := -1;end.