알짜게시판

[델파이] bsNone 인 폼에서 드래그 및 크기조절

unit Area;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.Mask, Vcl.ExtCtrls,
  JvExControls, JvButton, JvNavigationPane, Vcl.Buttons;

type
  TFrmArea = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    Label1: TLabel;
    Memo1: TMemo;
    JvNavIconButton1: TJvNavIconButton;
    Button1: TButton;
    BitBtn1: TBitBtn;
    SpeedButton1: TSpeedButton;
    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    procedure FormResize(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  protected
    procedure CreateParams(var Params: TCreateParams); override;
    procedure WMNCHitTest(var message: TWMNCHitTest); message WM_NCHITTEST;
  private
  public
    { Public declarations }
  end;

const
  Edge = 5;

var
  FrmArea: TFrmArea;

implementation

{$R *.dfm}

{ TFrmArea }

procedure TFrmArea.CreateParams(var Params: TCreateParams);
begin
  BorderStyle := bsNone;

  inherited;

  Params.WndParent := 0;
  Params.ExStyle := Params.ExStyle or WS_EX_APPWINDOW;
end;

procedure TFrmArea.FormCreate(Sender: TObject);
begin
  FormResize(Sender);
end;

procedure TFrmArea.FormResize(Sender: TObject);
var
  WindowRgn, HoleRgn : HRgn;
begin
  WindowRgn := 0;
  GetWindowRgn(Handle, WindowRgn);
  DeleteObject(WindowRgn);
  WindowRgn := CreateRectRgn(0, 0, Width, Height);
  HoleRgn := CreateRectRgn(Edge, Edge+Panel1.Height+Edge, Width-Edge, Height-Edge);
  CombineRgn(WindowRgn, WindowRgn, HoleRgn, RGN_DIFF);
  SetWindowRgn(Handle, WindowRgn, TRUE);
  DeleteObject(HoleRgn);
end;

procedure TFrmArea.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture;
  SendMessage(Handle, WM_NCLBUTTONDOWN, htCaption, 0);
end;

procedure TFrmArea.WMNCHitTest(var Message: TWMNCHitTest);
var
  P: TPoint;
begin
  inherited;

  P := ScreenToClient(Message.Pos);

  with Message do
  begin
    if Result = htClient then Exit;

    Result := htCaption;

    if P.Y < Edge then
    begin
      if P.X < Edge then
        Result := htTopLeft
      else if P.X > ClientWidth - Edge then
        Result := htTopRight
      else
        Result := htTop;
    end
    else if P.Y > ClientHeight - Edge then
    begin
      if P.X < Edge then
        Result := htBottomLeft
      else if P.X > ClientWidth - Edge then
        Result := htBottomRight
      else
        Result := htBottom;
    end
    else
    begin
      if P.X < Edge then
        Result := htLeft
      else if P.X > ClientWidth - Edge then
        Result := htRight
    end;
  end;
end;

end.

로그인 후 댓글내용을 입력해주세요

제목 글쓴이 조회 날짜
[PHP] Curl 접속 속도가 늦은 경우 36,956 23-04-10
[윈도우] 파일 내용 검색 46,088 23-02-09
[MySQL] unblock with 'mysqladmin flush-hosts' 에러 54,098 23-01-01
[ReactNative] 캐시 초기화 하는 방법 57,723 22-12-27
[윈도우] node.js 와 npm 업데이트(업그레이드) 57,754 22-12-01
[윈도우] 윈도우11 시작 메뉴 위치 변경(가운데, 왼쪽) 60,804 22-10-10
[델파이] 중복 실행 방지 59,243 22-09-21
[리눅스] yum 에서 Thread died in Berkeley DB library 오류 59,443 22-09-18
[리눅스] VNSTAT 설치하기 56,399 22-09-17
[리눅스] 로그 삭제 및 비우기(?) 58,562 22-09-09
[FTP] 500 Illegal PORT command. 47,766 22-09-03
[리눅스] .htaccess 를 이용해서 https 이동하기 45,614 22-08-31
[PHP] Imagek 를 이용한 썸네일 생성 46,027 22-08-26
[그누보드] 1364 : Field 'xxxxx' doesn't have a default value 45,484 22-08-20
[리눅스] 윈도우 프로그램 실행 (centos7, wine 7.0) 45,398 22-08-09
[윈도우] IPv6 켜기, 끄기 45,656 22-08-03
[그누보드] 회원 가입일 기준으로 이용기간 정하기 41,394 22-07-28
[그누보드] sql_fetch, sql_query 안쓰고 직접 mysql 사용하기 41,028 22-07-24
[PHP] PHP 수정시 적용이 안되는 경우 해결 (opcache 중지) 35,657 21-03-31
[맥OS] 마우스 휠 스크롤 방향 윈도우와 일치시키는 방법 26,329 21-02-28
[Ruby] 윈도우에서 pod install 실행시 UTF-8 오류 27,244 21-02-28
[Ruby] Could not open library 'libcurl' 25,512 21-02-28
[Android] Error type 3: Activity class {com.?.MainActivity} … 16,804 21-02-02
[PHP] Curl 을 이용하여 파일 다운로드 6,324 21-01-19
[PHP] Curl 을 이용하여 json 을 post 보내기 6,900 21-01-19
설치하려고 하는 앱이 Microsoft에서 확인된 앱이 아닙니다. 16,831 20-10-11
[델파이] Glyph 에 사용할 이미지 생성하기 1,940 20-09-02
파이썬 아나콘다 업데이트 2,196 20-08-06
[델파이] bsNone 인 폼에서 드래그 및 크기조절 3,553 20-07-11
[리눅스] Composer 설치하기 2,155 20-07-06
[윈도우] WinHTTP 사용에서 12175 에러 발생시 5,384 20-04-04
목록
심리톡톡개봉닷컴결혼준비성장노트꽃한송이