Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 676 to 690 of 888, page 46 of 60
<< previous next >>



Disable internal drag/drop in TAdvSmoothDock
To disable the internal item drag/drop in the TAdvSmoothDock add the
OnItemStartDrag event and set Allow to false:
procedure TForm1.AdvSmoothDock1ItemStartDrag(Sender: TObject; DragItem: TAdvSmoothDockItem; var Allow: Boolean); begin Allow := false; end;



Add a new page programmatically
This code snippet adds a new page to a TAdvSmoothTabPager:
var page: TAdvSmoothTabPage; begin page := TAdvSmoothTabPage.Create(AdvSmoothTabPager1); page.Caption := 'New page'; page.AdvSmoothTabPager := AdvSmoothTabPager1; end;



When trying to install the trial version of the components I get an error similar to: [Fatal Error] IW51TMSxx.dpk: Unit IWTMSCtrls was compiled with a different version of IWBaseControl.TIWBaseControl
Make sure there is ONLY ONE version of TMS IntraWeb Components in your Delphi or C++Builder library path and that this version matches EXACTLY your IntraWeb version. Ie. TMS IntraWeb Components for IntraWeb version X.Y.Z will ONLY work with IntraWeb X.Y.Z, NO OTHER IntraWeb versions. Make sure there are no old TMS IntraWeb Component version files in your library path as well as no different IntraWeb versions on your system.



Programmatically adding items to the application menu
This code snippet shows how menu items and submenu items can be programmatically added to the application menu, TAdvPreviewMenu:
begin AdvPreviewMenu1.MenuItems.BeginUpdate; with AdvPreviewMenu1.MenuItems.Add do begin Caption := 'Mainitem1'; SubMenuCaption := 'Sub menu caption1'; with SubItems.Add do begin Title := 'Subitem1'; Notes.Text := 'This is an additional note'; end; end; with AdvPreviewMenu1.MenuItems.Add do begin Caption := 'Mainitem2'; SubMenuCaption := 'Sub menu caption2'; with SubItems.Add do begin Title := 'Subitem2'; Notes.Text := 'This is an additional note'; end; end; AdvPreviewMenu1.MenuItems.EndUpdate; end;



I want to override the popup menu of the default grid inplace editor
You can assign a custom popup menu to the default grid inplace editor with following code:
procedure TForm2.AdvStringGrid1GetEditText(Sender: TObject; ACol, ARow: Integer; var Value: string); begin AdvStringGrid.NormalEdit.PopupMenu :=PopupMenu1; end;



Detect if a cell has an item
This code snippet shows how it can be detected whether there is an item in the selected cells or not:
begin if not Assigned(Planner1.Items.FindFirst(Planner1.SelItemBegin, Planner1.SelItemEnd, Planner1.SelPosition)) then begin ShowMessage('Time slot in planner is empty'); end; end;



Adding columns and items programmatically at runtime
This code snippet creates a TColumnListBox with 2 columns and 2 items at runtime:
var cb: TColumnListbox; begin cb := TColumnListbox.Create(self); cb.Parent := self; cb.Columns.Add; cb.Columns.Add; with cb.ListBoxItems.Add do begin Strings.Add('Col 1 Row 1'); Strings.Add('Col 2 Row 1'); end; with cb.ListBoxItems.Add do begin Strings.Add('Col 1 Row 2'); Strings.Add('Col 2 Row 2'); end; end;



Using the design time editor at runtime
Using the design time editor at runtime is easy. First of all, add the unit uMemoEdit to the uses list. If is desired a memo is being edited at runtime using the design-time editor, following code can be used:
procedure TForm2.Button1Click(Sender: TObject); var me: TTMSMemoEdit; begin me := TTMSMemoEdit.Create(self); try me.AdvMemo1.Lines.Assign(AdvMemo1.Lines); if me.ShowModal = mrOK then AdvMemo1.Lines.Assign(me.AdvMemo1.Lines); finally me.Free; end; end;



Retrieving list of files on the FTP server
To retrieve a list of files on the FTP server, following code can be used:
var i: integer; begin webcopy.Items.Clear; with webcopy.Items.Add do begin FTPHost := 'ftp.server.com'; FTPUserID := 'user'; FTPPassword := 'pasword'; Protocol := wpFtpList; TargetDir := 'c:\temp'; URL := 'ftpdirectory\*.txt'; end; webcopy.Execute; for i := 0 to webcopy.Items[0].FileDetails.Count - 1 do begin listbox.Items.Add(webcopy.Items[0].FileDetails[i].FileName); end; end;



Update smooth controls faster with BeginUpdate and EndUpdate
This short article describes the use of BeginUpdate and EndUpdate methods to allow faster updating and repainting.
When creating a smooth listbox or a smooth imagelistbox with 500+ items in code, it tends to be slow when starting the application.
For each item that is added / deleted or updated, the listbox is updated. It is just a matter of milliseconds to update the listbox for one item, but imagine the time that is needed to update 500 items. And these items are drawn with the default layout. With more advanced items the update process can be painfully slow.
Because we cannot predict when the user wants to update the listbox, we have implemented a BeginUpdate and EndUpdate which *blocks* the painting of the listbox until the EndUpdate is called. Then all the calculations and painting is executed once, with all the new information the user has inserted in the items.
Below is a code sample based on the TAdvSmoothListBox component to update all items between a BeginUpdate and EndUpdate.
var i: integer; begin AdvSmoothListBox1.Items.BeginUpdate; for I := 0 to AdvSmoothListBox1.Items.Count - 1 do begin AdvSmoothListBox1.Items[i].Caption := 'Item Updated !'; end; AdvSmoothListBox1.Items.EndUpdate;
Important note !: All BeginUpdate calls must end with an EndUpdate. In other words: The count of BeginUpdate and EndUpdate calls must be equal. When this condition is false, the listbox will not update, and the listbox will not respond to other update calls.
A List of components which currently implement the BeginUpdate and EndUpdate:
- AdvSmoothListBox (AdvSmoothListBox.Items.BeginUpdate / EndUpdate)
- AdvSmoothImageListBox (AdvSmoothImageListBox.Items.BeginUpdate / EndUpdate)
- AdvSmoothDock (AdvSmoothDock.BeginUpdate / EndUpdate)
- AdvSmoothExpanderGroup (AdvSmoothExpanderGroup.BeginUpdate / EndUpdate)
- AdvSmoothSplashScreen (AdvSmoothSplashScreen.BeginUpdate / EndUpdate)
- AdvSmoothTimeLine (AdvSmoothTimeLine.BeginUpdate / EndUpdate)
- AdvSmoothTouchKeyBoard (AdvSmoothTouchKeyBoard.Completion.BeginUpdate / EndUpdate)



Working with HTTPS
When using HTTPS, make sure to set Authenticate to waAuto or waAlways. When HTTPUserID is an empty string and Authenticate is either waAlways or waAuto, WebCopy will show a dialog to prompt for the HTTP username and password. Otherwise, the preset username and password is used:
with WebCopy.Items.Add do begin URL := 'https://www.tmssoftware.com/webcopy.zip'; Protocol := wpHTTP; FileDate := EncodeDate(2002,3,18); CopyNewerOnly := true; TargetDir := 'c:\temp'; Authenticate := waAlways; HTTPUserID := 'myhttpuserid'; HTTPPassword := 'myhttppassword'; end; WebCopy.Execute;



Adding multiline text in the listview header
The TAdvListView component supports HTML formatted text, combination of images and text as well as multiline text in the header. .The key property to enable this capability is AdvListView.HeaderOwnerDraw. When this property is set to true, this becomes possible. Following code snippet shows how to initialize the listview with multiline text:
begin advlistview1.ViewStyle := vsReport; AdvListView1.Columns.Add.Caption := 'Column 1'#13#10'Extra info'; AdvListView1.HeaderHeight := 30; AdvListView1.Columns.Add.Caption := 'Line1'#13#10'Line2'; AdvListView1.Columns.Add.Caption := 'Column 3'; advlistview1.OwnerDraw := true; advlistview1.HeaderOwnerDraw:= true; end;



Adding a tree structure in the InspectorBar
A tree structure can be added in InspectorBar items by using the item's Level property. By default, all items have Level = 0, meaning that all items are treated as root items. When Level is set to a value different from zero, this means that the item becomes the child item of another item before this item with a smaller Level property value. In this sample code snippet, a panel is programmatically created and a tree structure of a root item, a child item and a child of this child item is inserted.
begin InspectorBar1.Panels.Add; InspectorBar1.PanelCaption.SideDisplay := true; InspectorBar1.PanelCaption.SideWidth := 20; InspectorBar1.PanelCaption.OpenCloseGraphic := ocgCross; InspectorBar1.Mode := imMultiPanelActive; InspectorBar1.Panels[0].Caption := 'A panel'; InspectorBar1.Panels[0].ItemHeight := 23; InspectorBar1.Panels[0].Items.Add; InspectorBar1.Panels[0].Items.Add; InspectorBar1.Panels[0].Items.Add; InspectorBar1.Panels[0].Items.Add; InspectorBar1.Panels[0].Style := psProperties; InspectorBar1.Panels[0].Items[0].Level := 0; InspectorBar1.Panels[0].Items[0].Caption := 'Root 0'; InspectorBar1.Panels[0].Items[1].Level := 1; InspectorBar1.Panels[0].Items[1].Caption := 'Item'; InspectorBar1.Panels[0].Items[2].Level := 2; InspectorBar1.Panels[0].Items[2].Caption := 'SubItem'; InspectorBar1.Panels[0].Items[3].Level := 0; InspectorBar1.Panels[0].Items[3].Caption := 'Root 1'; end;



Showing a HTML Popup in the bottom right of the form
This code snippet shows how you can shows a HTMLPopup in the bottom right corner of your form:
procedure TForm2.Button3Click(Sender: TObject); var pt: TPoint; r: TRect; begin r := ClientRect; pt := Point(r.Right, r.Bottom); pt := ClientToScreen(pt); HTMLPopup1.Text.Text := 'Hello world'; HTMLPopup1.PopupWidth := 200; HTMLPopup1.PopupHeight := 200; HTMLPopup1.PopupLeft := pt.X - HTMLPopup1.PopupWidth; HTMLPopup1.PopupTop := pt.Y - HTMLPopup1.PopupHeight; HTMLPopup1.Show; end;



The caption is not displayed on the button.
Please make sure that you use a TrueType font such as Arial or Tahoma.
TAdvSmoothButton requires that a TrueType font is used for improved text rendering.