티스토리 뷰


폼들이 화면 밖으로 나가지 못하게 하려할때!
포인트 : WM_WINDOWPOSCHANGING 후킹

interface

uses

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

type
TForm1 = class(TForm)

private
   { Private declarations }
   procedure WMWindowPosChanging(var Message: TWMWindowPosChanging); message    
WM_WINDOWPOSCHANGING;
public
   { Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}



procedure TForm1.WMWindowPosChanging(var Message: TWMWindowPosChanging);
begin
  with Message.WindowPos^ do
  begin
    // Message.WindowPos^의 좌표를 이용해 폼이 데스크탑의 밖으로 나갈때
    // 가로채서 바탕화면의 가장자리에 붙여버린다.

    // 아래는 왼쪽 가장자리.. x : x 좌표 y : y 좌표, cx : 너비 cy :높이
    if X < 30 then x := 0;
    if Y < 30 then Y := 0;
    if X > Screen.Width - cx - 30 then X := Screen.Width - cx;
    if Y > Screen.Height - cy - 30 then Y := Screen.Height - cy;
  end;
end;

end.  

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크