알짜게시판

[Delphi] bsNone 인 폼에서 드래그 및 크기조절

[code]

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.
[/code]

번호 제목 글쓴이 조회 날짜
57 [Linux] 데몬(systemd service) 작성 및 실행하기 23,581 03-14
56 [MySQL] 업데이트 이후 에러 발생([ERROR] Incorrect definition of table … 90,049 12-08
55 구글 크롬 탭검색 비활성화 70,972 12-04
54 [MySQL] MySQL, MariaDB 업데이트 72,733 11-24
53 [아이폰] HTTPS 감청 우회하기 97,476 11-01
52 Windows에 Rust 설치하기 56,486 10-05
51 [ReactNative] android directory was detected in the project. 64,646 07-20
50 [리눅스] 메일(Mail) 삭제/초기화 57,359 07-18
49 [Delphi] 윈도우 알림센터에 메시지 출력하기 54,502 06-20
48 텔레그램 봇 (Telegram Bot) 만들기 37,222 05-03
47 [부트스트랩] nav 에서 하위 항목 활성화 시 부모 항목 활성화 34,336 04-30
46 [리눅스] PHP 버전 추가하기 33,977 04-29
45 [PHP] Curl 접속 속도가 늦은 경우 35,643 04-10
44 [윈도우] 파일 내용 검색 45,011 02-09
43 [MySQL] unblock with 'mysqladmin flush-hosts' 에러 52,973 01-01
42 [ReactNative] 캐시 초기화 하는 방법 55,376 12-27
41 [윈도우] node.js 와 npm 업데이트(업그레이드) 56,710 12-01
40 [윈도우] 윈도우11 시작 메뉴 위치 변경(가운데, 왼쪽) 59,872 10-10
39 [Delphi] 중복 실행 방지 58,361 09-21
38 [리눅스] yum 에서 Thread died in Berkeley DB library 오류 58,057 09-18
37 [리눅스] VNSTAT 설치하기 55,462 09-17
36 [리눅스] 로그 삭제 및 비우기(?) 56,800 09-09
35 [FTP] 500 Illegal PORT command. 46,666 09-03
34 [리눅스] .htaccess 를 이용해서 https 이동하기 44,848 08-31
33 [PHP] Imagek 를 이용한 썸네일 생성 45,292 08-26
32 [그누보드] 1364 : Field 'xxxxx' doesn't have a default value 44,738 08-20
31 [리눅스] 윈도우 프로그램 실행 (centos7, wine 7.0) 44,146 08-09
30 [윈도우] IPv6 켜기, 끄기 43,396 08-03
29 [그누보드] 회원 가입일 기준으로 이용기간 정하기 40,702 07-28
28 [그누보드] sql_fetch, sql_query 안쓰고 직접 mysql 사용하기 40,335 07-24
27 [PHP] PHP 수정시 적용이 안되는 경우 해결 (opcache 중지) 34,825 03-31
목록