티스토리 뷰
폼들이 화면 밖으로 나가지 못하게 하려할때!
포인트 : 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.
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.
'프로그래밍 > Delphi' 카테고리의 다른 글
[델파이소스] 윈도우 핸들로 실행화일명 찾기 (0) | 2009.08.05 |
---|---|
[델파이소스] IDFTP 이용한 디렉토리 통째 업로드 (0) | 2009.08.05 |
[델파이소스] 문자열이 올바른 IP 인지 확인 함수 (0) | 2009.08.05 |
[델파이소스] 작업스케쥴러 추가 (1) | 2009.08.05 |
[델파이소스] PC재부팅, PC끄기, 로그오프 (0) | 2009.08.05 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크