捐赠 | 广告 | 注册 | 发布 | 上传 | 关于我们    
  粤ICP备10103342号-1 DELPHI盒子 | 盒子文章 | 盒子问答悬赏 | 最新更新 | 盒子检索 | 下载中心 | 高级搜索    
  精品专区 | 繁體中文 | 奖励公告栏 | 直通车账号登陆 | 关闭GOOGLE广告 | 临时留言    
 
广告
评论:JJYY 聊天软件 (含服务器)
twofinger 31114 2007/9/6 16:52:21
顶了。。。
123ha 22433 2006/3/27 16:17:48
谁知道到底怎么安装这些控件啊?为什么不能编译呢?

有没有详细的步骤啊?
zjylyj 21738 2006/2/24 17:32:31
请把以下内容完全覆盖从本软件作者自带的TMagnetic文件即可。
unit Magnetic;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,Dialogs,
  ExtCtrls;

type
  TMagOption = class (TPersistent)
  private
      fMagTray:boolean;
      fMagExplorer:boolean;
      fMagCustom:boolean;
  public
      constructor Create;
      destructor Destroy;override;
  published
      property MagTray:boolean     read fMagTray      write fMagTray;
      property MagExplorer:boolean read fMagExplorer  write fMagExplorer;
      property MagCustom:boolean   read fMagCustom    write fMagCustom;
  end;

type
  TMagnetic = class(TCustomPanel)
  private
    fActive:Boolean;
    fCanResize:Boolean;
    fOldPoint:TPoint;     {old mouse point}
    fNewPoint:TPoint;     {moved point}
    fMagEffect:Integer;   {magnetic effect default 10pix}
    fMagOption:TMagOption;
    fMovedByForm:Boolean;
    fForm:TForm;
    fOldX, fOldY: Integer;
    fOldTWndMethod:TWndMethod;
    HWnd_Tray,HWnd_Explorer:HWND;
    RWnd_Tray,RWnd_Explorer,RWnd_Custrom:TRect;
    procedure Magnetic(var MagPoint:TPoint);
    procedure WndProcMe(var Message: TMessage);
    procedure WMMouseMove(var Msg:TMessage);
    procedure WMLButtonDown(var Msg:TMessage);
    procedure WMNCHitTest(var Msg: TMessage);
    { private declarations }
  protected
    procedure Loaded;override;
    procedure SetMagOption(Value:TMagOption);
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    { protected declarations }
  public
    CustomMagWnd:HWND;
    constructor Create(AOwner:TComponent); override;
    destructor Destroy; override;
    { public declarations }
  published
    property Active:boolean       read fActive          write fActive;
    property FormCanResize:boolean    read fCanResize       write fCanResize;    
    property MagOption:TMagOption read fMagOption       write SetMagOption;
    property MagEffect:Integer    read fMagEffect       write fMagEffect;
    property MovedByForm:Boolean  read fMovedByForm     write fMovedByForm;
    property Color;
    property Caption;
    property Align;
    { published declarations }
  end;


procedure Register;

implementation

constructor TMagOption.Create;
begin
  inherited Create;
  fMagTray:=True;
  fMagExplorer:=False;
  fMagCustom:=False;
end;

destructor TMagOption.Destroy;
begin
  inherited Destroy;
end;

constructor TMagnetic.Create(AOwner:TComponent);
begin
  inherited Create(AOwner);
  fActive:=True;
  fMagEffect:=10;
  fMovedByForm:=false;
  height:=30;
  width:=100;
  BevelInner:=bvNone;
  BevelOuter:=bvNone;
  Parent:=fForm;
  fMagOption:=TMagOption.Create;
  fForm:=TForm(AOwner);
  if fForm.BorderStyle=bsNone then fCanResize:=true;
end;

destructor TMagnetic.Destroy;
begin
  fMagOption.Free;
  if not (CsDesigning in ComponentState) then
    fForm.WindowProc:=fOldTWndMethod;
  inherited Destroy;
end;

procedure TMagnetic.WndProcMe(var Message: TMessage);
begin
  { disable during Delphi IDE }
  if (CsDesigning in ComponentState) then fOldTwndMethod(Message)
  else
    case Message.Msg of
      WM_LBUTTONDOWN : WMLButtonDown(Message);
      WM_MOUSEMOVE   : WMMouseMove(Message);
      WM_NCHITTEST   : WMNCHitTest(Message);
    else fOldTwndMethod(Message);
  end;
end;

procedure TMagnetic.WMMouseMove(var Msg:TMessage);
var
  pt:TPoint;
