1. 最大化时窗体总是到分辨率允许的范围内,如何设置大小其超过分辨率限制?(试过setwindowpos/Movewindow均不行)
2. 如何做到类似游戏地图一样,鼠标停在某固定边缘可以将窗口内的图片拉出来,且在边缘时移动越快,拉出速度也越快
3. 如何在第3方窗体的右上角加多一个图标(原有最大最小化等),并在点击时执行我的代码?
(分不够另外贴中结算)

解决方案 »

  1.   

    3 这是一个添加按钮的例程unit Unit1;interfaceuses
      Windows, Buttons, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs;type
      TForm1 = class(TForm)
        procedure FormResize(Sender: TObject);
      private
        { Private declarations }
        CaptionBtn:TRect;
        procedure DrawCaptButton;
        procedure WMNCPaint(var Msg:TWMNCPaint);message WM_NCPaint;
        procedure WMNCActivate(var Msg:TWMNCActivate);message WM_NCActivate;
        procedure WMSetText(var Msg:TWMSetText);message WM_SetText;
        procedure WMNCHitTest(var Msg:TWMNCHitTest);message WM_NCHittest;
        procedure WMNCLButtonDown(var Msg:TWMNCLButtonDown);message WM_NCLButtonDown;
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementationconst
      htCaptionBtn=htSizeLast+1;{$R *.DFM}procedure TForm1.DrawCaptButton;
    var
      xFrame,yFrame,xSize,ySize:Integer;
      R:TRect;
    begin
      xFrame:=GetSystemMetrics(SM_CXFRAME);
      yFrame:=GetSystemMetrics(SM_CYFRAME);
      xSize:=GetSystemMetrics(SM_CXSIZE);
      ySize:=GetSystemMetrics(SM_CYSIZE);
      //按钮属性调整->>
      CaptionBtn:=Bounds(Width-xFrame-5*xSize+2,yFrame+2,xSize+13,ySize-4);
      Canvas.Handle:=GetWindowDC(Self.Handle);
      Canvas.Font.Name:='宋体';
      Canvas.Font.Color:=clBlack;
      Canvas.Pen.Color:=clYellow;
      Canvas.Brush.Color:=clBtnFace;
      try
        DrawButtonFace(Canvas,CaptionBtn,1,bsAutoDetect,False,False,False);
        R:=Bounds(Width-xFrame-5*xSize+3,yFrame+3,xSize+10,ySize-7);
        with CaptionBtn do
          Canvas.TextRect(R,R.Left+5,R.Top,'New');
      finally
        ReleaseDC(Self.Handle,Canvas.Handle);
        Canvas.Handle:=0;
      end;
    end;procedure TForm1.WMNCActivate(var Msg: TWMNCActivate);
    begin
    inherited;
      DrawCaptButton;
    end;procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
    begin
    inherited;
      with Msg do
        if PtInRect(CaptionBtn,Point(xPos-Left,yPos-Top)) then
        Result:=htCaptionBtn;
    end;procedure TForm1.WMNCLButtonDown(var Msg: TWMNCLButtonDown);
    begin
    inherited;
      if(Msg.HitTest=htCaptionBtn)then
        Showmessage('添加您想执行的代码');
    end;procedure TForm1.WMNCPaint(var Msg: TWMNCPaint);
    begin
    inherited;
      DrawCaptButton;
    end;procedure TForm1.WMSetText(var Msg: TWMSetText);
    begin
    inherited;
      DrawCaptButton;
    end;procedure TForm1.FormResize(Sender: TObject);
    begin
      Perform(WM_NCACTIVATE,Word(Active),0);
    end;
      

  2.   

    1:拦截WM_SYSCOMMAND消息
    2:创建一个线程监视/计算鼠标行为,根据行为发送相应指令
    3: 遍历窗口EnumWindows,对可见窗口安装消息钩子
       或者子类化处理 dllinject+SetWindowLong
      

  3.   

    问题1
    分辨率与窗体大小(最大值)的关系
    分辨率                窗体大小(最大值)
    1024 X 768         1036 X 780
    1280 X 1024        1292 X 1036