Autor Beitrag
stifflersmom
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: Di 19.07.05 14:27 
Hallo,

ich bin gerade dabei mir einen Formulardesigner zu bauen,
der an sich so weit (wenn auch noch ziemlich rudimentär)
ganz gut funktioniert.
Jetzt ist mein aktuelles Problem, dass ich es dem Benutzer
wie in der Delphi IDE einfacher machen will, Steuerelemente auf
einem Formular zu Bewegen, in dem ich Sie an einem Raster
ausrichte.
Irgendwie sind meine Versuche über Form.MouseMove und dann per
SetCursorPos... nicht von befriedigendem Erfolg gekrönt.
Vielleicht verfolge ich da ja auch einen falschen Ansatz.
Kennt irgendjemand einen anderen Weg bzw. kann mir eine Quelle
nennen, die mir evtl. helfen würde?
Zeitgleich wedre ich hier im Forum mal weiter nach MouseHooks forschen.

Moin
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Di 19.07.05 14:29 
ich würde das so wie in Delphi machen: nicht die Maus sondern nur das Steuerelement wird am Raster ausgerichtet. Da kommst du doch völlig ohne SetCursorPos aus!
stifflersmom Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: Di 19.07.05 14:33 
Interessanter Ansatz,
hast Du mehr Info's dazu?
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Di 19.07.05 14:35 
Jepp, habe mal kurn ein code geschrieben:

ausblenden 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:
var xx,yy: Integer;
procedure TForm1.Shape1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if shift = [ssLeft] then
  begin
    shape1.Left := Round((shape1.left+(x-xx))/10)*10;
    shape1.Top := Round((shape1.Top+(y-yy))/10)*10;
  end;

end;

procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
xx := x;
yy := y;
end;

procedure TForm1.FormPaint(Sender: TObject);
var x,y: Integer;
begin
for x := 1 to (width div 10) do
  for y := 1 to (height div 10) do
      canvas.Pixels[x*10,y*10] := clGray;
end;
stifflersmom Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 194

XP /XP PRO/ SuSE div.
D1 - D7, BDS 2006
BeitragVerfasst: Di 19.07.05 14:42 
Tilman, klasse!

Super Ansatz und simpel umzusetzen.
Ich danke Dir!

Moin
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Di 19.07.05 14:44 
Danke für die Blumen. Ich habe das obenstehende Listing gerade nochmal um ein Raster ergänzt.