begin
  if not (CsDesigning in ComponentState) then
  begin
    fOldTWndMethod(Msg);
    if not fActive then exit;
    {whether can move}
    if (fForm.WindowState<>wsNormal)and not fActive then exit;
    {whether mouse left button}
    if HiWord(GetAsyncKeyState(VK_LBUTTON))>0 then
    begin
      pt:=Point(TWMMouseMove(Msg).XPos,TWMMouseMove(Msg).YPos);
      {calculate new point}
      fNewPoint:=Point(fForm.left+pt.x-fOldPoint.x,fForm.top+pt.y-fOldPoint.y);
      Magnetic(fNewPoint);  {do magnetic}
      fForm.SetBounds(fNewpoint.X,fNewpoint.Y,fForm.Width,fForm.Height);
    end;
  end;
end;

procedure TMagnetic.WMLButtonDown(var Msg: TMessage);
begin
  if not (CsDesigning in ComponentState) then
  begin
    fOldTWndMethod(Msg);
    if not fActive then exit;
    fOldPoint:=Point(TWMLButtonDown(Msg).XPos,TWMLButtonDown(Msg).YPos);
    if MagOption.fMagCustom and (CustomMagWnd>0) then
      GetWindowRect(CustomMagWnd, RWnd_Custrom);     { get custom rect }
    if MagOption.fMagExplorer then
      HWnd_Explorer:=FindWindow('CabinetWClass',nil);{ get explorer handle }
      if HWnd_Explorer>0 then
        GetWindowRect(HWnd_Explorer, RWnd_Explorer); { get explorer rect }
    if MagOption.fMagTray then
      HWnd_Tray:=FindWindow('Shell_TrayWnd',nil);    { get traybar handle }
    if HWnd_Tray>0 then
      GetWindowRect(HWnd_Tray, RWnd_Tray);          { get taskbar rect }
  end;
end;

procedure TMagnetic.WMNCHitTest(var Msg:TMessage);
var
  pt:TPoint;
begin
  if not (CsDesigning in ComponentState) then
  begin
    fOldTWndMethod(Msg);
    {if windowstate not normal and not can resize then exit}
    if (fForm.WindowState<>wsNormal) or not fCanResize then exit;
    {get form's edges and change it's size}
    pt:=Point(TWMNCHitTest(Msg).XPos,TWMNCHitTest(Msg).YPos);
    pt:=fForm.ScreenToClient(pt);
    if (pt.x<5) and (pt.y<5) then Msg.Result:=htTopLeft
    else if (pt.x>fForm.Width-5) and (pt.y<5) then Msg.Result:=htTopRight
    else if (pt.x>fForm.Width-5) and (pt.y>fForm.Height-5) then Msg.Result:=htBottomRight
    else if (pt.x<5) and (pt.y>fForm.Height-5) then Msg.Result:=htBottomLeft
    else if (pt.x<5) then Msg.Result:=htLeft
    else if (pt.y<5) then Msg.Result:=htTop
    else if (pt.x>fForm.Width-5) then Msg.Result:=htRight
    else if (pt.y>fForm.Height-5) then Msg.Result:=htBottom;
  end;
end;

procedure TMagnetic.Magnetic(var MagPoint:TPoint);
begin
  if not fActive then exit;

  if MagOption.fMagCustom and (CustomMagWnd>0) then
  begin
    { mangetize custrom}
    if Abs(RWnd_Custrom.Bottom-MagPoint.Y)<fMagEffect then MagPoint.Y:=RWnd_Custrom.Bottom
    else if Abs(MagPoint.Y+fForm.Height-RWnd_Custrom.Top)<fMagEffect then MagPoint.Y:=RWnd_Custrom.Top-fForm.Height;
    if Abs(RWnd_Custrom.Right-MagPoint.X)<fMagEffect then MagPoint.X:=RWnd_Custrom.Right
    else if Abs(MagPoint.X+fForm.Width-RWnd_Custrom.Left)<fMagEffect then MagPoint.X:=RWnd_Custrom.Left-fForm.Width;
  end;

  if MagOption.fMagExplorer and (HWnd_Explorer>0) then
  begin
    { mangetize explorer}
    if Abs(RWnd_Explorer.Bottom-MagPoint.Y)<fMagEffect then MagPoint.Y:=RWnd_Explorer.Bottom
    else if Abs(MagPoint.Y+fForm.Height-RWnd_Explorer.Top)<fMagEffect then MagPoint.Y:=RWnd_Explorer.Top-fForm.Height;
    if Abs(RWnd_Explorer.Right-MagPoint.X)<fMagEffect then MagPoint.X:=RWnd_Explorer.Right
    else if Abs(MagPoint.X+fForm.Width-RWnd_Explorer.Left)<fMagEffect then MagPoint.X:=RWnd_Explorer.Left-fForm.Width;
  end;

  if MagOption.fMagTray and (HWnd_Tray>0) then
  begin
    { mangetize tray}
    if Abs(RWnd_Tray.Bottom-MagPoint.Y)<fMagEffect then MagPoint.Y:=RWnd_Tray.Bottom
    else if Abs(MagPoint.Y+fForm.Height-RWnd_Tray.Top)<fMagEffect then MagPoint.Y:=RWnd_Tray.Top-fForm.Height;
    if Abs(RWnd_Tray.Right-MagPoint.X)<fMagEffect then MagPoint.X:=RWnd_Tray.Right
    else if Abs(MagPoint.X+fForm.Width-RWnd_Tray.Left)<fMagEffect then MagPoint.X:=RWnd_Tray.Left-fForm.Width;
  end;

  { magnetize screen }
  if MagPoint.X<fMagEffect then MagPoint.X:=0;
  if MagPoint.X>Screen.Width-fForm.Width-fMagEffect then MagPoint.X:=Screen.Width-fForm.Width;
  if MagPoint.Y<fMagEffect then MagPoint.Y:=0;
  if MagPoint.Y>Screen.Height-fForm.Height-fMagEffect then MagPoint.Y:=Screen.Height-fForm.Height;
  { end screen }

