Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Easymove (https://www.delphipraxis.net/4105-easymove.html)

synex 15. Apr 2003 14:07


Easymove
 
Ich habe folgendes Problem:
Meine Form2 soll sich rumschieben lassen, egal wo man hinklickt auf der Form (Wie bei Winamp). Ich habe dazu ein folgenden code verwendet:

Delphi-Quellcode:

private
    { Private declarations }
  procedure WMNCHitTest(var M: TWMNCHitTest); message wm_NCHitTest;

//blablabla

procedure TForm2.WMNCHitTest (var M: TWMNCHitTest);
begin
  inherited;
  if M.Result = htClient then
    M.Result := htCaption;
end;
Jetzt funktioniert aber mein SpeedButton nicht mehr, wenn ich auf ihn klicke bewege ich auch nur die Form.

Wie kann ich den Button wieder dazu bringen seine OnClock-Procedure auszuführen?


Mein 2. Problem:

ich habe meinem Programm jetzt einen HotKey zugewiesen (siehe hier )
Wie kann ich durch ein HotKey-Editfeld den Hotkey ändern?

danke schonmal,
der synex

City Light 15. Apr 2003 15:42

Hallo synex
ich habs getestet und dieser funktioniert!
Delphi-Quellcode:
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
                               Shift: TShiftState; X, Y: Integer);
begin
   ReleaseCapture;
   SendMessage(Form1.Handle, wm_SysCommand,$f012,0);
end;
zu 2. keine Ahnung Sorry

synex 15. Apr 2003 16:17

ok danke aber was ändert das?

Wie muss ich das verwenden?

City Light 15. Apr 2003 16:38

Schreib den Code einfach in MouseDown deiner Form rein
Dann funkt der Speed Button wieder!

synex 15. Apr 2003 16:49

hmm sorry aber irgendwie klappt dann der Knopf bei mir noch immer nicht :(

danke trotzdem

APP 15. Apr 2003 17:09

Hallo,

ich glaube Du mußt es umgekehrt machen:

Zitat:

But, I have components on a form!?
In most cases we'll have some components on a form. Let's say, for example, that one Panel object is on a form. If Align property of a panel is set to alClient, the Panel fills the entire client area so that it is impossible to select the parent form by clicking on it. The code above will not work! Why? The code above will not work because the mouse is always moving over the Panel component not the form.

To move our form by dragging a panel on the form we have to add few lines of code in the OnMouseDown event procedure for the Panel component:

procedure TForm1.Panel1MouseDown
(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
ReleaseCapture;
SendMessage(Form1.Handle, WM_SYSCOMMAND, 61458, 0);
end;

Note: this code will not work with non-window controls such as TLabel components
Du legst ein Panel auf Deine Form mit Align at Client, dann platzierst Du deine Controls (Buttons,...) die Du bedienen möchtest darauf.

Dann kommt:
Delphi-Quellcode:
unit bUnit1;

interface

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

type
  TForm1 = class(TForm)
    Panel1: TPanel;
    procedure Button1Click(Sender: TObject);
    procedure Panel1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
  procedure WMNCHitTest(var Msg: TWMNCHitTest);
  message wm_NCHitTest;


    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.WMNCHitTest(var Msg: TWMNCHitTest);
begin
  inherited;
  if Msg.Result = htClient then
    Msg.Result := htCaption;
end;

procedure TForm1.Panel1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  ReleaseCapture;
  SendMessage(Form1.Handle, WM_SYSCOMMAND, 61458, 0);
end;
und nun kannst Du die Form (über das Panel) verschieben und trotzdem die Buttons drücken.

(Frei nach Another Way to Drag a Window auf About.com)

[EDIT] :idea: Habe gerade bemerkt, dass es auch ohne Panel funkt, so wie es City Light beschrieben hat!! :idea: [/EDIT]

synex 15. Apr 2003 17:56

jo thx jetzt tuts.
DANKE!

Mr.Dollar2k3 13. Dez 2003 15:19

Re: Easymove
 
hi
ich hab versucht es nach zu machen aber bei mir funktioniert es nicht ich versuch aber mit einen bild das mann das drauf klickt und es bewegen kann


Alle Zeitangaben in WEZ +1. Es ist jetzt 00:34 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz