I'm using Victor's improved HTML embedded controls in TElXTree to display progress bars. I have a few questions regarding their use.
1. Is there a way to auto-size the control to fill the cell's width?
2. Is there a way to set a layout/alignment so the control is automatically positioned in the centre/middle of the cell? If not, I know I can use the OnAdjustControlPosition event to set the position but I can't see how to find the tree item/cell that contains the control in order to find the item's height/cell's width so I can centre the control.
3. How do I adjust properties of the control (such as progress bar's position, error/paused state and marquee state)? Can I access the actual control and manipulate that or do I just keep changing the HTML in the cell and let the HTML renderer do the work?
Perhaps it would be worth making a tutorial on these HTML controls since they appear quite powerful but aren't documented anywhere.
Comments
I am currently preparing a demo for HTML embedded controls in ElXTree.
Meanwhile, here are quick answers:
1. Yes, you can use OnAdjustControlPosition event. Sample code:
procedure TForm2.ElXTree1AdjustControlPosition(Sender: TObject;
aControlName: TLMDString; aData: Pointer; var X, Y: Integer);
var
lCell: TElXTreeCell;
begin
lCell := TElXTreeCell(aData);
TElXTreeItem(TElXTreeCell(aData).Owner).GetHTMLControlByName(aControlName).Width := lCell.Width;
X := 2;
Y := 2;
end;
2. Yes, you can use, again, the OnAdjustControlPosition event.
3. All the HTML embedded controls are child controls of ElXTreeView object. Also, each item mantnais its own list of HTML embedded controls. You can use either
ElXTree1.GetHTMLControlByName() method which looks for a given name among all treeview child controls, or ElXTreeItem.GetHTMLControlByName() method, which browses item's list of HTML embedded control.
In order to address HTML embedded control by name, you have to set its name in HTML code. Also, you can set property values in html code:
Also, at which point should I be able to access the control using the GetHTMLControlByName method? At the moment, I've got an event handler for the tree's OnItemPostDraw event that stores a pointer to the control so it can be accessed easily elsewhere. Is this event the best place to do this or is there a better way/place?
I look forward to your demo.
As to GetHTMLControlByName - you should be able to use it as soon as HTML code containing controls has been rendered. You can use OnAdjustControlPosition as well to gather pointers to embedded controls.
In previous post an HTML code sample is missing, so here is it:
"In order to address HTML embedded control by name, you have to set its name in HTML code. Also, you can set property values in html code:
<html><control vclclass="TProgressBar" name="p5" width="50" height="14" position="50"></html>
When the mouse is over the HTML control, the tree item doesn't HotTrack nor show item hints. Is this something you can add support for?
I see HotTracking while over HTML controls as expected behaviour since you're still hovering over the item itself. (The HTML control should essentially become part of the tree item.)
As for the hints, perhaps the item hint could show through when the HTML control has ShowHint = False, or alternatively include an HTMLControlShowItemHint (or similar) property on the tree item.