Link to home
Start Free TrialLog in
Avatar of Freerider
FreeriderFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Moving a form without border.

Hi all,

can anyone tell me how to make a form with [BorderStyle = bsNone] moveable? I am displaying an image on the form and don't want a border.

Thanks,
Freerider.
ASKER CERTIFIED SOLUTION
Avatar of marcoszorrilla
marcoszorrilla

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marcoszorrilla
marcoszorrilla

Another way to show an image:

procedure TfrMenu.FormCreate(Sender: TObject);
begin
  bmpFondo := TBitmap.Create;
  bmpFondo.LoadFromFile( 'c:\pan\MyBmp.bmp' );
end;
procedure TfrMenu.FormDestroy(Sender: TObject);
begin
 bmpFondo.Free;
end;

procedure TfrMenu.FormPaint(Sender: TObject);
begin
   
   Canvas.Draw(163, 55, bmpFondo );
end;


Best Regards.
Marcos.
hello Freerider, you might try

procedure TForml.MouseDown(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer);
Const SC_DragMove = $F012;
begin
  if (Button = mbLeft) then
  begin
  ReleaseCapture;
  Self.perform(WM_SysCommand, SC_DragMove, 0);
  end;

end;

the SC_DragMove is issued by the system after a htCaption, WM_NCHITTEST
procedure WMNCHitTest(var Msg : TMessage); message WM_NCHITTEST;

procedure TForm1.WMNCHitTest(var Msg : TMessage);
begin
  if GetAsyncKeyState(VK_LBUTTON) < 0 then
    Msg.Result := HTCAPTION
  else
    Msg.Result := HTCLIENT;
 end;

It makes windows think you are clicking on the title bar when you are clicking in the client area.
Avatar of Freerider

ASKER

Thanks,

I'll let you know how I get on...
Hi Freerider,

put this code in either onMouseClick or onMouseDown for the form or the image or both

ReleaseCapture;
TForm(form1).perform(WM_SYSCOMMAND, $F012, 0);

Regards

Hill
Freerider:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.