Programming/Delphi

런타임 중에 컨트롤 사이즈 조절하기

통통만두 2010. 7. 20. 19:00
반응형
{$REGION ' 컨트롤 크기 변경 '}
procedure Tfrm_Main.MouseMoveEvent(Sender: TObject; Shift: TShiftState; X, Y: Integer);
var
   WinControl : TWinControl absolute Sender;
begin
   if ((X < SC_DRAG_SIZE) AND (Y < SC_DRAG_SIZE))or ((X > WinControl.Width - SC_DRAG_SIZE) and (Y > WinControl.Height - SC_DRAG_SIZE)) then
      WinControl.Cursor := crSizeNWSE
   else if ((X < SC_DRAG_SIZE) and (Y > WinControl.Height-SC_DRAG_SIZE)) or ((X > WinControl.Width-SC_DRAG_SIZE) and (Y < SC_DRAG_SIZE))then
      WinControl.Cursor := crSizeNESW
   else if ((X < SC_DRAG_SIZE )or (X > WinControl.Width-SC_DRAG_SIZE))then
      WinControl.Cursor := crSizeWE
   else if ((Y < SC_DRAG_SIZE) or (Y > WinControl.Height-SC_DRAG_SIZE))then
      WinControl.Cursor := crSizeNS
   else
      WinControl.Cursor := crDefault;
end;

procedure Tfrm_Main.MouseDownEvent(Sender: TObject; Button: TMouseButton;
   Shift: TShiftState; X, Y: Integer);
var
   WinControl: TWinControl;
   SysCommWparam: integer;
begin
   WinControl := TWinControl(Sender);

   if (X < SC_DRAG_SIZE )and ( Y < SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZEUL
   else if(X > WinControl.Width-SC_DRAG_SIZE) and (Y > WinControl.Height-SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZEDR
   else if(X < SC_DRAG_SIZE) and (Y > WinControl.Height-SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZEDL
   else if(X > WinControl.Width-SC_DRAG_SIZE ) and ( Y < SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZEUR
   else if(X < SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZEL
   else if(X > WinControl.Width-SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZER
   else if(Y < SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZEU
   else if(Y > WinControl.Height-SC_DRAG_SIZE) then
      SysCommWparam := SC_DRAG_RESIZED
   else
      SysCommWparam := SC_DRAG_MOVE;

   ReleaseCapture();
   //SendMessage(WinControl.Handle, WM_SYSCOMMAND, SysCommWparam, 0);
   SendMessage(WinControl.Parent.Handle, WM_SYSCOMMAND, SysCommWparam, 0);
end;
{$ENDREGION}


참조 : http://delphi.about.com/library/weekly/aa110105a.htm
반응형

'Programming > Delphi' 카테고리의 다른 글

윈도우 특정키 막기  (0) 2010.07.23
델파이 Key Constants  (0) 2010.07.21
특정 폴더 오픈하기  (0) 2010.07.02
설치된 프로그램 리스트 얻기  (0) 2010.06.30
웹에서 HTML 소스 가져오기  (0) 2010.06.30