无标题的窗体,如何用鼠标拖动进行缩放????(50分)

L

laoli

Unregistered / Unconfirmed
GUEST, unregistred user!
新建一个过程,什么属性都不改,加入下面代码:
TForm1 = class(TForm)
...
procedure FormCreate(Sender: TObject);
private
...
procedure WMNCHitTest(var Msg: TWMNCHitTest);
message wm_NCHitTest;
end;
实现部分:
procedure TForm1.FormCreate(Sender: TObject);
var
TitleHeight: Integer;
begin
TitleHeight:= Height - ClientHeight;
SetWindowLong(Handle,GWL_STYLE, GetWindowLong(Handle,GWL_STYLE) AND NOT WS_CAPTION);
ClientHeight:= Height - TitleHeight;
Width:= Width + 1;
// 强迫它刷新一下自己
end;

procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
inherited;
if Msg.Result = htClient then
Msg.Result := htCaption;
end;

你运行一下看看,:)
如果解决了,别忘了给分,:)
 
如果只是鼠标拖动无标题窗体的缩放,下面简单: [:)]
.............
private
procedure CreateParams(var params:TCreateParams);override;
..............
implementation
procedure TForm1.CreateParams(var params:TCreateParams);//重载的方法
begin

Inherited createparams(params) ;

params.style:=WS_THICKFRAME or WS_POPUP or WS_BORDER;
end;
 
最简单的方法是在Form的MouseDown中加入:
procedure TForm1.FormMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
ReleaseCapture;
SendMessage(handle,wm_SysCommand,$F012,0);
end;
 
创建一个Panel,在OnMouseMove事件中写入以下代码:
procedure TfrmMain.panRightMouseMove(Sender: TObject;
Shift: TShiftState;
X, Y: Integer);
begin
if Shift=[ssLeft] then
begin
ReleaseCapture;
SendMessage(handle,WM_NCLBUTTONDOWN,HTRIGHT,0);
end;
end;
以上是向右,向下将“HTRIGHT”改为“HTBOTTOM”。
试一下就明白了
 
哦,对,是“缩放”。下面是我抄的,拖动和缩放它都做到了。
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;
type
TForm1 = class(TForm)
procedure FormMouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
implementation
{$R *.DFM}
procedure ManipulateControl(Control: TControl;
Shift: TShiftState;
X, Y, Precision: integer);
var
SC_MANIPULATE: Word;
begin
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最左侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if (X<=Precision) and (Y>Precision) and (Y<Control.Height-Precision)
then
begin
SC_MANIPULATE := $F001;
Control.Cursor := crSizeWE;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最右侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X>=Control.Width-Precision) and (Y>Precision) and (Y<Control.Height-Precision)
then
begin
SC_MANIPULATE := $F002;
Control.Cursor := crSizeWE;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最上侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X>Precision) and (X<Control.Width-Precision) and (Y<=Precision)
then
begin
SC_MANIPULATE := $F003;
Control.Cursor := crSizeNS;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的左上角**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X<=Precision) and (Y<=Precision)
then
begin
SC_MANIPULATE := $F004;
Control.Cursor := crSizeNWSE;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的右上角**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X>=Control.Width-Precision) and (Y<=Precision)
then
begin
SC_MANIPULATE := $F005;
Control.Cursor := crSizeNESW ;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的最下侧**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X>Precision) and (X<Control.Width-Precision) and (Y>=Control.Height-Precision)
then
begin
SC_MANIPULATE := $F006;
Control.Cursor := crSizeNS;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的左下角**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X<=Precision) and (Y>=Control.Height-Precision)
then
begin
SC_MANIPULATE := $F007;
Control.Cursor := crSizeNESW;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的右下角**********************************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X>=Control.Width-Precision) and (Y>=Control.Height-Precision)
then
begin
SC_MANIPULATE := $F008;
Control.Cursor := crSizeNWSE;
end
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//光标在控件的客户区(移动整个控件)******************************************
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
else
if (X>5) and (Y>5) and (X<Control.Width-5) and (Y<Control.Height-5)
then
begin
SC_MANIPULATE := $F009;
Control.Cursor := crSizeAll;
end
else
begin
SC_MANIPULATE := $F000;
Control.Cursor := crDefault;
end;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
if Shift=[ssLeft] then
begin
ReleaseCapture;
Control.Perform(WM_SYSCOMMAND, SC_MANIPULATE, 0);
end;
end;


procedure TForm1.FormMouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
begin
Caption := IntToStr(X) + '/' + IntToStr(Y);
ManipulateControl((Sender as TControl), Shift, X, Y, 10);
end;

end.
 

首先申明,我作的这个窗体是一个FLASH的屏幕窗体
在TFORM1.onResize里已经做了整体缩放处理
panel1.setfocus;
shockwaveflash1.setfocus;
没有事先声明,不好意思。。。。
to SupermanTm 能移动但不能缩放
to jrq 运行后,好像刷新有点问题, 依然不行。
to zw84611 没有效果
to 我来也 没有效果
to zw84611 也是没有效果
大家都有分,但是期待更好的答案。。。。。。。。。
 
老兄,不会吧。我copy的源码呀~~ [:)]
 
我测试过,可以拖动边界达到缩放的啊!
 
顶部