Board index » delphi » How to create drag images like TreeView/TreeList ?

How to create drag images like TreeView/TreeList ?

Hi !

I'm creating a TreeView clone in Delphi code, without using the standard Windows TvreeView control.
Sounds stupid, maybe, but I have my reasons. Now I could use tips on how to do this:

a) When you drag items in a TreeView or ListView, you get a dragimage that is like a shadowed
representation of the dragged item's icons and text. Any tips on how to do this ?
b) When you scroll (List-/TreeView) or expand/collapse an item (TreeView), the motion is "animated
". Obviously there is a number of painting operations done. Anyone know how to do this ?
c) I still haven't managed to create a dotted pen. Tips would be appriciated.

Thanks in advance !
--

Bjoerge

 

Re:How to create drag images like TreeView/TreeList ?


Hi Bj?rge,

Quote
"Bj?rge S?ther" wrote:
> c) I still haven't managed to create a dotted pen. Tips would be appriciated.

You could use LineDDA. However, it's slow.
Here is some example code:
----8<--------8<--------8<--------8<--------8<----

procedure LineProc(X, Y: Integer; P: Pointer); stdcall;
{$J+}
const
  DropPixel: WordBool = False;
var
  W, k: Integer;
begin
  with TCanvas(P) do
  begin
    W := Pen.Width;
    if not DropPixel then
    begin
      k := W div 2;
      if k = 0
        then Pixels[X, Y] := Pen.Color
        else Ellipse(X-k, Y-k, X+k, Y+k);
    end;
  end;
  Inc(Word(DropPixel));
  if Word(DropPixel) >= 2*W then DropPixel := False;
end;

procedure TForm1.PaintBox1Paint(Sender: TObject);
var
  i: Integer;
begin
  Randomize;
  Canvas.Pen.Color := clLime;
  Canvas.Pen.Width := 3;

  Canvas.Brush.Color := Canvas.Pen.Color;
  for i := 0 to 9 do
    LineDDA(Random(Width), Random(Height), Random(Width),
Random(Height), @LineProc, Integer(Canvas));
end;
----8<--------8<--------8<--------8<--------8<----

Greetings, Robert
--
Robert Ro?mair
http://home.t-online.de/home/Robert.Rossmair/
Programming environment: Delphi 3.0, WinNT 4.0 SP5

Re:How to create drag images like TreeView/TreeList ?


<<Robert Rossmair skrev i meldingen <37BED054.D45BA...@t-online.de>...
Hi Bj?rge,

Quote
"Bj?rge S?ther" wrote:
> c) I still haven't managed to create a dotted pen. Tips would be appriciated.

You could use LineDDA. However, it's slow.
Here is some example code:...>>

Yes, but you gave me an idea: Create one BMP with size:=1 x Screen.Height and one with
size:=Screen.width x 1, and use BitBlt in a customized LineDraw procedure. I only intend to paint
vertical or horizontal lines for now.

Thanks for the tip !
--

Bjoerge

Other Threads