ShowModal 폼을 불러내고 마우스 클릭이 모달폼 밖에서 클릭하면
자동으로 폼을 종료하게 하고 싶습니다.
좋은 방법이 있으면 알려주세요.
마우스 이벤트를 이용했지만 작동을 하지 않네요~
고수님들 좋은 방법좀 알려 주시기 바랍니다.
procedure TfrmPopupMenu.WMNCLButtonDown(var Msg : TWMNCLButtonDown);
var
MousePtX,
MousePtY : Integer;
FromAreaL,
FromAreaR,
FromAreaT,
FromAreaB : Integer;
FromRect : TRect;
begin
GetWindowRect(frmPopupMenu.Handle, FromRect);
FromAreaL := FromRect.Left;
FromAreaR := FromRect.Right;
FromAreaT := FromRect.Top;
FromAreaB := FromRect.Bottom;
MousePtX := Mouse.CursorPos.X;
MousePtY := Mouse.CursorPos.Y;
if (((MousePtX < FromAreaL) and (FromAreaR < MousePtX)) and
((MousePtY < FromAreaT) and (FromAreaB < MousePtY))) then //Clsoe;
lblMainTitle.Caption := 'OUT'
else lblMainTitle.Caption := 'IN';
end;
다른애플리케이션(바탕화면을 클릭한다던가... )을 활성화했다가 넘어올때는 Application.OnActivate 를 이용해야 합니다.
팁란에서 찾았는데요..
어떤 팁에 대한 꼬릿말입니다.해보진 않았지만..
Application.OnActivate와 OnDeactive를 이용하면 되겠네요
그리고 팁에서는
procedure WMActive(var Message: TWMActivate); message WM_ACTIVATE;
procedure TForm1.WMActive(var Message: TWMActivate);
begin
if Message.Active = WA_INACTIVE then
begin
Label1.Caption := 'OUT';
end
else if Message.Active in [WA_ACTIVE, WA_CLICKACTIVE] then
begin
Label1.Caption := 'IN';
end;
end;
아주 잘먹더군요..두개중에 아무거나 선택해서 쓰십시오..
덕분에 하나 배웠네요..