A
ADSL08
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, commctrl, StdCtrls;
const
TTS_BALLOON = $40;
TTM_SETTITLE = (WM_USER + 32);
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure AddToolTip(hwnd: DWORD; lpti: PToolInfo; IconType: Integer;
Text, Title: PChar);
procedure CreateToolTips(hwnd: Cardinal);
var
Form1: TForm1;
hTooltip: Cardinal;
ti: TToolInfo;
buffer: array[0..255] of char;
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);
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);
begin
CreateToolTips(Form1.Handle);
AddToolTip(Edit1.Handle, @ti, 0, '飞跃提示1', '提示');
AddToolTip(Edit2.Handle, @ti, 0, '飞跃提示2', '提示');
AddToolTip(Edit3.Handle, @ti, 0, '飞跃提示3', '提示');
AddToolTip(Edit4.Handle, @ti, 0, '飞跃提示4', '提示');
AddToolTip(Edit5.Handle, @ti, 0, '飞跃提示5', '提示');
end;
end.
上面的代码是当鼠标放到TEdit控件上才会有提示。
如何修改上面的代码,当TEdit控件具有焦点时,具有上面一样的提示信息。
在线等。急!!!
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, commctrl, StdCtrls;
const
TTS_BALLOON = $40;
TTM_SETTITLE = (WM_USER + 32);
type
TForm1 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
procedure AddToolTip(hwnd: DWORD; lpti: PToolInfo; IconType: Integer;
Text, Title: PChar);
procedure CreateToolTips(hwnd: Cardinal);
var
Form1: TForm1;
hTooltip: Cardinal;
ti: TToolInfo;
buffer: array[0..255] of char;
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);
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);
begin
CreateToolTips(Form1.Handle);
AddToolTip(Edit1.Handle, @ti, 0, '飞跃提示1', '提示');
AddToolTip(Edit2.Handle, @ti, 0, '飞跃提示2', '提示');
AddToolTip(Edit3.Handle, @ti, 0, '飞跃提示3', '提示');
AddToolTip(Edit4.Handle, @ti, 0, '飞跃提示4', '提示');
AddToolTip(Edit5.Handle, @ti, 0, '飞跃提示5', '提示');
end;
end.
上面的代码是当鼠标放到TEdit控件上才会有提示。
如何修改上面的代码,当TEdit控件具有焦点时,具有上面一样的提示信息。
在线等。急!!!