气泡提示,判断SQL SERVER是否停止服务

                            作者: 蓝叶菱
标题: 气泡提示,判断SQL SERVER是否停止服务。 
关键字: Hint,SQL SERVER 
分类: 编程手记 
密级: 公开 

http://www.delphibbs.com/keylife/iblog_show.asp?xid=21926


转载:bbscom
----------------
任何在TDBEdit控件上显示气泡提示?
像在XP登录时一样,有三角形的气泡提示信息。
Delphi怎么用它?
---
鼠标移动到MEMO上提示HINT,气泡提示。
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)
    Button1: TButton;
    Memo1: TMemo;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(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.Button1Click(Sender: TObject);
begin
  CreateToolTips(Form1.Handle);
  AddToolTip(Memo1.Handle, @ti, 0, '测试飞跃提示', '无图标提示');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  CreateToolTips(Form1.Handle);
  AddToolTip(Memo1.Handle, @ti, 1, '测试飞跃提示', '信息图标');
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
  CreateToolTips(Form1.Handle);
  AddToolTip(Memo1.Handle, @ti, 2, '测试飞跃提示', '警告图标');
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
  CreateToolTips(Form1.Handle);
  AddToolTip(Memo1.Handle, @ti, 3, '测试飞跃提示', '错误图标');
end;

end.
------------判断SQL SERVER 服务是否断开,可是判断端口的方法,判断SQL SERVER 服务的方法---
unit DTDem;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Psock, NMDayTim, ExtCtrls, ComCtrls;

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    NMDayTime1: TNMDayTime;
    Button1: TButton;
    Label3: TLabel;
    StatusBar1: TStatusBar;
    procedure Button1Click(Sender: TObject);
    procedure NMDayTime1Connect(Sender: TObject);
    procedure NMDayTime1Disconnect(Sender: TObject);
    procedure NMDayTime1HostResolved(Sender: TComponent);
    procedure NMDayTime1Status(Sender: TComponent; Status: String);
    procedure NMDayTime1ConnectionFailed(Sender: TObject);
    procedure NMDayTime1InvalidHost(var handled: Boolean);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

const
  StdCap = 'The Current Date and Time is : ';

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
  NMDayTime1.ReportLevel := Status_Basic;  //控制数量,Status_Basic=2。
  NMDayTime1.TimeOut := 300;  //控制时间,以毫秒为单位。
  NMDayTime1.Host := Edit1.Text;  //主机的名称或远程主机的IP地址。
  NMDayTime1.Port := StrToInt(Edit2.Text); //主机的端口。
  Label3.Caption := StdCap+NMDayTime1.DayTimeStr;//显示时间。
end;
//连接远程主机,此事件发生。
procedure TForm1.NMDayTime1Connect(Sender: TObject);
begin
  StatusBar1.SimpleText := 'Connected';     //显示连接
end;
//和远程的主机没连接上,此事件发生。
procedure TForm1.NMDayTime1Disconnect(Sender: TObject);
begin
  If StatusBar1 <> nil then
    StatusBar1.SimpleText := 'disconnected'; //显示断开连接。
end;
//当远程的主机地址被断然拒绝,此事件发生。
procedure TForm1.NMDayTime1HostResolved(Sender: TComponent);
begin
  StatusBar1.SimpleText := 'Host resolved';
end;
//一些状态改变时,此事件发生。
procedure TForm1.NMDayTime1Status(Sender: TComponent; Status: String);
begin
  If StatusBar1 <> nil then
    StatusBar1.SimpleText := status;
end;
//连接失败,此事件发生。
procedure TForm1.NMDayTime1ConnectionFailed(Sender: TObject);
begin
  ShowMessage('Connection Failed');
end;
//主机出毛病,此事件发生。
procedure TForm1.NMDayTime1InvalidHost(var handled: Boolean);
var
  TmpStr: String;
begin
  If InputQuery('Invalid Host!', 'Specify a new host:', TmpStr) then
  Begin
    NMDayTime1.Host := TmpStr;
    Handled := TRUE;
  End;
end;

end.
要使用TNMDayTime控件。
AdoQquery1.Sort = '字段名称 ASC' 


                                

查看回复