Home > Back-end >  How Delphi Header to form drag (or, how to take over, listening to the Header of the Header of drag
How Delphi Header to form drag (or, how to take over, listening to the Header of the Header of drag

Time:09-16

Recently, in order to achieve a system, is through the form after the Panel, drag the meter automatic generation control, but always can't find the header drag events?
I use the Dev CxGrid controls,

As shown in figure, I want to put the red box, drag and drop the meter

And the header in the CxGrid can only drag the Group (Group), or change in a sequence of mouse to move to other places will become not drag,
I try and Drag in the cxGridDBTableView about events, found only on, only to form Drag events recorded, Drag the table header, or invalid,


Think of some way to before a column, the result found column without access to relevant Drag events ,
,

Have 4, 5 hours and had to go to the source code to debug
'Found, click on the header is first performed TCxControl. The MouseDown event, begin the Drag action in this event also really

In this event and get to the class of Drag

As a result, to found the back, TcxGridColumnHeaderMovingObject this class,,, then I'm dizzy,,, can't find the clue,
 procedure TcxGridColumnHeaderMovingObject. CalculateDestParams (AHitTest: TcxCustomGridHitTest; 
The out AContainerKind: TcxGridItemContainerKind; The out AZone: TcxGridItemContainerZone);
The begin
Inherited;
If AContainerKind=ckNone then
The begin
AZone:=ViewInfo. GroupByBoxViewInfo. GetZone (AHitTest. Pos);
If AZone=nil then
The begin
AZone:=ViewInfo. HeaderViewInfo. GetZone (AHitTest. Pos);
If AZone & lt;> Nil then
AContainerKind:=ckHeader;
End
The else
AContainerKind:=ckGroupByBox;
end;
end;


The function TcxCustomGridController. StartDragAndDrop (const P: TPoint) : Boolean;
Var
AHitTest: TcxCustomGridHitTest;
The begin
AHitTest:=ViewInfo GetHitTest (P);
Result:=CanHandleHitTest (AHitTest);
If the Result then
The begin
Result:=AHitTest DragAndDropObjectClass & lt;> Nil;
If the Result then
The begin
CancelHint;
DragAndDropObjectClass:=AHitTest. DragAndDropObjectClass;
DragAndDropObject. Init (P, AHitTest);
end;
end;
end;

Procedure TcxControl. MouseDown (Button: TMouseButton; Shift: TShiftState; X, Y: Integer);


Procedure TcxControl. CMMouseEnter (var Message: TMessage);
The begin
Inherited;
If the Message. The lParam=0 then
MouseEnter (Self)
The else
MouseEnter (TControl (Message. LParam));
end;


Procedure TcxDragAndDropObject. DragAndDrop (const P: TPoint; Var Accepted: Boolean);
The begin
Dirty:=False;
Screen. The Cursor:=GetDragAndDropCursor (Accepted);
end;


Procedure TcxControl. DoMouseEnter (AControl: TControl);
The begin
If ((AControl=Self) or (AControl=nil)) and (FMouseEnterCounter=0) then
The begin
Inc (FMouseEnterCounter);
DxCallNotify (FOnMouseEnter, Self);
end;
end;

This is me out I think is the key code,,
I also try to through the header when the drag and drop, the cursor changes, to find a key code, the result is no harvest,
And, up to now I didn't understand first, who will go to trigger TcxControl. MouseDown event? The Column is not TcxControl class, not a TableView,
Only CxGrid1 ancestor class is TCxControl, but why am I in the MouseDown event CxGrid1, unable to capture?


After this the way to give up, I want to by intercepting Windows mouse messages to achieve a goal, messages can be intercepted, but has been unable to determine, whether the Column Column is in the condition of dragged,

Want to consult everybody a great god, and what method did not

CodePudding user response:

HotTrack properties!
  • Related