对收费窗口的弹出计数,我没有好方法。不过,如果通过鼠标拖拽得到窗体的handle,
倒是还好实现。以下程序可以得到能拖拽的窗体(包括TEdit)handle。不妨参考一下。
==============
project1.dpr
==============
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1};
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
==============
unit1.pas
==============
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ComCtrls;
type
TForm1 = class(TForm)
Image1: TImage;
Edit1: TEdit;
Label1: TLabel;
Edit2: TEdit;
Label2: TLabel;
Label3: TLabel;
StatusBar1: TStatusBar;
procedure Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
MousePoint : TPoint;
PassWordHwnd : Hwnd;
PassWordContent : array [0..255] of char;
begin
MousePoint := Self.ClientToScreen(point(x,y));
PassWordHwnd := WindowFromPoint(MousePoint);
if (GetWindowLong(PassWordHwnd,GWL_STYLE) and es_password ) = 0 then
begin
StatusBar1.Panels[0].Text := '不是有效的密码框!';
end;
SendMessage( PassWordHwnd, WM_GETTEXT, 100, LongInt(@PassWordContent));
Edit1.Text := PassWordContent;
Edit2.Text := IntToStr(PassWordHwnd);
MessageBeep(0);
end;
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
StatusBar1.Panels[0].Text := '正在查询...';
end;
end.