Frequently Asked Questions
What is KOL ? What is MCK ?
   KOL is a library of objects, which can be used with Delphi IDE and Delphi compiler to create small 32-bit GUI applications for Windows. Delphi versions from Delphi2 to Delphi7. The smallest GUI program, which can be created using KOL, is about 14K. Smallest console application is about 4,5K with KOL.
   MCK is a kit of mirror components for Delphi, which are installed to Component Palette and allows visual programming of KOL-based application.
Is a size of program made with KOL (and MCK) depending on Delphi version?
Very little. Difference between Delphi3 and Delphi5 can be usually about 1Kbytes, and not always in favour of older version. But, system.dcu replacement is suggested only for Delphi4-Delphi7, and with such replacement the executable can be 9-11K smaller. Choice is of yours.
Is it possible to use KOL (MCK) without uninstalling VCL. If I install KOL (MCK), could it be possible to use VCL without reinstalling the Delphi?
The KOL is installed just by copying it to a directory you choose. Then, it is used in your project units adding a reference to KOL.pas and other necessary units into uses clause. This does not affect VCL projects at all. Similar, for MCK, while it is installed, a set of mirror components is added to the Delphi Component Palette. All other components on the Palette are not affected (excluding a case, when its name is matching a name of one of MCK component. But usually this is rare, since all the MCK components have names like TKOLxxxxxx).
KOL library is developing fast, new properties, methods, events are adding constantly. Are your sure that your lirary will not grow enougth to become large as VCL? (And what the sense in that case to invent a wheel again...)
Yes, I am sure! Because of its well thought-out organization, KOL allows to Delphi compiler to use so called "smart-linking". For example, let us consider one of the addition: an event OnDropFiles (1-May-2001, v0.71). If this is not used and is not assigned, the size of the executable is not increased EVEN FOR A BYTE. And only in case when this event is used in the application, based on KOL, code of two procedures is added from the library: TControl.SetOnDropFiles and WndProcDropFiles. This is so because the procedure WndProcDropTarget is referring only from the method SetDropTarget, which is referring only in case, when an event handler is assigned to the event OnDropTarget. And the entire library is built on this basic principal. (The VCL should be built so, but it is NOT build so, since this, the VCL can not economy size of the executable, when invoked).
I installed additional MCK-component XXXXX in Delphi6 (Delphi7). I created the package, adding a unit XXXXX.pas, tried to install package, but Delphi can not find unit Proxies.dcu. I have no such unit on my machine. What I should to do?
This is standard situation for Delphi6. Add a reference to DesignIDE.dcp in usage part of the package. Do not forget also to change package options to 'Design time only' and 'Rebuild as needed', this is certain for any other Delphi version too (starting from Delphi3).
I have already designide.dcp in uses clause of MirrorKOLPackageD6.dpk (MirrorKOLPackageD7.dpk), but a project can not compile: Delphi says that proxies.pas (dsgnintf.pas) not found. What's wrong?
Following reasons are possible:
1. Your project is not converted to MCK. Please read instruction carefully "III. STARTING NEW KOL MIRROR PROJECT".
2. It is possible, that after dropping some components on the form, a reference to VCL unit is added to the uses clause, and out of IFNDEF KOL_MCK...$ENDIF brackets. May be, it is a reference to mckobjs.pas or other MCK unit. Move it into these brackets manually.
3. Or may be, some files were deleted, which contained important information, such as project options. Create another MCK project as it is said in instruction and see its Projects|Options|Directories\Conditions. Conditional defines must contain KOL_MCK symbol, and in Unit aliases, usual value is "Classes=;mirror=". Setup such options for your MCK project.
I am using your sys*.dcu replacement, but can not use Write and other functions for text files. What I should to do?
1. Read readme.txt :)
2. Call UseInputOutput procedure (once, e.g. in dpr-file).
I am not using sys*.dcu replacement, but I can not use try-except normally. What I should to do to provide correct working of exceptions?
Use err.pas from
Note: This unit does not require for correct working of try-finally therefore.
How to implement default (or cancel button), which responds to key Enter (or Escape)?
1. Now it is possible to use correspondent properties DefaultBtn and CancelBtn.
2. Use event Applet.OnMessage.
I have large fonts installed on my PC (125%). There is form property Scaled in VCL. It is sufficient to set it to False to provide correct showing of text labels on button, label and other controls independently on current screen settings. How to do the same in KOL?
It is sufficient to access property Font of form immediately after creating it. In result, object of type TGraphicTool is created, implementing font, which is assigned to device context of form window. Or, it is possible to access Font property of the Applet (returned by NewApplet function), to change default font for all forms in application. For example: MyForm.Font;
Or, it is possible to change any Font property of form/applet (style, color, height etc.). Note, that by default newly created font has size 20pixels (value of global variable DefFontHeight). Any child controls at the creation inherit font and brush of parent control (form).
When Applet is used, minimizing animation is performing not from main form position, but from top left corner of screen. How to fix this?
Assign True to MinimizeNormalAnimated property of the main form (in MCK) or call same-named method of the form (KOL). This not needed for applications, which contain a single form and do not create special Applet window.
How to create a DLL containing KOL form and to call it from the application?
How to create a DLL containing KOL form and to call it from the application? Create a form as usual and test it first in a standalone application (it is possible to create it visually using MCK). Then, prepare DLL project, containing exported function like follow:

