forms - Delphi: Make the window draggable from a component -


i have custom form (custom shape , transparency) no borders (borderstyle: bsnone). has background image, normal timage component. want form draggable timage. possible? i'm using lazarus 1.2.6 (fpc ver.: 2.6.4).

this custom form looks on empty desktop: image.

here cross-platform solution:

type tform1 = class(tform)     image1: timage;      procedure image1mousedown(sender: tobject; button: tmousebutton;       shift: tshiftstate; x, y: integer);     procedure image1mousemove(sender: tobject; shift: tshiftstate; x,       y: integer);     procedure image1mouseup(sender: tobject; button: tmousebutton;       shift: tshiftstate; x, y: integer);  var px, py: integer;      mouseisdown: boolean;  procedure tform1.image1mousedown(sender: tobject; button: tmousebutton;   shift: tshiftstate; x, y: integer); begin   if button = mbleft begin     mouseisdown := true;     px := x;     py := y;   end; end;   procedure tform1.image1mousemove(sender: tobject; shift: tshiftstate; x,   y: integer); begin   if mouseisdown begin     setbounds(form1.left + (x - px), form1.top + (y - py), form1.width, form1.height);   end; end;  procedure tform1.image1mouseup(sender: tobject; button: tmousebutton;   shift: tshiftstate; x, y: integer); begin   mouseisdown:=false; end;  

dragging timage cause form dragged.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -