Difference between revisions of "LMD VCL - LMD-Tools FAQ"

From LMD
Jump to: navigation, search
m
Line 76: Line 76:
 
To explicitely allow restart simply use a command line parameter, so that test for previous instance is skipped when command line parameter is set.
 
To explicitely allow restart simply use a command line parameter, so that test for previous instance is skipped when command line parameter is set.
  
 +
=== TLMDTrayIcon ===
 +
==== Starting a trayicon application in hidden state ====
 +
The TrayIcon demo from version LMD-Tools 8.10 on (check <b>lmdtools\Other\LMD Sys\LMDTrayIcon</b> in demos folder) demonstrates this feature (trayicon in taskbar is visible only). To achieve this feature, the project sourcecode must be altered as follows:
 +
<br><br>
 +
<b>Before Delphi/CRS 2007</b>
 +
<delphi>
 +
begin
 +
  Application.Initialize;
 +
  Application.Title := 'Traytool 1.0';
 +
  Application.ShowMainForm := false;
 +
  Application.CreateForm(TForm1, Form1);
 +
  Application.Run;
 +
end.
 +
</delphi><br>
 +
<b>Delphi/CRS 2007 and higher</b>
 +
<delphi>
 +
begin
 +
  Application.Initialize;
 +
  Application.Title := 'Traytool 1.0';
 +
  if LMDSIWindowsVistaUp then
 +
    Application.MainFormOnTaskBar := true;  // not required, but supported since 8.10 (--> Aero Glass)
 +
  Application.ShowMainForm := false;
 +
  Application.CreateForm(TForm1, Form1);
 +
  Form1.trayicon.HideApplication;
 +
  Application.Run;
 +
end.
 +
</delphi>
 +
Recent Delphi releases require additional code (caused by correct Vista support and the new MainFormOnTaskBar feature).
 
=== Container Controls ===
 
=== Container Controls ===
 
==== How to use TLMDStringStringList component correctly? How to add / remove items at runtime? ====
 
==== How to use TLMDStringStringList component correctly? How to add / remove items at runtime? ====
Line 129: Line 157:
 
I use html parser in LMDTextPanel control. The text is an HTML code like that<br>
 
I use html parser in LMDTextPanel control. The text is an HTML code like that<br>
  
<delphi><control vclclass=TButton name="b1" Caption="Hello" width="50" height="50"> <BR> <control vclclass=TLMDEdit name="e1" width="100" height="20"><BR> </delphi>
+
<delphi>
 +
<control vclclass=TButton name="b1" Caption="Hello" width="50" height="50"> <BR>  
 +
<control vclclass=TLMDEdit name="e1" width="100" height="20"><BR>  
 +
</delphi>
  
 
Why the embedded TLMDEdit control is now shown in runtime?<br>
 
Why the embedded TLMDEdit control is now shown in runtime?<br>

Revision as of 00:28, 11 June 2008

[edit]

<< Back to Overview page

General

C++ Builder Notes

  • WebPack: If you encounter linker errors like [Linker Error] Unresolved external "InternetCloseHandle" referenced from... Simply add wininet.lib to your project (file can be found in \lib directory of your C++ Builder / BDS / CRS installation).
  • TextPack: When Runtime Packages are used (Project options, "Build with runtime packages"), it must be assured that lmdparse4rt_XX (XX represents the compiler version) is mentioned before the TextPack packages. Otherwise an exception during application start will occur.
  • TLMDHideNonVC: This component has no functionality in LMD-Tools for CBuilder 5 (and higher) and is included for the sake of compatibility only. Please do not use this component in C++ Builder projects.
  • TLMDFormDisplay: The AddForm method of TLMDFormDisplay was renamed to AddFormExt due to naming conflicts with CBuilder routines.

Packages & Compatibility

Compatibility Components are not installed by default!

