QQ的窗口实现(用消息TMMESSAGE)
现在我在要做一个窗体界面。即窗口的隐藏。
已写出的代码如下:
unit q;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ShellAPI, AppEvnts;
type
TForm1 = class(TForm)
ApplicationEvents1: TApplicationEvents;
procedure FormCreate(Sender: TObject);
private
iXSize, iYSize: integer;
FromActive: Boolean;
procedure WMMove(var msg: TWMMOVE); message WM_MOVE;
procedure WMMOUSEENTER(var msg: TMessage);message CM_MOUSEENTER;
procedure WMMOUSELEAVE(var msg: TMessage);message CM_MOUSELEAVE;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
X1, Y1: integer;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.WMMOUSEENTER(var msg: TMessage);
var
pt :TPoint;
X1, Y1: integer;
begin
with Form1 do
begin
if ( Left = -Width + 10) then
begin
left := 0;
Form1.Height := Screen.Height;
FromActive := True;
msg.Result := 0;
end
else if Left = Screen.Width - 50 then
begin
top := 0;
left := SCreen.Width - Form1.Width;
Form1.Height := Screen.Height;
FromActive := True;
msg.Result := 0;
end
else
begin
iXSize := Form1.Width;
iYSize := Form1.Height;
msg.Result := 0;
end;
end;
end;
procedure TForm1.WMMOUSELEAVE(var msg: TMessage);
begin
end;
procedure TForm1.WMMove(var msg: TWMMOVE);
var
pt :TPoint;
begin
Inherited;
// Form1.Top := 0 - form1.Height +5;
x1 := msg.XPos;
y1 := msg.YPos;
// Form1.Width := iXSize;
// Form1.Height := iYSize;
if x1 < 50 then
begin
Form1.Left := - Form1.Width + 10;
Form1.Top :=0;
form1.Height :=Screen.Height ;
msg.Result := 0;
end
else if X1 > Screen.Width - 100 then
begin
Form1.Left := Screen.Width - 50;
Form1.Top := 0;
Form1.Height := Screen.Height;
msg.Result := 0;
end
else
begin
Form1.Width := iXSize;
Form1.Height := iYSize;
end;
msg.Result := 0;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.Width := 150;
Form1.Height := 350;
iXSize := Form1.Width;
iYSize := Form1.Height;
end;
end.
也不用多看,就是一个消息的识别。
但是,当我的问题出在:怎么样才能有效的将窗口从两边现出来。拖出窗口后,窗口的大小与原来的一样。用户可以在窗口没有粘在边沿上的时候进行大小修改。同时拖动时,如果用MOVE消息,会发现这个窗口是抖动的,有什么好的解决办法吗?