- This topic has 4 replies, 2 voices, and was last updated 15 years ago by Support.
-
AuthorPosts
-
September 8, 2009 at 4:40 pm #33236mconeParticipant
I discovered the TacFloatPanel in the Extras package and am very happy that you created it. I will use it to simulate a custom MDI interface that overcomes the bugs in standard MDI and add some special features that I need.
This component takes over the MouseDown event in the WndPro procedure. However, I need to know when the FloatPanel is being dragged, so I added a custom event MouseIsDown just after the start of WM_BUTTONDOWN and added the property and private variable to the class.
You can probably make this cleaner and more powerful. So I request/suggest that you include this kind of functionality in this source in the future.
Thanks –
MikeModified class:
CODETacFloatPanel = class(TsPanel)
private
FIsFloat: boolean;
FMouseBorderWidth: TacBordersSizes;
FOnMouseIsDown: TNotifyEvent; //Added
protected
function HTProcess(var Message : TWMNCHitTest) : integer;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure WndProc (var Message: TMessage); override;
published
property IsFloat : boolean read FIsFloat write FIsFloat default True;
property MouseBorderWidth : TacBordersSizes read FMouseBorderWidth write FMouseBorderWidth;
property OnMouseIsDown: TNotifyEvent read FOnMouseIsDown write FOnMouseIsDown; //Added
end;Modified procedure:
CODEprocedure TacFloatPanel.WndProc(var Message: TMessage);
begin
if not (csDesigning in ComponentState) then case Message.Msg of
WM_NCHITTEST : if FMouseBorderWidth.Left + FMouseBorderWidth.Top + FMouseBorderWidth.Right + FMouseBorderWidth.Bottom > 0 then begin
Message.Result := HTProcess(TWMNCHitTest(Message));
Exit;
end;
WM_LBUTTONDOWN : if IsFloat then
begin
if Assigned(FOnMouseIsDown) then FOnMouseIsDown(Self); //Added
Message.Result := 0;
ReleaseCapture;
Perform(WM_SYSCOMMAND, $F012, 0);
Exit;
end;
end;
inherited;
end;September 8, 2009 at 4:46 pm #40420mconeParticipantI just realized I posted this to the wrong forum. It should be in “suggestions.” My apologies.
MikeSeptember 14, 2009 at 2:22 pm #40469SupportKeymasterHello Mike
Thank you for suggestion, I'll be thinking how to implement it soon.
September 14, 2009 at 3:20 pm #40484mconeParticipantThanks Serge –
I discovered that I needed a mouse up event to make this work. Well, the call to SC_DragMove for WM_BUTTONDOWN causes the regular MouseUp event to never be triggered. After scouring the net for this issue, I found that it is a very common problem. This is how others have solved it.
I added a MouseIsUp event with a new object private FWasDragging boolean value. Whenever the panel floats, then I set the FWasDragging to TRUE. Then, when the left button comes up, the logic drops to the section below where we test the FWasDragging value for TRUE, then send the MouseIsUp event. It works every time.
You can probably improve on it by using the standard MouseUp and MouseDown events. However, I wanted get to a solution quickly – and this was the quickest way for me.
-Mike
In the class definition add:
CODE.
FOnMouseIsUp: TNotifyEvent;
.
.
property OnDragMouseIsUp: TNotifyEvent read FOnMouseIsUp write FOnMouseIsUp;In the constructor add:
CODEFWasDragging := false;At the bottom of the WndProc procedure add:
CODE.
.
.
WM_LBUTTONDOWN : if IsFloat then
begin
if Assigned(FOnMouseIsDown) then FOnMouseIsDown(Self);
Message.Result := 0;
ReleaseCapture;
Perform(WM_SYSCOMMAND, $F012, 0); //SC_DragMove
FWasDragging := true;
Exit;
end;
end;if FWasDragging then
begin
FWasDragging := false;
if Assigned(FOnMouseIsUp) then FOnMouseIsUp(Self);
end;
.
.
.November 18, 2009 at 6:40 am #41118SupportKeymasterHello
ACExtra package was updated today :
http://www.alphaskins.com/sfiles/acextra.zip
In the FloatPanel added FWasDragging:boolean property (True when panel is in dragging). Also added OnMove event. -
AuthorPosts
- You must be logged in to reply to this topic.