Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-07-1998, 01:13 AM
N/A
Guest
 
Posts: n/a
Default Dragging and Dropping

I want to create a deplhi application that

is capable of making the user able to drag

and drop graphical objects like a line or

something! I want to be able to create an

OnDblClick event for this line after it is

dragged in my form! How can I do so?
Reply With Quote
  #2  
Old 08-08-1998, 06:35 AM
N/A
Guest
 
Posts: n/a
Default RE: Dragging and Dropping

// Maybe this is what you want. If not email me.

// Reginaldo Ap. Rigo

// virtual@alphanet.com.br





// Hope it helps.

unit DragnDrop;



interface



uses

*Windows, Messages, SysUtils, Classes,

*Graphics, Controls, Forms, Dialogs,

*extctrls, StdCtrls;



type

*TForm1 = class(TForm)

* *procedure FormCreate(Sender: TObject);

* *procedure ImageClick(Sender: TObject);

*private

* *{ Private declarations }

*public

* *ImageNum : Integer;

* *Image : TImage;

* *//>>>

* *// declare our DROPFILES message handler

* *procedure AcceptFiles( var msg : TMessage );

* * * * * * *message WM_DROPFILES;

* *//<<<

*end;



var

*Form1: TForm1;





implementation

uses

*//

*// this unit contains certain

*// functions that we'll be using

*//

*//>>>

*ShellAPI;

*//<<<

{$R *.DFM}

//>>>



procedure TForm1.AcceptFiles( var msg : TMessage );

const

*cnMaxFileNameLen = 255;

var

*i,

*nCount * * : integer;

*acFileName : array [ 0 .. cnMaxFileNameLen ] of char;

begin

*// find out how many files we're accepting

*nCount := DragQueryFile( msg.WParam,

* * * * * * * * * * * * * $FFFFFFFF,

* * * * * * * * * * * * * acFileName,

* * * * * * * * * * * * * cnMaxFileNameLen );

*// query Windows one at a time for the file name

*for i := 0 to nCount-1 do

*begin

* *DragQueryFile( msg.WParam, i,

* * * * * * * * * acFileName, cnMaxFileNameLen );

* *// do our thing with the acFileName

* *if *StrUpper(PChar(ExtractFileExt( acFileName ))) ='.BMP' then

* *// We handling just .bmp files for now.

* *begin

* * * Image := TImage.Create( Self );

* * * with Image do

* * * begin

* * * * AutoSize := true;

* * * * Picture.LoadFromFile( acFileName );

* * * * Tag := ImageNum;

* * * * OnClick := ImageClick;

* * * * Parent := Form1;

* * * * Left := ImageNum * 10;

* * * * Top *:= ImageNum * 20;

* * * end;

* * * Inc( ImageNum );

* *end;

*end;

*// let Windows know that you're done

*DragFinish( msg.WParam );

end;

//<<<

procedure TForm1.FormCreate(Sender: TObject);

begin

*// tell Windows that you're

*// accepting drag and drop files

*//>>>

*DragAcceptFiles( Handle, True );

*//<<
*ImageNum := 1;

end;



procedure TForm1.ImageClick(Sender: TObject);

begin

* *Form1.Caption := 'There was a click on the '+ IntToStr(( Sender as TImage ).Tag )+ ' image!';

end;



end.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 06:52 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.