Autor Beitrag
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 29.05.05 09:47 
Tach,
ich möchte ermöglichen das man einen Button (Button1) auf den Formular (Form1) hin und her schieben kann. Wie beim Delphi-FormDesigner. Drag & Drop eben. Bisher weiß ich nur das ich beim Button und beim Form die Eigenschaft DragMode auf Auto stellen muss. Außerdem muss beim Fromular im OnDragOver "Accept:=TRUE;" stehen.

Ich dachte mir ich schreib ins OnDragDrop beim Button folgendes:

ausblenden Delphi-Quelltext
1:
button1.Left:=Screen.Cursor;					


Funktioniert aber nicht. Der Compiler meldet keine Fehler. Wenn ich den Button dann auf den Formular hin und her ziehe kommt zwar der Drag`n Drop Cursor aber der Button wird nicht verschoben.

Die Delphi Hilfe und Forensuche gab mir keine weiteren Infos. Wie kann ich mein Vorhaben realisieren.

Schonmal Danke,
Andy
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 29.05.05 09:53 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
const
  SC_DRAGMOVE = $F012;
begin
  ReleaseCapture;
  TWinControl(Button1).Perform(WM_SYSCOMMAND, SC_DRAGMOVE, 0);
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 29.05.05 11:27 
Ähm... und wo kommt das hin?
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 29.05.05 13:39 
ich wusste doch dass was fehlt...
OnMouseDown des Buttons.
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 29.05.05 17:25 
Also erstmal Danke. Ich hab jetzt den Code eingefügt aber der Button lässt sich immernoch nicht verschieben.

Was muss ich noch tun?

Bye,
Andy
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 29.05.05 18:02 
ausblenden volle Höhe Delphi-Quelltext
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

const
  SC_DRAGMOVE = $F012;

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture;
  TWinControl(Button1).Perform(WM_SYSCOMMAND, SC_DRAGMOVE, 0);
end;

end.

Funktioniert unter D3 einwandfrei, unter D2005 hab ich n Programm das unmittelbar drauf aufbaut und auch funzt.
Bei Speedbuttons gehts allerdings net, hab auch ne ganze Zeit gebraucht um das rauszufinden.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: So 29.05.05 18:33 
blöd ist nur, dass man den button nicht mehr anklicken kann :P

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: So 29.05.05 20:21 
jetzt funktioniert alles. Vielen Dank
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 29.05.05 20:43 
Woram lag's denn?
Den butrtonklick musst'de dann halt auhc auf onmousedown amchen, oder ne checkbox mit einfügen, mit der de einstellst ob du verschieben oder clicken willst.