[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 288
  • Last Modified:

custom "drag bar"

I have an application where the it doesnt have the top bar that you use for draging the application the application has a image across the whole width of it. Now Im trying to make it to where the top 0-10 pixels are used for draging any ideas how to do that?

Tom
0
T0masz
Asked:
T0masz
1 Solution
 
wavgetCommented:
Put a panel at the top of the form where you want the user to be able to drag the form. Then add the follwoing code:

procedure TForm1.Panel1MouseDown(Sender: TObject; Button:
TMouseButton; Shift: TShiftState; X, Y: Integer);
const SC_DRAGMOVE = $F012;
begin
  if Button = mbLeft then
  begin
    ReleaseCapture;
    Perform(WM_SYSCOMMAND, SC_DRAGMOVE, 0);
  end;
end;

Basically, all the method does is send a WM_SYSCOMMAND message to the form with the SC_DRAGMOVE constant to perform a drag move.
0
 
Slick812Commented:
hello T0masz, I think that  wavget  code will just move the panel? ? I have used code like this for and Image covered form, you will need to get the Form's OnMouseDown  event -


procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var
hSysMenu: THandle;
begin
if Button = mbLeft then
if PtInRect(Rect(4,3,22,21), Point(X,Y)) then
  begin
  // this will show a Popup menu like the system Icon menu
  PopupMenu1.Popup(Left+4, Top+27);
  end else
  // you can define your Drag Rectangle to suit your form and Image and drag area
  // maybe something like
  if PtInRect(Rect(23,3{border},Width-6, 18), Point(X,Y)) then
    begin
    ReleaseCapture;
    Form1.perform(WM_SysCommand, $F012, 0);
    end;
end;

 - - - - - - - - - - - - - - -  - - - - - - - - -

ask questions if you need more
0
 
Lee_NoverCommented:
how about simulating a drag on the title ..

OnMouseDown:
ReleaseCapture;
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
0
 
EddieShipmanCommented:
Lee_Nover has the correct answer!!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now