User who you used the older components of version 1/3 in their projects (e.g. the ones from the LMD Free tab) must explicitly mark the corresponding check box in the installation options to install the LMD-Tools compatibility components.
Please note:
No components were left out, they're all still available (and will be available in the future). However we want to avoid that new user use these controls because they will not be improved in the future (because they're replaced by improved controls).

ToolBar97 components

The registered VCL Win32 versions of LMD-Tools include a license for the Toolbar97 components. Please note that no precompiled packages are installed during installation, simply install the DPK if you want to use the ToolBar97 components. The ToolBar97 units can be found in the \lib\toolb97 folder. Documentation can be found in HTML format in the \help folder.

LMD-Tools

TLMDCaptionPanel (-Group)

Pasting components from ClipBoard not possible

Because of a glitch with inner controls pasting components from clipboard onto TLMDCaptionPanel components is not possible (controls will be simply not visible). However there is a simple workaround. In context menu of form select “View as Text” and move the object data within the PanelClient object of TLMDCaptionPanel directly in DFM code. Example:

[1] This is an empty TLMDCaptionPanel <delphi>

 object LMDCaptionPanel1: TLMDCaptionPanel
   Left = 304
   Top = 144
   Width = 193
   Height = 121
   Bevel.Mode = bmStandard
   Bevel.StandardStyle = lsWindowBorder
   TabOrder = 0
   object TLMDCaptionPanelClient
   end
 end

</delphi>
[2] Move component data between “object TLMDCaptionPanelClient” and “end”, e.g. <delphi>

 object LMDCaptionPanel1: TLMDCaptionPanel
   Left = 304
   Top = 144
   Width = 193
   Height = 121
   Bevel.Mode = bmStandard
   Bevel.StandardStyle = lsWindowBorder
   TabOrder = 0
   object TLMDCaptionPanelClient
     object Button1: TButton
       Left = 80
       Top = 40
       Width = 75
       Height = 25
       Caption = 'Button1'
       TabOrder = 0
     end
   end
 end

</delphi>

TLMDFormDisplay

How to access specific controls on displayed forms?

To access controls on forms displayed in a TLMDFormDisplay component you have to typecast the active form. E.g. to access an Edit control on a form called TMyForm called Edit1, you have to typecast to:

<delphi>TMyForm(MyFormDisplay.ActiveForm).Edit1.Text:='SampleText';</delphi>
Reason
The Internal Forms array or ActiveForm property use the abstract TCustomForm class. This fact allows you to add any form which is derived from TCustomForm to the TLMDFormDisplay component. The side effect is however, that TLMDFormDisplay control does not know of any special features which are available for a specific descendant (thus typecasting to desired form type is required).

TLMDOneInstance

Flickering of main window when second instance is started.

There are two ways to workaround this:

  • You create a small separate application which has nothing else to do except closing the current instance and restarting it..
  • You do not use the component but internal functions of LMD-Tools (more complex, but elegant).

To mimic TLMDOneInstance without using the control: In the project source file add LMDClass unit to uses clause and check LMDApplication.IsPrevRunning property before any form is loaded (this global property tells you, whether a previous instance is running). If yes, simple exit the application and call LMDActivatePrevInstance method from LMDUtils.pas to activate the already running instance. To explicitely allow restart simply use a command line parameter, so that test for previous instance is skipped when command line parameter is set.

TLMDTrayIcon

Starting a trayicon application in hidden state

The TrayIcon demo from version LMD-Tools 8.10 on (check lmdtools\Other\LMD Sys\LMDTrayIcon in demos folder) demonstrates this feature (trayicon in taskbar is visible only). To achieve this feature, the project sourcecode must be altered as follows:

Before Delphi/CRS 2007 <delphi> begin

 Application.Initialize;
 Application.Title := 'Traytool 1.0';
 Application.ShowMainForm := false;
 Application.CreateForm(TForm1, Form1);
 Application.Run;

end. </delphi>
Delphi/CRS 2007 and higher <delphi> begin

 Application.Initialize;
 Application.Title := 'Traytool 1.0';
 if LMDSIWindowsVistaUp then
   Application.MainFormOnTaskBar := true;  // not required, but supported since 8.10 (--> Aero Glass)
 Application.ShowMainForm := false;
 Application.CreateForm(TForm1, Form1);
 Form1.trayicon.HideApplication;
 Application.Run;

