Autor Beitrag
Xabitire
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 114

Win Xp, Win Vista
D6 PE, D7 PE
BeitragVerfasst: So 25.02.07 13:40 
Hi allerseits,

also wenn ich bei meinem Form den borderstyle auf clnone stelle, hab ich ja nur noch die Benutzeroberlfläche!

Jetzt hab ich allerdings keine Möglichkeit mehr mein Form zu verschieben und daher wollte ich mal fragen, ob es die Möglichkeit gibt einen Bereich zu bestimmen, wo ich das Form verschieben kann und wie das funktioniert!

thx schonmal!
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: So 25.02.07 15:22 
So in der Art

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:
TMainForm = class(TForm)
...
    procedure WMNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;


procedure TMainForm.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  DefaultHandler(Msg);
  with Msg do
    if PtInRect(Rect(0,0,4,4),
                Point(XPos-Left,YPos-Top)) then
      RESULT := htTopLeft
    else if PtInRect(Rect(Width-4,0,Width,4),
                     Point(XPos-Left,YPos-Top)) then
      RESULT := htTopRight
    else if PtInRect(Rect(0,Height-4,4,Height),
                     Point(XPos-Left,YPos-Top)) then
      RESULT := htBottomLeft
    else if PtInRect(Rect(Width-4,Height-4,Width,Height),
                     Point(XPos-Left,YPos-Top)) then
      RESULT := htBottomRight
    else if PtInRect(Rect(0,0,Width,4),
                     Point(XPos-Left,YPos-Top))then
      RESULT := htTop
    else if PtInRect(Rect(0,0,4,Height),
                     Point(XPos-Left,YPos-Top)) then
      RESULT := htLeft
    else if PtInRect(Rect(0,Height-4,Width,Height),
                     Point(XPos-Left,YPos-Top)) then
      RESULT := htBottom
    else if PtInRect(Rect(Width-4,0,Width,Height),
                     Point(XPos-Left,YPos-Top)) then
      RESULT := htRight
    else
      inherited;
end;


MfG
elundril
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3747
Erhaltene Danke: 123

Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
BeitragVerfasst: So 25.02.07 15:25 
oder du könntest z.b: ein Label machen und das auf align alTop setzen und dann im MouseUp ne Boolean variable auf true setzen und im MouseDown auf False.
Im MouseMove überprüfst du dann ob die variable gesetzt ist. wenn ja dann ändertst du die Left und Top koordinate nach der X und Y Koordinate der Maus.

lg el

_________________
This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
Dunkel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 682

Mac OS X Snow Leopard
Xcode 3.1
BeitragVerfasst: So 25.02.07 18:16 
Oder einfach ein TShape (oder sonst was) auf die Form legen.

Im Private-Abschnitt der TForm
ausblenden Delphi-Quelltext
1:
procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;					

einfügen, welche dann in etwa so
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.WMNCHitTest (var M: TWMNCHitTest);
var
 MousePos: TPoint;
begin
 inherited;
 MousePos.X:= M.XPos;
 MousePos.Y:= M.YPos;
 if PtInRect(Rect(Left+Shape1.Left, Top+Shape1.Top, Left+Shape1.Width, Top+Shape1.Height), MousePos) then
   if M.Result = htClient then
     M.Result := htCaption;
end;

aussehen könnte. (Vorsicht, mehr oder weniger ungetestet!)

Klickt man jetzt auf das Shape und bewegt die Mouse, bewegt sich auch die Form analog.
Xabitire Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 114

Win Xp, Win Vista
D6 PE, D7 PE
BeitragVerfasst: So 25.02.07 19:25 
Danke!

Habs jetzt hingekriegt!

Hab allerdings statt einem Tshape ein Timage benutzt, beim Tshape hats an manchen Stellen einfach nicht funktioniert!
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: So 25.02.07 19:33 
Der Vollständigkeit halber möchte ich noch diese sehr schöne Variante anbringen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
 // Ins OnMouseDown einer beliebigen Komponente:
if button = mbLeft then
  begin
    ReleaseCapture;
    PerForm(WM_SysCommand, $F012 , 0);
  end;

Wenn man die 12 durch andere Werte ersetzt, kann man z.B. eine Größenveränderung in die eine oder andere Richtung (auch diagonal) bewirken.

_________________
We are, we were and will not be.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: So 25.02.07 20:16 
Noch zum WMNCHitTest:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TStartScreen.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  inherited;

  if (Msg.Result = htClient) then
    Msg.Result := htCaption;
end;

Das ist kürzer.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Coder
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1383
Erhaltene Danke: 1

WinXP
D2005 PE
BeitragVerfasst: So 25.02.07 20:23 
In meiner Version ist noch das Feature eingebaut die Form in der Größe zu ändern.
Ok, das war ja nicht gefragt. :roll:

MfG