Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:42:01+00:00 2026-06-17T20:42:01+00:00

Using: Delphi XE2 Update 4.1, 32-bit VCL application, Windows 8 If DragMode is set

  • 0

Using: Delphi XE2 Update 4.1, 32-bit VCL application, Windows 8

If DragMode is set to dmAutomatic the the OnStartDrag event is called; however if the DragMode is set to dmManual, the OnStartDrag event is bypassed.

Is this by design? How to ensure that OnStartDrag event is called?

EDIT: Code posted on request. The event in question is TTableDesigner.LblStartDrag which is not being executed after a call to BeginDrag (in TTableDesigner.LblOnMouseDown) .

unit uTableDesigner;

interface

uses
  System.SysUtils, System.Classes, Vcl.Controls, Graphics, JvCaptionPanel,
  StdCtrls, ExtCtrls;

type
  TMyTable = record
    TableName: String;
    TableFields: TStrings;
    TableObject: Pointer;
  end;

  PMyTable = ^TMyTable;

  TTableDesigner = class(TCustomControl)

    procedure CreateWnd; override;
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    procedure LblOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
    procedure LblDragDrop(Sender, Source: TObject; X, Y: Integer);
    procedure LblDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
    procedure LblEndDrag(Sender, Target: TObject; X, Y: Integer);
    procedure LblStartDrag(Sender: TObject; var DragObject: TDragObject);
    // procedure Paint; override;
  private
    { Private declarations }
    FTableList: TList;
    FCaptionPanelList: TList;
    FPanelSlot_Left: Integer;
    FPanelSlot_Top: Integer;
    FStartDragPnl: TJvCaptionPanel;
    FDragHoverPnl: TJvCaptionPanel;
    FEndDragPnl: TJvCaptionPanel;

    procedure HighlightPanelLabel(ALabel: TLabel);
  protected
    { Protected declarations }
  public
    { Public declarations }

    procedure AddTable(const ATableName: String; const AFields: TStrings);
    procedure DeleteTable(const ATableName: String);
    procedure DeleteAllTables;
  published
    { Published declarations }
    property Align;
    property Visible;
    property Color;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Samples', [TTableDesigner]);
end;

constructor TTableDesigner.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);

  FTableList := TList.Create;
  FCaptionPanelList := TList.Create;

  FPanelSlot_Left := 40;
  FPanelSlot_Top := 40;
end;

destructor TTableDesigner.Destroy;
begin
  DeleteAllTables;
  FTableList.Free;
  FCaptionPanelList.Free;

  inherited;
end;

procedure TTableDesigner.CreateWnd;
begin
  inherited;
end;

procedure TTableDesigner.AddTable(const ATableName: String; const AFields: TStrings);
var
  pnl: TJvCaptionPanel;
  c, h, j: Integer;
  lbl: TLabel;
  MyTable: PMyTable;
begin

  pnl := TJvCaptionPanel.Create(Self);
  pnl.Parent := Self;
  pnl.Color := clWhite;
  pnl.Caption := ATableName;
  pnl.CaptionPosition := dpTop;
  pnl.Left := FPanelSlot_Left;
  pnl.Top := FPanelSlot_Top;

  // FPanelSlot_Left := FPanelSlot_Left + pnl.Width + 40;
  // if FPanelSlot_Left > ClientWidth - 100 then
  // begin
  // FPanelSlot_Left := 40;
  //
  // j := 0;
  // for c := 0 to FTableList.Count - 1 do
  // if j < TJvCaptionPanel(TMyTable(FTableList.Items[c]^).TableObject).Height then
  // j := TJvCaptionPanel(TMyTable(FTableList.Items[c]^).TableObject).Height;
  //
  // FPanelSlot_Top := FPanelSlot_Top + j + 40;
  // end;

  h := 0;
  for c := 0 to AFields.Count - 1 do
  begin
    lbl := TLabel.Create(pnl);
    lbl.Parent := pnl;
    lbl.Align := alTop;
    lbl.Caption := AFields[c];
    lbl.Transparent := False;
    lbl.ParentColor := False;
    lbl.DragKind := dkDrag;
    lbl.OnMouseDown := LblOnMouseDown;
    lbl.OnDragDrop := LblDragDrop;
    lbl.OnDragOver := LblDragOver;
    lbl.OnEndDrag := LblEndDrag;
    lbl.OnStartDrag := LblStartDrag;
    // lbl.DragMode := dmAutomatic;

    h := h + lbl.Height + 4;
  end;
  pnl.ClientHeight := pnl.CaptionHeight + h;

  MyTable := AllocMem(SizeOf(TMyTable));
  Initialize(MyTable^);
  MyTable.TableName := ATableName;
  MyTable.TableFields := TStringList.Create;
  MyTable.TableFields.Assign(AFields);
  MyTable.TableObject := pnl;
  FTableList.Add(MyTable);