end. </delphi> Recent Delphi releases require additional code (caused by correct Vista support and the new MainFormOnTaskBar feature).

Container Controls

How to use TLMDStringStringList component correctly? How to add / remove items at runtime?

Against the VCL TStrings or TStringList objects the TLMDStringList class is a container for ANY number of TStrings objects. Component does not hold TStrings directly, but TLMDStringListItem objects which provide an Items property for the internal TStringlist object (use this Items property to get access to all properties and methods of the known TStringList oject).
As follows examples for working with TLMDStringList component. To add a new item to the TLMDStringList class write e.g.: <delphi>myIndex:=LMDStringList1.Add(nil); // now you have created a new item with Index myIndex (--> declare as Integer).</delphi> The new created type is a TLMDStringListItem class, which CONTAINS a TStringList object as Items property. Use this Items property as you would use a TStrings or TStringlist object. To assign e.g. a TStringlist object write: <delphi> LMDStringList1.Items[myIndex].Items.Assign(myExternalVCLStringList);// or alternatively write LMDStringList1.Items[myIndex].Items:=myExternalVCLStringList; </delphi> Because TLMDStringListItems array is default array you could also write <delphi>LMDStringList1[myIndex].Items:=myExternalVCLStringList;</delphi> Knowing this you should be able to access single lines or a full stringlist, one example from the helpfile: <delphi> MyLabel.Caption:=LMDStringList1[myIndex].Items[5]; </delphi> This line would assign the 6th line of your recently created stringlist to the Caption property of MyLabel. Other examples: <delphi> LMDStringList1[myIndex].Items.Add('New String'); // Adds new string to the StringList with ID 'myindex' LMDStringList1[myIndex].Items.Delete(3); // Deletes string with index 3 from StringList with ID 'myindex' </delphi> TLMDStringList can handle many TLMDStringListItem objects. Using the .Add method as above you can add as many items as you like. To delete an item from the TLMDStringList class use the .Delete method. To delete the TLMDStringList object itself use <delphi> LMDStringList1.Delete(myIndex); </delphi> To insert a new item at a specific position (here at index 2) use e.g. <delphi>myIndex:=LMDStringList1.Insert(2, nil);</delphi> Check the helpfile or use Code Completion in editor for other standard methods (like Move, LoadFromFile, SaveToFile etc.). Major advantage of using TLMDStringList is saving of large number of text snippets in one component and possibility to compress large large text snippets.


Dialog Controls

Using OnCustomize event in native LMD Dialog controls

<delphi> procedure TForm1.dCustomize(Sender: TObject); var i:Integer; begin with TForm(Sender) do for i:=0 to ComponentCount-1 do if (Components[i] is TLMDButton) and (TLMDButton(Components[i]).Caption='&New Folder') then TLMDButton(Components[i]).Caption:='MyString'; end; </delphi>

LMD TextPack

Using embedded controls in LMDTextPanel

Question

I use html parser in LMDTextPanel control. The text is an HTML code like that

<delphi> <control vclclass=TButton name="b1" Caption="Hello" width="50" height="50">
<control vclclass=TLMDEdit name="e1" width="100" height="20">
</delphi>

Why the embedded TLMDEdit control is now shown in runtime?

Answer

You can use TEdit, TButton, TCheckBox, TRadioButton as embedded controls without any additional code, because these classes are automatically registered in constructor TLMDEmbdControl.Create.

However, you can use any other control TSomeControl provided that RegisterClass(TSomeControl) was called prior to html parsing.

For example, your code will work fine if you add LMDEdit to uses clause and code RegisterClass(TLMDEdit) in FormCreate.

Note for C++ Builder users:
Use RegisterClass(__classid(TLMDEdit)) instead of RegisterClass(TLMDEdit).