Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

On dock start, cannot access child vcl component's data fields

edited May 2014 in LMD-Tools Vote Up0Vote Down
Hi,

sorry its something very basic but i need help.

I have a TLMDDockPanel with a TFrame on it, the TFrame has a TTreeView component. After i assign object references to the treenode's 'data' property and i undock the dockpanel i get bunch of error messages. That is because it seems that i cannot access treenode's data while docking (treeview has an OnChange event handler and in that i access the treenode's data property - OnChange is called because the treeview get focus at dock start, although i dont know why). The question is that why i cannot access the treenodes data while docking (dock start), is it normal? 

I set the following:

procedure TfrmCLmain.LMDDP_DevTreeEndDock(Sender, Target: TObject; X,
  Y: Integer);
begin
  frmDevTree.Enabled := true;
end;

procedure TfrmCLmain.LMDDP_DevTreeStartDock(Sender: TObject;
  var DragObject: TDragDockObject);
begin
  frmDevTree.Enabled := false;
end;

But yet sometimes i get a 'Cannot focus a disabled or invisible window' message and the Dockpanel disappears forever (:. Is there any way to disable the autofocus on TFrame at dock start? And is that a normal behavior that i cannot access LMDDock panels child components data fields while docking (dock start)?

Thank You!

Comments

  • 3 Comments sorted by Votes Date Added
  • Hi,

    This is a known bug of TTreeView. It will happen in any docking operation, including standard Delphi docking. The technical problem is that tree view recreates all items when its Handle is recreated. It saves items to internal stream and restores it back after creation of new window handle. This will even happen if you change the Parent of the tree view. 

    Generally, there is nothing to do with that. You should solve the problem algorithmically, e.g. by storing data anywhere in your own array and re-associating it after treee view handle re-creation.
  • edited May 2014 Posts: 13Vote Up0Vote Down
    Thank You, that makes sense.
Sign In or Register to comment.