Hi,
kurze Erklärung:
Habe eine Form1, auf der befinden sich 2 GroubBoxen und in diesen jeweils eine ScrollBox.
Nun soll aus dem Windows explore oder Winkommander per dragdrop eine Datei in die ScrollBox abgelegt werden.
Dazu wird zur Laufzeit eine 'gaugecomponente' erstellt die den Namen der Datei erhält.
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:
| type TForm1 = class(TForm) ..... .....
protected procedure WMDROPFILES(var Msg: TMessage); message WM_DROPFILES;
.....
end;
var ...
const DF_NUMBEROFFILES = $FFFFFFFF;
implementation
{$R *.dfm}
...... procedure TForm1.FormCreate(Sender: TObject); begin ..... DragAcceptFiles(ScrollBox1.Handle, true); DragAcceptFiles(scrollbox2.Handle, true); DragAcceptFiles(Form1.Handle, true);
end;
procedure TForm1.WMDROPFILES(var Msg: TMessage); var i, anzahl, size: Integer; Dateiname: PChar; point: tpoint; begin inherited; anzahl := DragQueryFile(Msg.WParam, DF_NUMBEROFFILES, Dateiname, 255); for i := 0 to (anzahl - 1) do begin GetCursorPos(point); size := DragQueryFile(Msg.WParam, i, nil, 0) + 1; Dateiname := StrAlloc(size); DragQueryFile(Msg.WParam, i, Dateiname, size); ShowMessage(Dateiname); PlayGauge:=TGaugeCaption.create(self); with playgauge do begin Name := 'PlayGauge'+inttostr(plg); Caption := ExtractFileName(Dateiname); OnMouseDown := Form1.ScrollBox1MouseDown; PopupMenu := Form1.PopupMenu1; top := pl; if ((FindDragTarget(point, FALSE) = Form1.ScrollBox1)) then parent := Form1.ScrollBox1; if ((FindDragTarget(point, False) = Form1.ScrollBox2)) then parent := Form1.ScrollBox2; show; end; StrDispose(Dateiname); plg := plg+1; pl := pl+PlayGauge.Height+5; end; DragFinish(Msg.WParam); end; ... ... |
Leider funct das Ablegen in der jeweilige ScrollBox nicht, obwohl der Cursor mir zeigt das die Componente empfangsbereit ist.
Delphi-Quelltext
1:
| ->DragAcceptFiles(ScrollBox1.Handle, true); |
Beim Testen habe ich folgendes bemerkt:
Delphi-Quelltext
1:
| ->if ((FindDragTarget(point, FALSE)=Form1.ScrollBox1)) then |
kann nicht funktionieren weil die maus aus dem winExplorer kommt ??! habe ich festgestellt.
wenn ich aber ohne if abfrage folgendes mache:
Delphi-Quelltext
1:
| parent := Form1.ScrollBox1; |
und per dragdrop die maus auf der Form1 loslasse(nicht auf der ScollBox) wird die gaugekomponente erstellt. mh......
auch das umändern:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9:
| type TscrollBox = class (Forms.TscrollBox)
protected procedure WMDROPFILES(var Msg: TMessage); message WM_DROPFILES;
end;
procedure TscrollBox.WMDROPFILES(var Msg: TMessage); |
brachte keinen Erfolg.
Nun meine Frage(n):
Warum klappt es nicht auf der scrollbox selbst, sondern nur auf form1
wer kann mir da tipps oder links geben, was ich wo wie ändern muss mit dem ablegen??
Bitte sagt mir nicht: Hilfe, Suchen, Google 
mache ich schon seit 2 Tagen.
und vieles gefunden wie dragdrop mit memos label grids usw, waren aber keine hilfe für mich
Gruss ALF