LMD VCL - LMD ElPack FAQ
<< Back to Overview page
Contents
TElDateTimePicker
a) To translate the names of months and days use property CustomCalendarNames that contains lists of LongMonthNames, ShortMonthNames, LongDayNames and ShortDayNames. It changes the captions in calendar-grid.
b) There are several ways to change buttons captions:
- 1) you can change resourcestrings SLMDCapToday, SLMDCapOk etc. in LMDElConst.pas
- 2) you can use method c)
- 3) you can change variable that declared in ElDTPick for example as below:
<delphi> procedure TForm1.FormCreate(Sender: TObject); begin // destroy old form if need:
ElDateTimePicker1.ShowPopupCalendar := False;
// change variable that contains caption for Today button:
TodayCap := 'Now!';
// new form with new captions will be created:
ElDateTimePicker1.ShowPopupCalendar := True;
end; </delphi>
You can change ClearCap, TodayCap, OkCap, CancelCap, CalendarCap, CapCalendarGB, CapClockGB, NextYearHint, NextMonthHint, PrevYearHint and PrevMonthHint.
c) To manage buttons:
<delphi> type
THElDateTimePicker = class(TElDateTimePicker);
procedure TForm1.ElDateTimePicker1DropDown(Sender: TObject); var
LForm: TElCalendarForm;
begin
LForm := THElDateTimePicker(Sender).FForm; if Assigned(LForm) then begin // tuneup the form. LForm.ClearBtn.Visible := false; end;
end; </delphi>
Available buttons: ClearBtn, TodayBtn, OkBtn, CancelBtn.
TElInspector
How to use custom inplace editors?
Inspector uses own collection of inplace editors. You can examine them in ElInspectorEditors.pas We'll define simple descendant of the button edit and will use it for editing of boolean values. <delphi> type
TForm1 = class(TForm)
ElInspector1: TElInspector; ElInspectorRTTIDataSource1: TElInspectorRTTIDataSource;
...
end;
TMyElInspectorInplaceButtonEdit = class(TElInspectorInplaceButtonEdit) protected procedure BtnClick(Sender: TObject); override; end;
implementation
{ TMyElInspectorInplaceButtonEdit }
procedure TMyElInspectorInplaceButtonEdit.BtnClick(Sender: TObject); begin
if MessageDlg('Yes = True, No = False', mtConfirmation, [mbYes,mbNo], 0) = mrYes then begin TElInspectorItem(Item).InspectorData.AsString := 'True'; Editor.Text := 'True'; end else begin TElInspectorItem(Item).InspectorData.AsString := 'False'; Editor.Text := 'False'; end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: integer; LT: TElInspectorRegister;
begin // we must to find current editor for boolean values in inspector's editors list
for i := 1 to ElInspectorRTTIDataSource1.RegisterList.Count - 1 do begin LT := TElInspectorRegister(ElInspectorRTTIDataSource1.RegisterList.Items[i]); if (LT is TElInspectorTypeInfo) and (TElInspectorTypeInfo(LT).TypeInfo = TypeInfo(Boolean)) then begin // remove current boolean editor ElInspectorRTTIDataSource1.RegisterList.Remove( ElInspectorRTTIDataSource1.RegisterList.Items[i] ); // register our editor ElInspectorRTTIDataSource1.RegisterList.Insert(i, TElInspectorTypeInfo.Create(TMyElInspectorInplaceButtonEdit, TElBooleanProperty, TypeInfo(Boolean))); Break; end; end;
</delphi>
TStyleManager
How to use StyleName?
Style Manager operates with hierarchical style sheets. These style sheets are similar to Cascading Style Sheets (CSS), used in web pages, but they are more effective and easy to use. Each style sheet contains several styles.
Each style contains one or more property values. When the style is applied to the component, the component is checked for presence of the property with given name. If the property is present, it is set to the value, specified in the style.
Style can be one of three types:
- 1) Default
- 2) Class
- 3) Specific
There is one default style per style sheet. It is an ancestor for all other styles. Specific styles are applied when they are explicitly referred to by the component (in it's StyleName property).
Name of Specific style should begin by point (ex. '.CustomStyle') for prevention of crossing with names of classes.
Class styles are applied when there is no specific style name specified for the component. In this case the style with the name equal to component's class is searched for and applied. For example, if the component TElEdit refers to style manager, but there is no style name specified, Style Manager tries to find the style named 'TElEdit'. If it finds, this style is applied.
HTML controls
Could you tell me how to get the HTML text on an HTML Label (View, TElXTreeCell etc.) to center?
You may use <html4strict>''</html4strict> tag to set desired text alignment.ElShellTree, ElTree, ElXTree
How to automatically check/uncheck all child nodes with check/uncheck a folder node?
In this example we place on form TElShellTree and assign it's event handlers as below.
<delphi> uses .... , LMDTypes, ShlObj;
procedure TForm1.FormCreate(Sender: TObject); begin
ElShellTree1.ShowCheckBoxes := True;
// don't clear items on collapse to not discard checkbox's state
ElShellTree1.ClearOnCollapse := False;
end;
procedure TForm1.ElShellTree1ItemChecked(Sender: TObject; Item: TElTreeItem);
procedure CheckChilds(AItem: TElTreeItem); var it : TElTreeItem; begin it := AItem.GetFirstChild; while Assigned(it) do begin it.Checked := AItem.Checked; CheckChilds(it); it := AItem.GetNextChild(it); end; end;
begin
CheckChilds(Item);
end;
procedure TForm1.ElShellTree1ItemAdded(Sender: TObject;
ItemName: TLMDString; ShellFolder: IShellFolder; RelPIDL: PItemIDList; Item: TElShellTreeItem);
begin // check that the item has checkbox's state as its parent // this is necessary only for TElShellTree because it's build dynamically
if Assigned(Item.Parent) then Item.Checked := Item.Parent.Checked;
end; </delphi>
El(X)Tree
How to draw part of item's text to pass over the several columns?
You can use OnItemPostDraw event to redraw part of item. For example I can redraw item text over first two columns:
<delphi> uses elstrutils;
procedure TForm1.ElTree1ItemPostDraw(Sender: TObject; Canvas: TCanvas;
Item: TElTreeItem; ItemRect: TRect; var DrawFocusRect: Boolean);
var
R: TRect; s: TElFString; i: integer;
begin
R := ItemRect; R.Right := ElTree1.HeaderSections[0].Width + ElTree1.HeaderSections[1].Width - 1; R.Top := R.Top + Item.Height div 2; // dirty calculation. use HTMLRender to render text if you need exact result // this is main column so we need to take into account space for lines and buttons R.Left := R.Left + Item.IndentAdjust; if (ElTree1.ShowRoot and ElTree1.ShowLines) or (ElTree1.ShowButtons and ElTree1.ShowRootButtons) then Inc(R.Left, ElTree1.ItemIndent) else Inc(R.Left, ElTree1.ItemIndent div 5); // offset rect if we use images R.Left := R.Left + 20 ; // paste here image width + 4 instead of 20 Canvas.Brush.Style := bsSolid; Canvas.Brush.Color := clWhite; // set item's color if need// my Item.Text = '<html>Some text 1
'+#13#10+'Some very very very very very very long text 2</html>' i := Pos(#10, Item.Text); s := ; if i > 0 then s := Copy(Item.Text, i + 1, length(Item.Text) - i - 8); // 8 to ignore '</html>' DrawTextW(Canvas.Handle, PWideChar(s), length(s), R, DT_NOPREFIX and DT_Left); end; </delphi>
ElDB(X)Tree
How could I display images in an Item if I've stored image's indexes in a database field?
- 1. Set TElDBXTree.ShowImages = True
- 2. Assign list of images (TImageList, TElImageList etc) to TElDBXTree.Images (and TElDBXTree.Images2 if you need it) properties
- 3. Open TElDBXTree.StylesDefs property in Object Inspector and choice "Table field" radiobutton in "Item images" radiogroup. It enforce setting Item.ImagesFromBase property to True for items.
- 4. Set data fields, where values for 1st (and 2st) image indexes was stored (look at Normal and State combos).
Hereon you should see images on the left side of the item's text.
How to make the sorted column drawn with an special background color
There are several ways to reach it.
- 1) you may use OnSortEnd event to set custom style to each cell
ex:
<delphi>
procedure TForm1.ElXTree1SortEnd(Sender: TObject);
var
i, j: integer;
begin
for j := 0 to ElXTree1.Items.Count - 1 do begin for i := 0 to ElXTree1.HeaderSections.Count - 1 do begin ElXTree1.Items.Item[j].Cells[i].UseOwnStyle := True; if (i = ElXTree1.SortSection) and (ElXTree1.HeaderSections.Sections[ElXTree1.SortSection].SortMode <> hsmNone) then begin ElXTree1.Items.Item[j].Cells[i].Style.CellBackGroundColor := clMoneyGreen; ElXTree1.Items.Item[j].Cells[i].Style.ParentColors := false; ElXTree1.Items.Item[j].Cells[i].Style.UseBackGroundColor := true; end else begin ElXTree1.Items.Item[j].Cells[i].Style.CellBackGroundColor := clWhite; ElXTree1.Items.Item[j].Cells[i].Style.ParentColors := false; ElXTree1.Items.Item[j].Cells[i].Style.UseBackGroundColor := true; end; end; end;
end;
</delphi>
- 2) you may use the cascading property of style to reach the same effect:
ex:
<delphi>
procedure TForm1.FormCreate(Sender: TObject);
var
i, j: integer;
begin // create test tree with 5 items. set custom colors in cells but not activate it
for j := 0 to 5 do begin ElXTree1.Items.AddChild(nil,'Item'+Inttostr(j)); ElXTree1.Items.Item[j].Cells[1].Text := Inttostr(j); for i := 0 to ElXTree1.HeaderSections.Count - 1 do begin ElXTree1.Items.Item[j].Cells[i].UseOwnStyle := True; ElXTree1.Items.Item[j].Cells[i].Style.CellBackGroundColor := clMoneyGreen; ElXTree1.Items.Item[j].Cells[i].Style.ParentColors := true; end; end;
end;
procedure TForm1.ElXTree1SortEnd(Sender: TObject); var
i, j: integer;
begin // in this procedure we activate using own colors for cells in sorted section
for j := 0 to ElXTree1.Items.Count - 1 do begin for i := 0 to ElXTree1.HeaderSections.Count - 1 do begin if (i = ElXTree1.SortSection) and (ElXTree1.HeaderSections.Sections[ElXTree1.SortSection].SortMode <> hsmNone) then ElXTree1.Items.Item[j].Cells[i].Style.ParentColors := false else ElXTree1.Items.Item[j].Cells[i].Style.ParentColors := true; end; end;
end;
</delphi>
- 3) if the tree contains a lot of items more optimized to set colors in OnItemPreDraw event:
ex:
<delphi>
procedure TForm1.ElXTree1ItemPreDraw(Sender: TObject; Item: TElXTreeItem);
var
i: integer;
begin
for i := 0 to ElXTree1.HeaderSections.Count - 1 do begin Item.Cells[i].UseOwnStyle := True; if (i = ElXTree1.SortSection) and (ElXTree1.HeaderSections.Sections[ElXTree1.SortSection].SortMode <> hsmNone) then begin Item.Cells[i].Style.CellBackGroundColor := clMoneyGreen; Item.Cells[i].Style.ParentColors := false; Item.Cells[i].Style.UseBackGroundColor := true; end else begin Item.Cells[i].Style.CellBackGroundColor := clWhite; Item.Cells[i].Style.ParentColors := false; Item.Cells[i].Style.UseBackGroundColor := true; end; end;
end;
</delphi>
- 3a) ... or use virtual mode of tree
[ Please look examle of virtual tree in our demo]
NVIDIA problem
Spme users reported that they have pronlem with nView desktop manager. The Problem in the implementation of nView. It also crash Windows Explorer, WebEx in IE.
Solution:
Try to update to latest Version of nView. There are hooking some Win-API's and Windows-Messages and sometimes forget to pass the messages to the real destination.