Sign in Join
Wiki copytemporary

KOL: what changed

Revision 3 to 4. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11## Introduction
22
3-![](/wiki-images/a/a5/Kolmck.png)\
4-
5-The Key Objects Library, a.k.a. KOL, is an object oriented framework created by Vladimir Kladov ([website](http://f0460945.xsph.ru/rindex.htm)) in 2000. It is the successor to the XCL library by the same author. The Mirror Classes Kit, a.k.a. MCK, is a set of visual components to write KOL applications in a visual design way, from within the Delphi IDE.
3+[![kolmck.png](/wiki-images/c/ca/kolmck.png)](</File:kolmck.png>)
4+
5+The Key Objects Library, a.k.a. KOL, is an object oriented framework created by Vladimir Kladov in 2000. It is the successor to the XCL library by the same author. The Mirror Classes Kit, a.k.a. MCK, is a set of visual components to write KOL applications in a visual design way, from within the Delphi IDE.
66
7-The current point release is 3.23 for KOL and 3.23 for MCK.
7+The current point release is 3.23 for KOL and 3.23 for MCK.
88
9-New versions appear with Irregular intervals, but the library is currently maintained. There is an svn repository for KOL and MCK at <https://svn.code.sf.net/p/kolmck/code/> which is usually more up to date than the point releases.
9+New versions appear with Irregular intervals, but the library is currently maintained.
10+There is a git repository for KOL and MCK at <https://github.com/Thaddy/kol4/> which is usually more up to date than the point releases. At the time of writing this is version 4.00RC and updated to work with newer Freepascal and Delphi versions.
1011
11-The main reason creating this library is explained through the dissatisfaction of Vladimir and others towards ever increasing code bloat. Nobody seemed to care anymore about *efficient* coding. According to KOL users there a strong correlation between Moore's law and degrading code optimizing efficiency.
12+The main reason creating this library is explained through the dissatisfaction of Vladimir and others towards ever increasing code bloat. Nobody seemed to care anymore about *efficient* coding. According to KOL users there a strong correlation between Moore's law and degrading code optimizing efficiency.
1213
13-An MCK project designed in a Delphi IDE can be recompiled with both 32 bit and 64 bit FPC 2.7.1 or later compilers without change. This way you can without having to upgrade your Delphi to a recent version:
14+An MCK project designed in a Delphi IDE can be recompiled with both 32 bit and 64 bit FPC 2.7.1 or later compilers without change. This way you can without having to upgrade your Delphi to a recent version:
1415
15-- obtain a 64 bit version of a project.
16-- obtain a unicode version of a Delphi project (5-2007) by simply defining -dUNICODE_CTRLS.
17-- or both!
16+ * obtain a 64 bit version of a project.
17+ * obtain a unicode version of a Delphi project (5-2007) by simply defining -dUNICODE_CTRLS.
18+ * or both!
1819
19-The framework centers around three basic concepts:
20+The framework centers around three basic concepts:
2021
21-- It uses - some say old school - pascal objects, not classes.
22-- Most of the widgets are basically one and the same object. Polymorphism is through constructing functions.
23-- It ignores the VCL/LCL, in fact it attempts to replace them.
22+ * It uses - some say old school - pascal objects, not classes.
23+ * Most of the widgets are basically one and the same object. Polymorphism is through constructing functions.
24+ * It ignores the VCL/LCL, in fact it attempts to replace them.
2425
25-This has several **advantages**, some of which are:
26+This has several **advantages** , some of which are:
2627
27-- The size of your binary is very tiny, on average more than 20 times smaller than a VCL/LCL binary, but a factor 100 or more is not unusual.
28-- KOL binaries (both executables and dll's) have much much faster load times and feel snappier.
29-- KOL is very easy to extend once you understand its concepts. It is a fully object oriented framework.
28+ * The size of your binary is very tiny, on average more than 20 times smaller than a VCL/LCL binary, but a factor 100 or more is not unusual.
29+ * KOL binaries (both executables and dll's) have much much faster load times and feel snappier.
30+ * KOL is very easy to extend once you understand its concepts. It is a fully object oriented framework.
3031
31-It also has very obvious **disadvantages**, some of which are:
32+It also has very obvious **disadvantages** , some of which are:
3233
33-- KOL is a framework. It doesn't mix very well with classes and it can't be sensibly mixed with LCL/VCL code because you will loose the size advantage.
34-- If you are not familiar with the old Object Pascal paradigm from Turbo Pascal the learning curve can be steep.
35-- You will miss some functionality that has become common place, like RTTI, but most of these features are often codebloat and the reason why KOL exists in the first place.
36-- Because you are often working on the same object with multiple appearances, it may be confusing that some methods or properties that you can see in the code editor do not apply.
34+ * KOL is a framework. It doesn't mix very well with classes and it can't be sensibly mixed with LCL/VCL code because you will loose the size advantage.
35+ * If you are not familiar with the old Object Pascal paradigm from Turbo Pascal the learning curve can be steep.
36+ * You will miss some functionality that has become common place, like RTTI, but most of these features are often codebloat and the reason why KOL exists in the first place.
37+ * Because you are often working on the same object with multiple appearances, it may be confusing that some methods or properties that you can see in the code editor do not apply.
3738
3839## Requirements
3940
40-- Free Pascal compiler 2.6.4 or later for Win32
41-- Free Pascal compiler 2.7.1 or later for Win64
42-- [KOL 3.23 or later](http://f0460945.xsph.ru/rindex.htm) for win32
43-- The Mirror Classes Kit a.k.a. MCK for those who want to develop using a visual designer like Lazarus or Delphi.
44-- [Release preview of KOL 3.23-64](https://yadi.sk/d/Z0uMP31_67nJY) for KOL win32/64
45-- [[KOL-CE|See the KOL CE page]] for win-ce development and requirements.
46-- Not required, but recommended is a copy of FPC's RTL and/or Delphi's RTL sources
41+ * Free Pascal compiler 2.6.4 or later for Win32
42+ * Free Pascal compiler 2.7.1 or later for Win64
43+ * [KOL 3.23 or later](<http://f0460945.xsph.ru/rindex.htm>) for win32
44+ * The Mirror Classes Kit a.k.a. MCK for those who want to develop using a visual designer like Lazarus or Delphi.
45+ * [Release preview of KOL 3.23-64](<https://yadi.sk/d/Z0uMP31_67nJY>) for KOL win32/64
46+ * [[KOL-CE|See the KOL CE page]] for win-ce development and requirements.
47+ * Not required, but recommended is a copy of FPC's RTL and/or Delphi's RTL sources
4748
4849## Supported targets
4950
50-- All 32-bit Windows: from Windows 95 to Windows 8.1.
51-- All 64-bit x86_64 from Windows 2000 to Windows 8.1.
52-- [[WinCE port|Windows CE]] based PocketPC and Smartphones. More information on the [[KOL-CE|KOL CE page]]
51+ * All 32-bit Windows: from Windows 95 to Windows 8.1.
52+ * All 64-bit x86_64 from Windows 2000 to Windows 8.1.
53+ * [[WinCE port|Windows CE]] based PocketPC and Smartphones. More information on the [[KOL-CE|KOL CE page]]
5354
5455## Example
5556
56-Let's illustrate KOL with a simple example. A form, a button and some action. You will notice that the code resembles that of a LCL/VCL application and basically: It does exactly the same! The main difference is the use of objects and pointer to objects instead of classes and the use of constructing functions instead of constructors.
57-
58-Here's the main program file:
57+Let's illustrate KOL with a simple example. A form, a button and some action. You will notice that the code resembles that of a LCL/VCL application and basically: It does exactly the same! The main difference is the use of objects and pointer to objects instead of classes and the use of constructing functions instead of constructors.
5958
60-``` pascal
61- program koldemo;
62- {This line makes us FPC and Delphi compatible}
63- {$IFDEF FPC}{$MODE DELPHI}{$H+}{$ENDIF}
64- {$APPTYPE GUI}
65- uses
66- Kol,
67- koldemo1 in 'koldemo1.pas';
68-
69- begin
70- NewForm1( Form1, nil);
71- Run(Form1.form);
72- end.
59+Here's the main program file:
7360```
61+program koldemo;
62+ {This line makes us FPC and Delphi compatible}
63+ {$IFDEF FPC}{$MODE DELPHI}{$H+}{$ENDIF}
64+ {$APPTYPE GUI}
65+ uses
66+ Kol,
67+ koldemo1 in 'koldemo1.pas';
68+
69+ begin
70+ NewForm1( Form1, nil);
71+ Run(Form1.form);
72+ end.
73+```
7474
75-And here is the main unit, again, you will notice it is very similar to LCL/VCL code:\
75+
76+And here is the main unit, again, you will notice it is very similar to LCL/VCL code:
7677
77-``` pascal
78- unit koldemo1;
79-
80- interface
81- uses
82- Windows, Messages, Kol;
83- const
84- cps:KolString = 'Kol project in ' + {$IFDEF FPC}'Freepascal '{$ELSE}'Delphi '{$ENDIF} +
85- {$IFDEF WIN64}'64 bits '{$ELSE}'32 bits '{$ENDIF} +
86- {$IFDEF UNICODE_CTRLS}'Unicode'{$ELSE}'Ansi'{$ENDIF};
87- type
88-
89- PForm1=^TForm1;
90- TForm1=object(Tobj)
91- {Note both widgets are of the same type}
92- Form, Button:pControl;
93- public
94- {The message handler for our Button}
95- procedure ButtonClick(Sender:PObj);
96- end;
97-
98- procedure NewForm1( var Result: PForm1; AParent: PControl );
99-
100- var
101- Form1:pForm1;
102-
103- implementation
104-
105- procedure NewForm1( var Result: PForm1; AParent: PControl );
106- begin
107- New(Result,Create);
108- with Result^ do
109- begin
110- {The appearance of a widget depends on its creating function}
111- Form := NewForm(AParent,cps);
112- Button := NewButton(Form,'&Click Me');
113- {Attach the MessageHandler}
114- Button.OnClick := ButtonClick;
115- { The applet variable is the Application object
116- Assigning the main form to it assigns the main message loop to the form.}
117- Applet:=Form;
118- Form.Add2AutoFree(Result);
119- end;
120- end;
121-
122- procedure TForm1.ButtonClick(Sender: PObj);
123- begin
124- ShowMessage('Ouch!');
125- end;
126-
127- end.
12878```
129-
130-So what's so special about it? Well, for one, compile this and look at the executable size. A similar program, Form + Button + ShowMessage compiled with Delphi 7 is **394 Kilobytes** and it gets much worse for progressive newer versions of Delphi:2267 Kilobytes XE7-32, 3672 Kilobytes XE7-64. For comparison: the KOL version compiled with D7 is **156** times smaller than the VCL version compiled with XE7.
79+unit koldemo1;
80+
81+ interface
82+ uses
83+ Windows, Messages, Kol;
84+ const
85+ cps:KolString = 'Kol project in ' + {$IFDEF FPC}'Freepascal '{$ELSE}'Delphi '{$ENDIF} +
86+ {$IFDEF WIN64}'64 bits '{$ELSE}'32 bits '{$ENDIF} +
87+ {$IFDEF UNICODE_CTRLS}'Unicode'{$ELSE}'Ansi'{$ENDIF};
88+ type
89+
90+ PForm1=^TForm1;
91+ TForm1=object(Tobj)
92+ {Note both widgets are of the same type}
93+ Form, Button:pControl;
94+ public
95+ {The message handler for our Button}
96+ procedure ButtonClick(Sender:PObj);
97+ end;
98+
99+ procedure NewForm1( var Result: PForm1; AParent: PControl );
100+
101+ var
102+ Form1:pForm1;
103+
104+ implementation
105+
106+ procedure NewForm1( var Result: PForm1; AParent: PControl );
107+ begin
108+ New(Result,Create);
109+ with Result^ do
110+ begin
111+ {The appearance of a widget depends on its creating function}
112+ Form := NewForm(AParent,cps);
113+ Button := NewButton(Form,'&Click Me');
114+ {Attach the MessageHandler}
115+ Button.OnClick := ButtonClick;
116+ { The applet variable is the Application object
117+ Assigning the main form to it assigns the main message loop to the form.}
118+ Applet:=Form;
119+ Form.Add2AutoFree(Result);
120+ end;
121+ end;
122+
123+ procedure TForm1.ButtonClick(Sender: PObj);
124+ begin
125+ ShowMessage('Ouch!');
126+ end;
127+
128+ end.
129+```
131130
132-Compiled with PPC386 it renders an executable of 48128 bytes. Compiled like:
131+So what's so special about it? Well, for one, compile this and look at the executable size. A similar program, Form + Button + ShowMessage compiled with Delphi 7 is **394 Kilobytes** and it gets much worse for progressive newer versions of Delphi:2267 Kilobytes XE7-32, 3672 Kilobytes XE7-64. For comparison: the KOL version compiled with D7 is **156** times smaller than the VCL version compiled with XE7.
133132
134-```text
135-ppc386 -Mdelphi -CX -XX -Xs -Os koldemo.dpr
133+Compiled with PPC386 it renders an executable of 48128 bytes. Compiled like:
136134```
137-
138-Compiled with PPCX64 for Windows it renders 65536 bytes. Compiled like:
135+ppc386 -Mdelphi -CX -XX -Xs -Os koldemo.dpr
136+```
139137
140-```text
138+Compiled with PPCX64 for Windows it renders 65536 bytes. Compiled like:
139+```
141140ppcx64 -Mdelphi -Rintel -CX -XX -Xs -Os koldemo.dpr
142141```
143142
144-The above examples are for an ANSI application. To compile a UNICODE application, simply add the UNICODE_CTRLS define, like:
145-
146-```text
143+The above examples are for an ANSI application. To compile a UNICODE application, simply add the UNICODE_CTRLS define, like:
144+```
147145ppcx64 -Mdelphi -Rintel -dUNICODE_CTRLS -CX -XX -Xs -Os koldemo.dpr
148146```
149147
150-Note that especially for 64 bit, Free Pascal renders consistently smaller code than its expensive cousin. Also note that 32 bit Free Pascal has a slightly bigger runtime payload than its cousin. The size difference disappears when your application becomes more complex.
148+Note that especially for 64 bit, Free Pascal renders consistently smaller code than its expensive cousin. Also note that 32 bit Free Pascal has a slightly bigger runtime payload than its cousin. The size difference disappears when your application becomes more complex.
151149
152150## Tip
153151
154-For size, KOL defaults to an ugly system font. Here are multiple ways to remedy that:
155-
156-``` pascal
157- {Add this code after the NewForm Function}
158- {Release the font}
159- Form.Font.ReleaseHandle;
160- {Assign the default windows GUI font object}
161- Form.Font.AssignHandle(GetStockObject(DEFAULT_GUI_FONT));
152+For size, KOL defaults to an ugly system font. Here are multiple ways to remedy that:
162153```
163-
164-The second method is slightly more involved, but is the [\|MSDN](http://msdn.microsoft.com/en-us/library/windows/desktop/dd144925%28v=vs.85%29.aspx) recommended way:
165-
166-``` pascal
167- {Add this function}
168- function GetGuiFont:TLogFont;
169- var Metrics:TNonClientMetrics;
170- begin
171- Metrics.cbSize := SizeOf(Metrics);
172- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, SizeOf(Metrics), @Metrics, 0);
173- Result := Metrics.lfMessageFont;
174- end;
175- {And call it after the form creation}
176- Form.Font.LogFontStruct :=GetGuiFont;
154+{Add this code after the NewForm Function}
155+ {Release the font}
156+ Form.Font.ReleaseHandle;
157+ {Assign the default windows GUI font object}
158+ Form.Font.AssignHandle(GetStockObject(DEFAULT_GUI_FONT));
177159```
178160
179-Fonts in KOL are objects of type TGraphicTool. This object can also represent pens and brushes. We can also create a new GraphicTool object representing the GUI font:
161+The second method is slightly more involved, but is the [|MSDN](<http://msdn.microsoft.com/en-us/library/windows/desktop/dd144925%28v=vs.85%29.aspx>) recommended way:
162+```
163+{Add this function}
164+ function GetGuiFont:TLogFont;
165+ var Metrics:TNonClientMetrics;
166+ begin
167+ Metrics.cbSize := SizeOf(Metrics);
168+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, SizeOf(Metrics), @Metrics, 0);
169+ Result := Metrics.lfMessageFont;
170+ end;
171+ {And call it after the form creation}
172+ Form.Font.LogFontStruct :=GetGuiFont;
173+```
180174
181-``` pascal
182- {The KOL way to assign the GUI font}
183- function GuiFont:PGraphicTool;
184- var Metrics:TNonClientMetrics;
185- begin
186- Result := NewFont;
187- Metrics.cbSize := SizeOf(Metrics);
188- SystemParametersInfo(SPI_GETNONCLIENTMETRICS, SizeOf(Metrics), @Metrics, 0);
189- Result.LogFontStruct := Metrics.lfMessageFont;
190- end;
191- {We can now assign the new font to the Form's font property}
192- Form.Font.Assign(GuiFont);
175+Fonts in KOL are objects of type TGraphicTool. This object can also represent pens and brushes. We can also create a new GraphicTool object representing the GUI font:
193176```
177+{The KOL way to assign the GUI font}
178+ function GuiFont:PGraphicTool;
179+ var Metrics:TNonClientMetrics;
180+ begin
181+ Result := NewFont;
182+ Metrics.cbSize := SizeOf(Metrics);
183+ SystemParametersInfo(SPI_GETNONCLIENTMETRICS, SizeOf(Metrics), @Metrics, 0);
184+ Result.LogFontStruct := Metrics.lfMessageFont;
185+ end;
186+ {We can now assign the new font to the Form's font property}
187+ Form.Font.Assign(GuiFont);
188+```
194189
195-And this is the result: ![](/wiki-images/0/0f/Kolscreenshot.png)
190+And this is the result: [![kolscreenshot.png](/wiki-images/4/4a/kolscreenshot.png)](</File:kolscreenshot.png>)
196191
197192---
198-*From the Free Pascal wiki, page "KOL", as it stood on 2023-02-04 after a change by Alextp, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
199-Category: Tutorials
193+*From the Free Pascal wiki, page "KOL", as the Internet Archive kept it on 2026-08-06, last changed on 2026-07-17. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history