end;

procedure TMagnetic.SetMagOption(Value:TMagOption);
begin
  FMagOption.Assign(Value);
end;

procedure TMagnetic.MouseDown(Button: TMouseButton; Shift: TShiftState; X,
  Y: Integer);
begin
  inherited;
  if not (CsDesigning in ComponentState) then
  begin
    if not fActive then exit;
    FOldX := X;
    FOldy := Y;
    if MagOption.fMagCustom and (CustomMagWnd>0) then
      GetWindowRect(CustomMagWnd, RWnd_Custrom);
    if MagOption.fMagExplorer then
      HWnd_Explorer:=FindWindow('CabinetWClass',nil);
      if HWnd_Explorer>0 then
        GetWindowRect(HWnd_Explorer, RWnd_Explorer);
    if MagOption.fMagTray then
      HWnd_Tray:=FindWindow('Shell_TrayWnd',nil);
    if HWnd_Tray>0 then
      GetWindowRect(HWnd_Tray, RWnd_Tray);
  end;
end;

procedure TMagnetic.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
  inherited;
  if not (CsDesigning in ComponentState) then
  begin
    if not fActive then exit;
    if (fForm.WindowState<>wsNormal)and not fActive then exit;
    if HiWord(GetAsyncKeyState(VK_LBUTTON))>0 then
    begin
      fNewPoint:=Point(fForm.left+x-fOldx,fForm.top+y-fOldy);
      Magnetic(fNewPoint);
      fForm.SetBounds(fNewpoint.X,fNewpoint.Y,fForm.Width,fForm.Height);
    end;
  end;
end;

procedure TMagnetic.Loaded;
begin
  inherited;
  if not (CsDesigning in ComponentState) then
  begin
    fOldTWndMethod:=fForm.WindowProc;
    if fMovedByForm then
      fForm.WindowProc:=WndProcMe;
  end;
end;

procedure Register;
begin
  RegisterComponents('Samples', [TMagnetic]);
end;


end.
wanlijielang 18751 2005/10/29 9:52:17
这个不错呢,我正准备做毕业设计呢,做一个
网上聊天程序,不知道有那位大哥可以帮帮我呀
我的QQ:277909748 加我呀,
你们也可以联系方式给我呀
cswang 18467 2005/10/17 0:54:29
我用 delphi7 没有
tclientsock 
哪能找到
zjf80 18442 2005/10/15 16:00:41
TMagnetic控件怎么装不上,点编译后没有一点反应.
wqy888 18340 2005/10/11 21:43:59
好东西 留个记号
loskiller 18308 2005/10/10 16:40:49
我上传的代码里放了TMagnetic控件
happy0429 18296 2005/10/10 8:39:07
TMagnetic这个控件用不起来,我装了盒子上找到的,不行,不知道到底在哪里有下载
yizongxing 18151 2005/9/27 16:40:36
顶不错
yinpengxiang 17584 2005/9/6 8:48:30
呵呵,有兴趣用用FC,www.friendcome.com
用delphi做的
技术上和这个差不多吧
cctv_6012_cn 17386 2005/8/31 16:05:53
刚下载了和同事试了一下,感觉很不错滴说,希望楼主能继续努力的啊
leon2huang 17370 2005/8/31 9:06:26
还是非常希望,把它做成一个我们可以共同使用的好工具,一起用它来聊天,该有多好。
加倍努力哦。
kygl 17333 2005/8/30 17:01:24
能用就是软件
leon2huang 17316 2005/8/30 9:29:20
--还有很多的bug,代码也很乱,感觉要做好太难了。

大家都这么说,不知道什么时候才会有完美的软件出现。
webfly 17314 2005/8/30 9:15:18
刚才测试了一下,效果不错,努力啊
sunyesy 17311 2005/8/30 7:53:27
还没下载看过,但是帮你顶起!勇气可嘉!
第一页 上一页 下一页 最后页 有 17 条纪录 共1页 1 - 17
 用户名:
 密 码:
自动登陆(30天有效)
 
  DELPHI盒子版权所有 技术支持:深圳市麟瑞科技有限公司 1999-2024 V4.01 粤ICP备10103342号-1 更新RSS列表