function ExecuteKOLform( < parameters > ): Integer; stdcall;
var MyKOLForm: PControl;
  Applet := NewApplet( '' );
  MyKOLForm := NewForm( Applet, 'DllKolForm' );
  ... // create form controls, do other things
  ... // here You can read the state of controls // and to do something with it Applet.Free; end;
How to show form modal correctly?
There are two cases at all. First, more simple, when a form is created just before showing and destroyed immediately after finishing modal dialog. For such case, it is not necessary to have separate Applet object (for MCK project, component TKOLApplet is not required).

// showing of a modal dialog, created just before
// starting it and destroyed after finishing it
procedure TForm1.Button1Click(Sender: PObj);
  NewForm2( Form2, Applet );
  // insert here any code to make
  // changes before showing Form2
  // insert here any code to read
  // some data from Form2
  Form2.Form.Free; // not Close !
  //ShowMessage( 'End of TForm1.Button1Click' );

For such case it is sufficient to create an event handler (like following), which is called (e.g.) in result of click on some button (but for this case, even such handler is not needed, and form can be closed clicking 'x' button of window caption or by some another way (e.g. system menu).

procedure TForm2.Button1Click(Sender: PObj);
  Form.ModalResult := 1; // any value <> 0
The second case is harder a bit. If the form is already existing (but usually is hidden), and we want to show it modal, but without destroying it immediately after finishing the dialog (suppose, we want to hide it instead). For such case, separate object must be used as Applet (for MCK project this means, that TKOLApplet object should be used).

// Showing a dialog modal:
procedure TForm1.Button1Click(Sender: PObj);

// Finishing a dialog on button click:
procedure TForm2.Button1Click(Sender: PObj);
  Form.ModalResult := 1; // any value <> 0

// Event handler for form's event OnClose
// must be defined to prevent form destroying:
procedure TForm2.KOLForm1Close(Sender: PObj;
var Accept: Boolean);
  Accept := FALSE; // prevents closing
  Form.ModalResult := -1; // any value <> 0
Take in your attantion, that in both cases final steps are made by the code, which is initiating showing modal dialog, i.e. in Form1 code.
Is it possible to create a DLL containing KOL forms visually, using MCK?
Yes, certainly. Create MCK project as usual, and then change word program in your dpr-file to library. Make also your forms not auto-creating, and add exported function(s) like it is shown in answer above.
To prevent executing Run( Applet ), modify file E.g., write there:

I want to provide dragging a button (or any other control) using left (or right) mouse button. How to do this?
Following code should work for all controls, including buttons:

procedure TForm1.BitBtn1MouseMove(Sender: PControl;
var Mouse: TMouseEventData);
  if FBtn1Down then
procedure TForm1.BitBtn1MouseDown(Sender: PControl;
var Mouse: TMouseEventData);
  if Mouse.Button = mbLeft then
  FBtn1Down := TRUE;
procedure TForm1.BitBtn1MouseUp(Sender: PControl;
var Mouse: TMouseEventData);
  FBtn1Down := FALSE;

( FBtn1Down: Boolean; should be declared in TForm1 object).

And, for most of controls it is sufficiently to use following code:
procedure TForm1.Panel1MouseDown(Sender: PControl;
var Mouse: TMouseEventData);
But this code provides only dragging by left mouse button, and it is useless for button.
How to paint on desktop directly, but using PCanvas ?
procedure TForm1.Toolbar1TB1Click(Sender: PControl; BtnID: Integer);
var C: PCanvas;
	D: HDC;
  D := GetDC( 0 );
  C := NewCanvas( D );
  C.LineTo( 400, 400 ); // use here methods &
	                    // properties of TCanvas
  ReleaseDC( 0, D );
I have on the form two or more toolbars, and my project is not compiled, and an error detected: name TB1 is duplicated.
   It is necessary to give unique names for toolbar buttons, e.g.: TBOpen, TBClose, etc. In such case it is convenient to access toolbar buttons properties using those names, e.g.: Toolbar1.TBButtonVisible[ TBSave ]. Moreover, it is not necessary to change source code every time when new buttons are added (or inserted) or deleted to a toolbar.
   If you do not want take care of toolbar button names, just turn off property GenerateButtonNames for a toolbar. The same is for ListView columns and menu items.
How to assign a regular procedure or function rather then a method of object as an event handler for some event (e.g. OnMessage)? MainForm.OnMessage := TOnMessage(MakeMethod(nil,@OnHotKey)); where OnHotKey is defined as: function OnHotKey( var Msg: TMsg; var Rslt: Integer ): Boolean; leads to errors due execution.
A procedure or a function which is a method of object or class, differ from a regular procedure or function by a presence of hidden first parameter, which represents the Self variable. Almost all the events are defined as methods of objects. So, if a regular procedure or function should be used, missing first parameter must be declared:
function OnHotKey( Dummy_Self: PObj; var Msg: TMsg; var Rslt: Integer ): Boolean;
In such case an object passed as the first parameter of MakeMethod (in your case above it is nil) will be passed to OnHotKey as the first parameter Dummy_Self. But would it be missed in OnHotKey declaration, then nil is passed incorrectly as Msg which certainly produces an exception due execution.
The Delphi debugger watches incorrect values for properties while debugging the application, how to fix this?
1. Add not a property itself to Watch window, but a correspondent field. E.g., MyList.FCount rather then MyList.Count.
2. Use KOL with classes (see KOL2FPC, now GlueCat), at least while debugging.

Copyright (C) 1999-2006 by Vladimir Kladov