end;

procedure TTableDesigner.DeleteTable(const ATableName: String);
var
  c: Integer;
begin
  for c := 0 to FTableList.Count - 1 do
    if TMyTable(FTableList.Items[c]^).TableName = ATableName then
    begin

      TJvCaptionPanel(TMyTable(FTableList.Items[c]^).TableObject).Free;

      TMyTable(FTableList.Items[c]^).TableFields.Free;
      Finalize(TMyTable(FTableList.Items[c]^));
      FreeMem(FTableList.Items[c]);
      FTableList.Delete(c);
      Break;
    end;

end;

procedure TTableDesigner.DeleteAllTables;
var
  c: Integer;
begin
  for c := FTableList.Count - 1 downto 0 do
  begin

    TJvCaptionPanel(TMyTable(FTableList.Items[c]^).TableObject).Free;

    TMyTable(FTableList.Items[c]^).TableFields.Free;
    Finalize(TMyTable(FTableList.Items[c]^));
    FreeMem(FTableList.Items[c]);
    FTableList.Delete(c);
  end;

end;

procedure TTableDesigner.HighlightPanelLabel(ALabel: TLabel);
var
  pnl: TJvCaptionPanel;
  c: Integer;
begin
  pnl := TJvCaptionPanel(ALabel.Parent);
  for c := 0 to pnl.ControlCount - 1 do
    if pnl.Controls[c] = ALabel then
      TLabel(pnl.Controls[c]).Color := clHighlight
    else
      TLabel(pnl.Controls[c]).Color := pnl.Color;
end;

procedure TTableDesigner.LblOnMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  HighlightPanelLabel(TLabel(Sender));
  BeginDrag(False, 4);
end;

procedure TTableDesigner.LblDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  FEndDragPnl := TJvCaptionPanel(TLabel(Sender).Parent);

  FEndDragPnl.Color := clWhite;
end;

procedure TTableDesigner.LblDragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
  FDragHoverPnl := TJvCaptionPanel(TLabel(Sender).Parent);

  FDragHoverPnl.Color := clGreen;

  Accept := True;
end;

procedure TTableDesigner.LblEndDrag(Sender, Target: TObject; X, Y: Integer);
begin
  TJvCaptionPanel(TLabel(Sender).Parent).Color := clPurple;

end;

procedure TTableDesigner.LblStartDrag(Sender: TObject; var DragObject: TDragObject);
begin
  FStartDragPnl := TJvCaptionPanel(TLabel(Sender).Parent);

  FStartDragPnl.Color := clRed;
end;


// procedure TTableDesigner.Paint;
// var
// c: Integer;
// begin
// inherited;
//
// // Canvas.Pen.Mode := pmBlack;
// // Canvas.Pen.Color := clBlack;
// // Canvas.Pen.Style := psSolid;
// // Canvas.Pen.Width := 1;
// // Canvas.MoveTo(50, 50);
// // Canvas.LineTo(500, 500);
//
// end;

end.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:42:03+00:00Added an answer on June 17, 2026 at 8:42 pm

    You’re in a method of ‘TTableDesigner’, if you do not qualify a method ‘Self’ is implied. So the ‘BeginDrag’ call applies to the TableDesigner object.

    You’d rather call ‘TLabel(Sender).BeginDrag(..’.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Delphi XE2 update 3 or update 4 on Win7 64 bit. Calling enumwindows
I am using Delphi XE2 to write a VCL win32 application. Delphi XE2 support
Using Delphi XE2 on Win 7 64 bit creating a 32 bit app... In
I have developed an database application with Delphi XE2 using an Access DB, now
Using: Delphi XE2, DBExpress, Firebird I can't access any VCL control outside the main
Using Delphi XE2 I wanted to make some buttons move in delphi application. I
I'm migrating an old Delphi application (using ZeosDB) to Delphi XE2. I want to
I'm using Delphi-XE2 Enterprise, SQLServer 2008 R2 on Windows Server 2008 R2. When a
I'm using Delphi XE2 Update 3. Update 4 is not compatible with some of
I am using Delphi XE2 with update 4 hotfix 1 My default FMX app

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.