3 de fev. de 2005

Como impedir a movimentação do form MDI filho?

Do fórum ClubeDelphi:

usando o código mostrado no post sobre ocultar as barras de rolagem em aplicativo MDI... tem como impedir a movimentação do form MDI filho para fora da área do MDI pai?

Pesquisei o NG da Borland e encontrei esta thread com o seguinte código:

1 type 2 TForm2 = class... 3 private 4 procedure WMWindowPosChanging(var Msg: TWMWindowPosChanging); 5 message WM_WINDOWPOSCHANGING; 6 ... 7 8 procedure TForm2.WMWindowPosChanging(var Msg: TWMWindowPosChanging); 9 var 10 R: TRect; 11 begin 12 with Msg.WindowPos^ do begin 13 14 if (flags and SWP_NOMOVE) = 0 then begin 15 16 Windows.GetClientRect(Application.MainForm.ClientHandle, R); 17 18 if x < 0 then 19 x := 0; 20 21 if y < 0 then 22 y := 0; 23 24 if (x + cx) > R.Right then 25 x := R.Right - cx; 26 27 if (y + cy) > R.Bottom then 28 y := R.Bottom - cy; 29 end; 30 end; 31 32 inherited; 33 end;

Nenhum comentário: