whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

46 Visitors Online


 
...allow to move form only within working area?
Autor: binary[lv]
Homepage: http://lovelysoft.sytes.net/
[ Print tip ]  

Tip Rating (8):  
     


{ .... }

type
  
TForm1 = class(TForm)
  private
  protected
    procedure 
WMMoving(var Message: TWMMoving); message WM_MOVING;
  public
  end
;

{ .... }

procedure TForm1.WMMoving(var Message: TWMMoving);
var
  
rec: ^TRect;
  wrk: TRect;
begin
  
SystemParametersInfo(spi_getworkarea, 0, @wrk, 0);
  rec := Pointer(Message.DragRect);
  if rec^.Left < wrk.Left then
  begin
    
rec^.Right := rec^.Right - (rec^.Left - wrk.Left);
    rec^.Left  := wrk.Left;
  end
  else if 
rec^.Right > wrk.Right then
  begin
    
rec^.Left  := rec^.Left - (rec^.Right - wrk.Right);
    rec^.Right := wrk.Right;
  end;
  if rec^.Top < wrk.Top then
  begin
    
rec^.Bottom := rec^.Bottom - (rec^.Top - wrk.Top);
    rec^.Top    := wrk.Top;
  end
  else if 
rec^.Bottom > wrk.Bottom then
  begin
    
rec^.Top    := rec^.Top - (rec^.Bottom - wrk.Bottom);
    rec^.Bottom := wrk.Bottom;
  end;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners