Autor Beitrag
Thunder
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 145

WinXP
D6 Pers
BeitragVerfasst: Do 31.10.02 18:12 
Hallo,

Ich hab ne transparente Form mit nem TImage un nem Label. Als Style bsNone. Also ohne Rand und so..
Dadurch kann ich das kompilierte Fenster nicht mehr verschieben.

Jetz möchte ich das machen, das man wenn man in das Image bzw. das Fenster klickt, man das Fenster mit dem Cursor ziehen kann.

Bitte helft mir,
Danke im Voraus
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Do 31.10.02 18:18 
das soll also ein EsayMove wie bei Winamp werden ??

Dann schau mal hier: www.delphi-treff.de/...ine/index.php4?id=17

_________________
In the beginning was the word.
And the word was content-type: text/plain.
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 31.10.02 19:16 
das habe ich auch mal gemacht.
Ich hab's so gelöst:
Man setzt im OnMouseDown-Event eine Point-Variable, die die aktuelle Position relativ zum Fenster festlegt. Also die X und Y-Variablen aus dem Event nehmen. Diese Variable muss natürlich global sein ;-)
Dann macht man im OnMouseMove einfach die Position des Fensters (Top- und Left-Properties, Integer) als obsolute Position der Maus (auf dem ganzen Desktop) minus das, was im OnClick gespeichert wurde.

Wenn also ClickedPos deine Point-Variable ist sieht's so aus:
ausblenden Quelltext
1:
2:
Form1.Left := Mouse.X - ClickedPos.X;
Form1.Top := Mouse.Y - ClickedPos.Y;


Sinnvoll ist natürlich, im Onclick eine Boolean-Variable zu setzen, und diese dann im OnMouseMove-Event abzufragen, damit man auch nur verschiebt, wenn die Maus wirklich gedrückt ist. Diese Variable ist normalerweise False, wird beim OnMouseDown auf True gesetzt und beim OnMouseUp wieder auf False. In obiges Beispiel kommt dann einfach nur
ausblenden Quelltext
1:
2:
3:
if Variable then begin
...
end;


So eifnach kann man eine Form ohne Rand bewegen. Wenn man dann noch den Cursor der Form auf diese 4 Pfeile verändert, weiß auch der Anwender sofort, daß man da was bewegen kann.

Tschüß
Thomas

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Popov
Gast
Erhaltene Danke: 1



BeitragVerfasst: Do 31.10.02 20:01 
So gehts (bzw. geht auch ;))

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if not (Button = mbLeft) then Exit;
  ReleaseCapture;
  Perform(WM_SysCommand, $F012, 0);
end;


ist eigentlich das gleiche wie

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if not (Button = mbLeft) then Exit;
  ReleaseCapture;
  SendMessage(Self.Handle, WM_SysCommand, $F012, 0);
end;


Durch die Abfrage reagiert das nur auf die linke Maustaste.
Thunder Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 145

WinXP
D6 Pers
BeitragVerfasst: Do 31.10.02 20:09 
Titel: Danke
Hi,

das probier ich aus! Bei der ersten Methode von WinAmp funzt nämlich mein PopupMenu nicht mehr!
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 31.10.02 20:25 
was? bei meiner? das ist richtig, wenn du das PopUp-Menü durch einen rechtsklick öffnest. Sonst musst du abfragen, ob rechts oder links geklickt wurde.

@popov: ICh finde meinen Code schöner, weil ich deinen nicht verstehe. Meiner ist irgendwie logischer und verdeutlicht die Funktionsweise. Bei dir ist mir zuviel API drin :mrgreen:

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
Thunder Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 145

WinXP
D6 Pers
BeitragVerfasst: So 03.11.02 12:56 
Titel: ??? Code ???
Is das net scheissegal wie der Code aussieht??!!
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: So 03.11.02 13:05 
doch.
Aber meiner sieht trotzdem schöner aus...
Hat's denn geklappt?

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert