Comment faire pour recuperer le chemin d'un ficher poser par la methode du glisser sur une fiche ??
Comment faire pour recuperer le chemin d'un ficher poser par la methode du glisser sur une fiche ??
Voici un petit exemple touvé sur ce site
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls; type TForm1 = class(TForm) Button1: TButton; Panel1: TPanel; procedure FormDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); procedure FormCreate(Sender: TObject); private { Déclarations privées } OriginalFormWindowProc : TWndMethod; public { Déclarations publiques } procedure FormWindowProc(var Msg : TMessage); procedure FormFileDrop(var Msg: TWMDROPFILES) ; end; var Form1: TForm1; implementation Uses ShellApi; {$R *.dfm} procedure TForm1.FormWindowProc(var Msg : TMessage); var Fn : Array [0..255] of Char; begin if Msg.Msg = WM_DROPFILES then FormFileDrop(TWMDROPFILES(Msg)) else OriginalFormWindowProc(Msg); end; procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin Accept := True; end; procedure TForm1.FormFileDrop(var Msg: TWMDROPFILES) ; var numFiles : longInt; buffer : array[0..MAX_PATH] of char; begin numFiles := DragQueryFile(Msg.Drop, $FFFFFFFF, nil, 0) ; if numFiles > 1 then begin ShowMessage('You can drop only one image file at a time!') ; end else begin DragQueryFile(Msg.Drop, 0, @buffer, sizeof(buffer)) ; Form1.Caption := Buffer ; end; end; procedure TForm1.FormCreate(Sender: TObject); begin OriginalFormWindowProc := Form1.WindowProc; Form1.WindowProc := FormWindowProc; DragAcceptFiles(Form1.Handle,true) ; end; end.
La réponse est même dans la FAQ de developpez.com![]()
http://www.developpez.com/delphi/faq...estionmessages
en gros :
1) Dire a la création de la form qu'on accepte le d&d avec DragAcceptFiles
2) Créer une procedure qui sera lancée lors du message WM_DROPFILES
3) dans le corps, compter le nombre de fichier dropés et enumérer
Vous avez un bloqueur de publicités installé.
Le Club Developpez.com n'affiche que des publicités IT, discrètes et non intrusives.
Afin que nous puissions continuer à vous fournir gratuitement du contenu de qualité, merci de nous soutenir en désactivant votre bloqueur de publicités sur Developpez.com.
Partager