Delphi and Lazarus
Trekking and Events
Blog and Forum
Čeština English
Main menu
Delphi and Lazarus
Top downloads
KGrid (23598x)
KControls Component Suite (16194x)
KHexEditor (5278x)
KIcon (2584x)
CAN Event Manager (415x)

KControls Component Suite

KControls is a freeware distribution, a flagship of tkweb. It contains all of my published components for Delphi and Lazarus. All controls have been written with the aim to become both cross-IDE compatible (Delphi/C++Builder VCL and Lazarus LCL) and cross-platform compatible in Lazarus. There are some exceptions to this scheme, see below.

Components included
TKGrid - powerfull control for working with table data, replacement for TStringGrid and TDrawGrid - full compatibility and lot of new features
TKDBGrid - control for working with database tables, possible replacement for TDBGrid
TKMemo - native replacement for TMemo/TRichEdit - written from scratch, great features, full RTF support etc.
TKHexEditor - another useful control for binary file editing
TKIcon - powerfull component for working with icons and cursors (files *.ico and *.cur, works only on Windows)
TKPrintPreview - control for displaying print preview, it is part of KControls built in printing capabilities, every visual control supports printing and previewing
TKPrintPreviewDialog - nonvisual component - dialog - for an easy print preview implementation
TKPrintSetupDialog - nonvisual component - dialog - for an easy implementation of printing preferences
TKCustomControl - a base for your visual controls, for which you want to implement e.g. printing and previewing capabilities in Delphi or Lazarus (just 2 short functions to write).
TKNumberEdit - edit control to input numbers in various formats
TKFileNameEdit - edit control to input file names
TKLinkLabel - label to show clickable link
TKGradientLabel - label with gradient background
TKLog - component for event logging
TKPercentProgressBar - custom drawn progress bar which shows actual percentage of the progress
TKBrowseFolderDialog - wrapper for the standard Windows API browse for folder dialog (works only on Windows)
TKBitBtn - like TBitBtn - draws PNG and alpha channel correctly in Delphi, has WordWrap property, works in Lazarus as well
TKColorButton - just another button to pick color
TKPageControl - page control written from scratch with custom painted tab panel, has tab icons and close button icon


KControls is provided free on 'as is' basis, with complete source code. However, it is licensed software. More information about license can be found in source file headers.

All controls support Delphi and Lazarus IDEs fully. But there are some exceptions: TKIcon and TKBrowseFolderDialog work only on Windows and printing and previewing might not work in some widgetsets in Lazarus.

Note about cross-platform development in Delphi: I strongly disagree with the way Embarcadero took with the FMX library to allow cross-platform development, so FMX will never be supported. As Lazarus has become very good IDE, in many aspects better than Delphi, I recommend you try it if you need cross platform features.


If you want to donate for further development of KControls just think about building your own photovoltaics and using the WATTrouter device produced by our company. You will save lots of energy and it will be the best donation to me you can make!

Screenshots (click the images to enlarge)

KControls components (Windows Vista)KControls components (Windows XP/GTK2runtine)
KMemo rich text editor showing the KMemo manual.KMemo rich text editor showing more complex sample RTF document.

Repository - development versions

You may now download newest development version at bitbucket. But be careful! These versions are mainly tested in Delphi XE where our main development is still ongoing!

Downloading KControls

Important note: When installing the packages in Delphi XE2 and later you must add "Vcl;Vcl.Imaging" to Unit Scope Names in Delphi Options/Library! Otherwise the packages won't compile!

FileVersionNumber of
Available for:Changes
kcontrols_1.7.zip1.73826Delphi 7+,Lazarus 1.2.2+, C++Builder 2007+support for RAD Studio XE8, major work on TKMemo which is already usable, bugfixes...
kcontrols_1.6.zip1.62574Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+support for RAD Studio XE6, Columns property in TKDBGrid, bugfixes...
kcontrols_1.5.zip1.5328Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+new components TKMemo, TKBitBtn, TKColorButton, some bugfixes...
kcontrols_1.4.zip1.4969Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE3-XE5, new components etc.
kcontrols_1.3.zip1.32695Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE2
kcontrols_1.2.zip1.23060Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+cumulative update (KGrid 1.7, KHexEditor 1.5, KIcon 2.2)
kcontrols_1.1.zip1.11073Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+cumulative update (KGrid 1.6, KHexEditor 1.4, KIcon 2.1)
kcontrols_1.0.zip1.01669Delphi 6+,Lazarus 0.9.29(SVN#21827)+initial release (KGrid 1.5, KHexEditor 1.4, KIcon 1.9)

If you have a question you may ask below and I will probably answer it, after some time.


Home | Software | Delphi and Lazarus | Trekking, travelling | Sport | Blog

Search in comments: 
inserted: 2016-09-06 22:07:35   Reply...
From: krzynio
Lazarus 1.7 (svn 52880M) GTK2 FPC3.0.0
Cannot compile: kmemortf.pas(4030,10) Error: Identifier not found "UTF8Copy"
Can you help, please?
inserted: 2016-09-20 09:36:45   Reply...
From: tk
Ok, you can use my today's commit, it should compile fine with your 1.7. I've replaced the obsolete UTF8 functions from LCLProc with equivalents from LazUTF8. The UTF8 functions were not removed from LCLProc yet, but apparently will be in the future. See
inserted: 2016-09-07 21:48:57   Reply...
From: tk
I don't have this version (been using the official 1.6) but someone probably removed the function from LCLProc.pas. It was marked as deprecated. Changes in KControls will be made first when it does not compile with the official stable release.

Solutions for now:
1) Either use a Lazarus version which has the function.
2) Or take the missing functions from previous versions of LCLProc.pas.
3) Or file a bug report and demand the obsolete functions to be returned to LCLProc.pas.
inserted: 2016-08-25 13:59:45   Reply...
From: inform
we just start to use KGrid and it works good for us. We use it as a replacement for TDrawGrid.

During the replacement process we found some points to enhance the compatibility with VCL and we have an suggestion about an enhancement (including source).

Is there any way to contact you directly by E-Mail?
inserted: 2016-08-30 21:11:01   Reply...
From: tk
Did you send the email? I am asking because I experienced some problems with this email account few days ago. Now it seems to work fine.
inserted: 2016-08-25 15:33:44   Reply...
From: tk
Yes use the email you see in the source headers.
inserted: 2016-07-11 18:22:10   Reply...
From: HexUser

I see that there are exactly the first 25 MB loaded.
It happens both with x86 and x86_64 compiler in Lazarus 1.6.0
inserted: 2016-07-19 18:57:26   Reply...
From: tk
With my new commit even files > 4GB should open fine (when compiled with 64-bit compiler). Tried with 64-bit Lazarus. However, the editor has no paging mechanism. Loading & saving is very slow and working with the file is not very fast either.
inserted: 2016-07-18 13:53:36   Reply...
From: tk
KHexEditor is not ready to open big files. Although I am able to open files as large as you mention (when compiled with 64-bit compiler) there is unpredictable behavior due to miscellaneous arithmetic overflows. The reason for these are the Integer/Cardinal types used everywhere in the control, which are always 32 bit wide.

The control would need some work to handle big files correctly.
inserted: 2016-07-11 18:15:19   Reply...
From: HexUser
I have a Problem, when I load large Files in the KHexEditor.

The example-file with 4.02 GB normaly ends at
0x101993FF9, but in the Hex View only a first part until
0x001993FF0 is loaded.

Is this a known Issue? Is there a fix or workaround?
inserted: 2016-06-14 06:33:29   Reply...
From: RobV
Hi Tk,

How I get the exact position or rect of an container (table) ?

when I evaluate two tables the second seems to display corresponding to the correct position:

  for I := 0 to LineCount - 1 do
        J := FLines[I].StartBlock;
        Item := Items[J];
        if item is TKMemoContainer then begin
          x:=TKMemoContainer(item).BoundsRect.Bottom ;


inserted: 2016-06-14 06:39:31   Reply...
From: RobV
sorry .. the observation that wanted to do is

...the position of a second table on the same page appears not correspond to its correct position.
inserted: 2016-06-15 14:05:44   Reply...
From: tk
Well I don't understand this either, has it sth. to do with the print&preview issues which we've discussed below? If yes you might try the current repo download. For tables, I made page breaks to ensure table rows will be shown on next page if they don't fit to current page.
inserted: 2016-06-15 17:33:20   Reply...
From: RobV

hi tk,

I found that this latest version you fixed the texts that were not being displayed correctly when the page change.

But in the example file
 the text after the second table is not displayed neither the first nor the second page. For you to evaluate this inconsistency this file must be loaded in the example of the program KMemoEditorLaz.

inserted: 2016-06-15 21:34:25   Reply...
From: tk
Hmm, you're right! Still bugs there in TKMemoBlocks.GetPageCount and GetPageData. I'll fix them tomorrow.
inserted: 2016-06-15 17:48:21   Reply...
From: RobV


inserted: 2016-06-15 21:54:51   Reply...
From: tk
Btw. the font in the document seems to be invalid. Lazarus LCL clearly understands the font name 'default' but Delphi VCL does not. And Word does not either. How did you get this font there?
inserted: 2016-06-16 13:02:21   Reply...
From: RobV
the texts off the table were produced by typing in your sample program "KMemoEditorLaz" (propertie font=Tahoma DEFAULT_CHARSET size 8)
compiled in lazarus 1.6 windows 10 pro version 64bits. The two tables have been copied with clipboard from example 13 "KMemoDemo.exe"
inserted: 2016-06-16 13:05:24   Reply...
From: RobV
the file "teste.rtf" was saved using kMemoEditorLaz.
inserted: 2016-06-16 13:30:44   Reply...
From: RobV
the problem of supply becomes evident when you begin to suspect the copy to kmemo clipboard which is another problem or bug even be repaired.
The reported issue is about texts or tables that should go out on the next page and are not displayed because of the two routines that you have mentioned.
the problem remains in other examples see
inserted: 2016-06-17 01:13:44   Reply...
From: RobV
with commit e44a8bcdfc4a this works fine.

inserted: 2016-06-12 09:47:43   Reply...
From: Whisper
I select a grid: N-col and M-row. How I can mark all grids of the same row? I've tried differents methods without any success. Any help code?

Thanks in advanced
inserted: 2016-06-13 20:22:29   Reply...
From: tk
Don't understand, please specify exactly what you want to do.
inserted: 2016-06-14 16:56:01   Reply...
From: Whisper
Hi tk!
For example. I have this kgrid (picture 1)
The position of cursor/mouse is inside of the grid with "light grey" color (picture 1 and 2). I would like that all grids, in the same row, where the mouse is, are in the same "light grey" color (picture 3).

I check the first checkbox (picture 4), and then, it should be mark the rest of checkboxes of first col.

picture 1->

Thanks for your interest
inserted: 2016-06-15 10:46:20   Reply...
From: tk
To select entire line use goRowSelect, like in normal Tstringgrid.
To show all checkboxes checked or unchecked according to some condition you need some custom code in OnDrawCell. Here to draw the checkboxes in checked/unchecked state according to the first checkbox state. Use property TKGridCellPainter.CheckboxChecked for this. Then, you would need to call TKGrid.InvalidateCol when the first checkbox state is clicked and this will redraw entire column.
inserted: 2016-06-17 09:47:34   Reply...
From: Whisper
Thanks for your tips. I've fixed the ISSUES!!

inserted: 2016-06-12 03:42:02   Reply...
From: abdel
Hi tk.
many thanks for your great work!!! Can you add support for Arabic language to kmemo please...
inserted: 2016-06-13 20:21:13   Reply...
From: tk
Well, it is hard to make sth I don't understand. Maybe some Arabic speaking contributor could...
inserted: 2016-06-06 18:14:02   Reply...
From: RobV
hi tk,

this function
function RectInRect(Bounds, Rect: TRect): Boolean;
  Result :=
    (Rect.Left < Bounds.Right) and (Rect.Right >= Bounds.Left) and
    (Rect.Top < Bounds.Bottom) and (Rect.Bottom >= Bounds.Top);

was produced to check if the rect rectangle is within (or is internal to) the bounds rectangle or has another meaning?

(I question this because geometrically the
Rect.Bottom> Bounds.Bottom is not true)


inserted: 2016-06-06 22:13:03   Reply...
From: tk
There are two similar functions in KFunctions.pas. The function RectInRectFully probably does what you need. I remember only I needed both.
inserted: 2016-06-05 17:54:23   Reply...
From: RobV
I downloaded the bitbucket the latest version after your last commit 795e924
and I made the following adjustments and incorporated in the latter commits

I create only more one variable "isPrinting" incorporated into the object
TKPrintPageSetup and added it in 3 procedures of this object all of unit kcontrols

in unit kmemo, was only necessary to replace the procedure
TKMemoBlocks.PaintToCanvas of object TKMemoBlocks only that.

this repair is that routine that had developed and is now reduced in this
setting that prevents the last lines of each page to be printed or displayed
correctly. Only that.

i generate the file "adjustmentsKControl05062016.txt" that
containing the summary of the above adjustments

this works fine and is linked here

inserted: 2016-06-06 22:08:29   Reply...
From: tk
Hi, your patch works perfectly but only when there are no tables and other nested blocks. So I cannot apply your patch to the main trunk now because we heavily use KMemo tables in our projects (with print&preview). I'll soon solve the issue with truncated lines on page breaks and possibly also the preview scaling glitch. Until then please keep your modification if it works for you. It is a good reference for me as well where to start.
inserted: 2016-06-06 23:16:08   Reply...
From: RobV
hi tk,

as I perform a test to see if the line (text) is used for a table?

for example "if linebottom [i] is Table ...." (or another argument)
inserted: 2016-06-07 00:01:02   Reply...
From: tk
You should obey the principle of nested blocks by adding new virtual method chain to TKMemoBlock/TKMemoBlocks to inspect line rectangles including the nested ones. This is my idea now. For tables perhaps there should be page break before a row that does not fit anymore because text lines might end at different Y positions in each cell. I got most inspiration how Word and LibreOffice does this. Yes it is not so easy to understand this at first glance. And it is not easy to make any changes in KMemo for new people because word processing is not easy task and KMemo uses specific techniques. Plus then testing on at least 3 Delphi versions + Lazarus. But despite that useful contributions are welcome:-)
inserted: 2016-06-06 23:46:23   Reply...
From: RobV
The good news is that the adjustment that had done previously, the construction was carried out in TKCustomMemo.PaintPage and correctly display the table. Check here this executable:

When modified and simplified I transferred to the TKMemoBlocks object (which does not validate table).

I'll see if I can see the point that obstructs the table or else redo the previous routine and then put the patch.

in previous:

  if (Blocks.LineBottom[I] + ATop >= TmpRect.Top) and
  (Blocks.LineTop[I] + ATop + (Blocks.LineBottom[i]-Blocks.LineTop[i]) < TmpRect.Bottom) then
        begin .....

in the current code:

      if (LineBottom[I] > xTop) then begin ...

inserted: 2016-06-08 21:52:22   Reply...
From: tk
I've made some changes to KMemo Print&Preview today. It should already work as you would expect. Needed quite many modifications.
inserted: 2016-06-07 00:05:02   Reply...
From: tk
Nope. Does not work for me.
inserted: 2016-05-31 01:47:50   Reply...
From: RobV
hi tk,
how could copy a preview page to bitmap?

(I tried but half of the page appears in black)

inserted: 2016-05-31 09:42:04   Reply...
From: tk
I don't know, never been using this. The print preview has not been designed that way, but iirc the components themselves have the PaintToCanvas method which could be used with any canvas.
inserted: 2016-05-31 11:15:23   Reply...
From: tk
Maybe TKPrintPreviewForm.preview.PaintTo used with Bitmap.Canvas.Handle would work. Never tested this however. Lazarus has an overloaded PaintTo that can be used with Bitmap.Canvas directly.
inserted: 2016-05-31 23:11:56   Reply...
From: RobV
his suggestion did not work.
Under a situation that works with memo.blocks.paintToCanvas

procedure TKMemoFrame.SpeedButton3Click(Sender: TObject);
var bm:TBitMap;
  editor.canvas.Refresh ;
  SaveIndex := SaveDC(editor.canvas.Handle);
  bm.Width:= editor.Width ;
  bm.Height:= editor.Height+1500 ; //i.e. 1500 or more
  r:=rect(0,0,bm.Width ,bm.Height );
  Bm.Canvas.Brush.Color := clWhite;
  editor.Blocks.PaintToCanvas(bm.canvas,0,0,r) ;
  RestoreDC(editor.canvas.Handle, SaveIndex);
  editor.canvas.Refresh ;

inserted: 2016-06-01 14:40:48   Reply...
From: tk
Hmm, interesting. Why would you need to copy this to a bitmap? Some Making some screenshot?
inserted: 2016-06-01 17:00:26   Reply...
From: RobV
also logically it serves a screenshot. What worries me is with users of a text editor that will not like the preview that exists today in kmemo. This is because a different scale of 100%, the screen canvas is different from the printed canvas and so they will complain. A preview of 100% displayed is gigantic and therefore this will not practical for a user of an application.
So I am studying a way to treat via emf (initially tested now with bitmap). But I know that Lazarus has nothing ready/write in emf. In the unit kcontrol in the graphic unit, I saw that there metafile object, but do not know if it is functional.
inserted: 2016-06-01 21:03:11   Reply...
From: tk
Try new snapshot from bitbucket. I've implemented a custom variant of TKPrintPreview.PaintTo. How to use it is shown in KMemoDemo example, method Test25. Works now both in Delphi and Laz.
inserted: 2016-06-02 15:51:09   Reply...
From: RobV
ok the screenshot works fine!

but do you know any way to reduce the display in preview of
ratio of 100% as in normal editors?
inserted: 2016-06-02 16:42:09   Reply...
From: tk
TKPrintPreview has Scale and ScaleMode properties that allow custom scaling, the combo on print preview form uses these.
inserted: 2016-06-02 22:50:51   Reply...
From: RobV
1) when the user chooses
ScaleMode = smScale and scale = 25%,75%....500% (exept 100%) or ScaleMode=smWholePage or
ScaleMode = smPageWidth
the page content appears in screen canvas appears in a different position of the printer canvas

2) when the user chooses ScaleMode = smScale and scale = 100%
the page content in screen canvas appears in the same position the printer canvas, only with the use of that reparative code posted to you via link.

The problem is that with scale = 100% the text or content is displayed on screen canvas as very large , hindering navigation

for example, the components for Delphi, TRichView, TextControl, DevExpress, or any wordprocessor, the scale = 100% is displayed in the normal almost equivalent to scale = 75% of KControl but if you use it, you will have problems with printing in different positions as reported.
Once solved this issue, it will be the component that meet "initial" conditions for a word processor, for Lazarus, distancing even more of richmemo component.

Today, the only strong point of richmemo on Kmemo is the zoom property that works in normal editing text.

inserted: 2016-06-03 14:56:54   Reply...
From: tk
To be honest I don't understand what is the problem. I cannot reproduce any differences between preview and print (tested on a PDF printer now).
Yes 100% preview is now bigger than in other programs (I don't consider this a bug because it now maps printer resolution to desktop resolution 1:1, it might be configurable in future however to consider DPI even here).
And of course there is LOT of work to do on this component.

Because this forum does not accept images you could perhaps open a thread for this on Lazarus forum.
inserted: 2016-06-03 15:42:10   Reply...
From: RobV
Hi tk

 see in

 (with your last version of kmemo)
inserted: 2016-06-03 22:10:58   Reply...
From: tk
Aha, this I don't take as bug by far:-) Is only small glitch...
Please don't take TKMemo as replacement of TRichView or any other fully fledged component, is not meant to be, maybe sometime in VERY distant future...
inserted: 2016-06-05 16:58:40   Reply...
From: RobV
my expectation with kcontrols is good just to be part of lazarus what other referenced components are not part. It is necessary to go through time to evolve. In the code free nothing is ready, and programmers
They work harder. This brings evolution to those who participate!
inserted: 2016-06-03 15:49:17   Reply...
From: RobV

you could tell me where considered a property to desktop resolution 1: 1? (So I can understand better)

inserted: 2016-05-26 04:09:19   Reply...
From: Бегемот
Nice try but it won't work with RX10 Seattle.
inserted: 2016-05-26 20:33:37   Reply...
From: tk
The repo download should work already, although I didn't test this myself.
inserted: 2016-05-27 03:57:45   Reply...
From: Бегемот
Nope. The package installs with no components. Maybe Win10 is the cause...
inserted: 2016-05-27 10:32:47   Reply...
From: tk
Hmm, was contribution from another user. Maybe the package for D10 is corrupted. The ever soaring prices for Delphi are the cause that I haven't tested this myself yet. I/we won't buy Delphi anymore, will entirely migrate to Lazarus. But I'll at least download the evaluation and try this package myself.
inserted: 2016-05-27 10:56:49   Reply...
From: tk
Will test only the new Berlin release.
inserted: 2016-05-27 12:29:01   Reply...
From: tk
Tested now on 10.1 and modified also the Seattle packages a little. The run time package was corrupted, missing the KDBGrids.pas file. For some reason I had to add path to sources to the design time package dproj files, don't know why Delphi suddenly did not find the res files etc. when compiling design time package. Things that worked fine all the time don't work anymore:-( Seems that the new Delphi versions are not only more and more expensive, but even worse and worse.

I still have W7 but the programs we create with KControls run on W10 normally.
inserted: 2016-05-23 16:06:38   Reply...
From: RobV
Hi Tk,

I believe you will like to see these settings in the preview of kmemo (only).
I Fix so that the texts were not being displayed properly when the page
changes, both in preview and in printOutput. Modifications incorporated,
sought comment with "//Adicionei"

I posted the link below for you to download (I will leave a few days)

I could not make all text displayed in the preview,
is exactly the same position when printed (eg pdf creator,
Microsoft print to pdf or HP printers).
This is for you to know quite the windows api.

The result is that the kmemo is approaching an
WYSIWYG editor

The next step is to place a ruler in this editor
inserted: 2016-05-24 09:15:12   Reply...
From: tk
Thank you but could you modify the newest repository snapshot and send me the patch? This way I am unable to apply your contributions to the main trunk.
inserted: 2016-05-24 15:53:48   Reply...
From: RobV
I do not know the latest repository. What is it?
inserted: 2016-05-25 10:59:15   Reply...
From: tk
See above, the link to BitBucket. Please go there and download current repo snapshot. Implement your modifications there. I/We must review each contribution thoroughfully to avoid some problems in our projects.

After a short review of your modifications I have following notes:

Please avoid old fashioned constructs like:

  PLinkNP = ^AListNP; //Adicionei*
  AListNP = record //Adicionei*
    I:integer; // = line
    Value:integer;// = page

  PLinkTop = ^AListTop; //Adicionei*
  AListTop = record //Adicionei*

Instead of these use classes and object lists (because of compatibility with old Delphi versions use normal object lists with custom getters and setters, see the many helper classes in kmemo.pas for reference).

Also please ALWAYS avoid using global variables!

  linkPagePrev: Integer;//Adicionei*

This way the {$WEAKPACKAGEUNIT ON} directive would not work in Delphi! Rather than that use some helper classes for this and instantiate them directly in TKCustomMemo class (or whenever you use it)!

Also please avoid commented out code chunks when possible.

Thank you
inserted: 2016-05-25 17:22:30   Reply...
From: RobV
I did so (temporary) because they do not know with certainty the structure of objects in kcontrol. The primary objective was to test what was inconsistent. (I'm new here ok?) Anyway I appreciate your guidance and few know its structure, will have conditions
to incorporate in existing objects.

tk: what is the reason of a plain text is displayed in a position (preview canvas), different from what is printed (printer canvas)? Where (procedure / functions) you suggest I can step up testing to try to hunt this inconsistency?

inserted: 2016-05-26 20:03:22   Reply...
From: RobV
tk: in the lazarus (because I am avoiding using the Delphi)
I tested considering {.$DEFINE KMEMO_DISABLE_KERNING} whether the texts are now displayed in the screen canvas as the printer canvas that is ok!

you'd better clarify the reason for this occurrence since the file the question is about speed and not text display position.
inserted: 2016-05-26 20:31:26   Reply...
From: tk
I remember having problems with kerning pairs when testing under Linux Kubuntu. That's the reason for this directive, the problem was IMO not in Lazarus but in underlying GTK engine.
inserted: 2016-05-21 00:15:36   Reply...
From: iru
Could you please explain the relationship between CELL, CELLS and COLUMN/S?
I am having troubles with "column" display widths when I use "KDBGrid.Cells[0, ?] := 'xxx'. How can I control the "CELL, ""COLUMN"width?
inserted: 2016-05-21 02:06:52   Reply...
From: iru
On a closer look the problem is not the width of the displayed columns but that some columns overlap others. For example, if I have a grid with 10 columns and perform the following:
  For i := 2 to 5 do
    KDBGridLap.Cells[i, 0] := 'Lap ' + IntToStr(i);

The display is: Col0|Col1|L|L|L|Lap 5|Col6...... (where Col0/1/6 are "normal" columns).
inserted: 2016-05-22 14:22:46   Reply...
From: tk
Don't understand what you're up to. You're assigning values to Cells in a DBGrid? But that's IMO generally wrong unless I miss sth. In KDBGrid cells are automatically filled with data from the data set and your values get overriden on next data update event!

To adjust column widths use ColWidths property or the Columns[x].Extent property at design time. At runtime Cols[x] is quite equal to Columns[x] (Cols is just shorter variant for Columns).
inserted: 2016-05-24 12:37:03   Reply...
From: iru
Apologies about KDBGrid, should have been KGrid.

I have been looking at KGrid source and pottering with my code.
Issuing KGridLap.Cols[vCtr].MinExtent := InSize (where InZize is 55,just longer than the size of something like 'Lap 12.0') seems to resolve things.

Thank you for your response, Ian
inserted: 2016-05-29 12:57:53   Reply...
From: iru
Some more this. Setting KGridLap.Cols[vCtr].MinExtent solved the problem once.

Run some code, the column widths are OK, columns are visible.
Run the same code again and the columns are in-visible.
Run the same code again and the columns are OK, columns are visible.

I have put traces in the KGrid code and have been able to work out where things start to go wrong.

I have inserted some ugly code at the start of Kgrid.SetVisible as follows:
    FBackExtent := 0;
    Extent := 64;

Ugly but it fixes the display.

I think it will take me some time to sort this out.With your experience with KGrid it may be simple.

The application is small and self contained. Is there some way I can send it and usage instructions?

Thanks, Ian.

inserted: 2016-05-31 09:30:46   Reply...
From: tk
Thank you for the example but it cannot be loaded. Lazarus reports: Unable to find the component class "TLEDNumber"... It is needed by unit:...frmmain.pas.
inserted: 2016-05-31 09:45:18   Reply...
From: tk
Was the missing industrial package (my Laz strangely reported the missing package only when compiling, not when loading the project).

But there are another errors when compiling:
Compile Project, Target: LS.exe: Exit code 1, Errors: 8, Hints: 1
frmmain.pas(158,3) Note: Local variable "vTime" not used
frmmain.pas(266,12) Error: Identifier not found "vSList"
frmmain.pas(285,12) Error: Identifier not found "vSList"
frmmain.pas(307,22) Error: Identifier not found "vSList"
frmmain.pas(341,27) Error: Identifier not found "vSList"
frmmain.pas(342,27) Error: Identifier not found "vSList"
frmmain.pas(393,4) Error: Identifier not found "DataModuleDB"
frmmain.pas(393,36) Error: Identifier not found "DebugIni"
frmmain.pas(393,61) Error: Identifier not found "DebugIni"
inserted: 2016-05-31 10:09:58   Reply...
From: tk
Ok, run it on Win, had to add the vSList to kgrids.pas and comment out the line:
DataModuleDB.DM.AppName := Copy(DebugIni, 1, Pos('.INI', DebugIni)-1);

Then I could find the problem.


Procedure UpdateVis(InCol : Integer; InNumber : Integer; InState : Boolean);
    vCtr :Integer;
    For vCtr := InCol to (InCol + InNumber - 1) do
      if InState then
        KGridLap.ColWidths[vCtr] := KGridLap.DefaultColWidth
        KGridLap.ColWidths[vCtr] := 0;

Don't use Cols[x].Visible because it is known to be somewhat buggy. Also you should use ColCount instead of this to specify column count. This will avoid hidden columns.
inserted: 2016-05-30 22:33:22   Reply...
From: tk
Well, I still don't understand what is the problem. I don't use MinExtent properties so there might be bug. Please create a simple app that demonstrates the problem and send it to the email provided in source headers.
Thank you
inserted: 2016-05-31 23:56:21   Reply...
From: iru
Thank you for your response and your work. Apologies for the missing components/errors in the code. Must be strange things in my LAZ IDE.

All fixed, problem solved.
Thanks once again, Ian
inserted: 2016-05-14 03:10:52   Reply...
From: RobV
Hi tk,
to add single image from clipboard

function TKMemoBlocks.AddImageBlockFromClipBoard(At: Integer): TKMemoImageBlock;
var pic : TPicture;
     Jpg : TJPEGImage;


  if (Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap))) or

  (Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap))) then begin

    Result := TKMemoImageBlock.Create;

    pic:=TPicture.create ;

    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap)) then



    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap)) then


     Jpg := TJpegImage.Create;
       Jpg.Assign(pic.Graphic );

       AddAt(Result, At);



inserted: 2016-05-15 05:42:43   Reply...
From: RobV
small adjustment to copy the contents of clipboard to exact location of the cursor positioned

function TKMemoBlocks.AddImageBlockFromClipBoard: TKMemoImageBlock;
var pic : TPicture;
     Jpg : TJPEGImage;


  if (Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap))) or

  (Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap))) then begin

    Result := TKMemoImageBlock.Create;

    pic:=TPicture.create ;

    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfDelphiBitmap)) then



    if Clipboard.HasFormat(PredefinedClipboardFormat(pcfBitmap)) then


     i:= Count ;

     Jpg := TJpegImage.Create;
       Jpg.Assign(pic.Graphic );

       AddAt(Result, i);




procedure TForm1.SpeedButton1Click(Sender: TObject);
  Stream: TMemoryStream;
  S: TKString;
  IB: TKMemoImageBlock;

    IB := KMemo1.Blocks.AddImageBlockFromClipBoard;
    if ib=nil then ib.Free
    else begin

     i:=kmemo1.blocks.Count-1 ;
     kmemo1.Blocks.Items[i].SelectAll ;

      S := kmemo1.ActiveBlocks.SelText;
      Stream := TMemoryStream.Create;
        kmemo1.SaveToRTFStream(Stream, True);
        Stream.Seek(0, soFromBeginning);
        kmemo1.LoadFromRTFStream(Stream, kmemo1.RealSelEnd );

      kmemo1.ActiveBlocks.ClearSelection(false) ;



inserted: 2016-05-22 14:10:04   Reply...
From: tk
Thank you.
inserted: 2016-05-13 15:29:51   Reply...
From: Woj
When I use kPrint in preview I see only records which are visible on the screen, other records are empty.
But when I scroll down in kdbgrid these records appear. Earlier I used dbgrid.datasource.dataset.last function to bypass problem, but now I have more records (abaout 500) and this trick doesn't work. Could you tell me what can I do to solve this problem?
inserted: 2016-05-14 13:51:04   Reply...
From: tk
The preview shows only currently loaded rows/records from the dataset. It does not load new records like when scrolling the grid. If you want to show all records in the preview then you must somehow load them into the grid. You can try new method LoadAllRecords that simplifies that task for KDBGrid, see the repo.
inserted: 2016-05-15 21:49:37   Reply...
From: Woj
It's what I've been looking for, thank you very much.
inserted: 2016-05-04 14:28:59   Reply...
From: HexUser
Is it possible to group only 2 Hexchars in the KHexEditor, for viewing full Bytes (8 Bit)?
inserted: 2016-05-09 10:58:33   Reply...
From: tk
Yes, use DigitGrouping property.
inserted: 2016-05-09 15:01:27   Reply...
From: HexUser
inserted: 2016-05-04 12:07:44   Reply...
From: Whisper
I've got a problem with Kgrid.
I'm doing an application and If I add the following code to the event "DrawCell" (Resultados is the kgrid type).

the code is for formatting the cells
procedure TBuscaDu.ResultadosDrawCell(Sender: TObject; ACol, ARow: Integer;
  R: TRect; State: TKGridDrawState);
   Resultados.CellPainter.Text := Resultados.Cells[ACol, ARow];
   if (ARow > 1) and (ACol >= 3) then Resultados.CellPainter.HAlign := halRight;
   if (ARow = 0) and ((ACol = 3) or (ACol = 4)) then Resultados.CellPainter.HAlign := halCenter;
   if (ARow = 0) and (ACol >= 1) then
         Resultados.Font.Size := Resultados.Font.Size+10;
         Resultados.Font.Bold := TRUE;
   if (ARow = 0) and (ACol >= 1) then
         Resultados.Font.Size := Resultados.Font.Size-10;
         Resultados.Font.Bold := FALSE;

Kgrid blocks the red button to finish the aplication. I can NOT close/terminated the aplication

Is it a bug?

PD: I've uploaded a simple test project where you can see the problem. If you press the NEW button, Kgrid show up and now if you push the closed/finish red button, it doesn't work properly.!3QMm1Jha!PpUKtWYSG_-wTj68NftlpoUtSyv3HSouwOCYM9CQj8w
inserted: 2016-05-06 12:37:38   Reply...
From: Whisper
Fixed the issue:

if I change:

Resultados.Font.Size -> Resultados.CellPainter.Canvas.Font.Size

The same for the rest of code
inserted: 2016-05-16 09:55:16   Reply...
From: tk
You should only access Resultados.CellPainter.Canvas.Font in OnDrawCell, not Resultados.Font.
inserted: 2016-05-02 13:57:24   Reply...
From: CrazyDron
Good day!
I have installed v1.7 of KControls and using Win7 x64.

After creating new project and adding onto form control TKGrid - it compiles normal.

But when I set options of project to:
1. Target OS: WinCE
2. Target CPU: arm

compilation stops at unit CairoCanvas and says
cairocanvas.pas Fatal: Cannot find unit Cairo, used in CairoCanvas of package cairocanvas_pkg.

(Remark: units Pango, PangoCairo, GLib2 are not founded too).
What should I do?
Thank you.
inserted: 2016-05-02 21:04:30   Reply...
From: tk
I think your Lazarus installation or build configuration is corrupt under Linux or not ready for cross compiling. I am not expert here. Please search or ask on Lazarus forum There are many clever people that might be able to help you.
inserted: 2016-05-03 08:05:17   Reply...
From: CrazyDron
Thank you, and my apologizes about not refining that I write in Lazarus.

My Lazarus installation is Win32+cross_arm_ce.
I write big project for WinCE/arm, and it compiles and works perfectly. But all this is on standard installation, external components is only KControls.

Maybe this information help you (and me too :D ).

inserted: 2016-05-03 12:16:45   Reply...
From: tk
Well, I don't have this installation so I am not able to help you. Generally I've always tested only on Win or Linux, x86 or x64. I don't even know if KControls works in other widget sets.

Please ask on Lazarus forum about this error.

inserted: 2016-05-01 16:13:28   Reply...
From: Whisper
I have a problem with Kgrid and CheckBox.

I add checkboxes to col 0 (the first of the left side) in kgrid with the code:

procedure TBuscaDu.ResultadosDrawCell(Sender: TObject; ACol, ARow: Integer; R: TRect; State: TKGridDrawState);
   if (ACol = 0) and (ARow > 0) then
        Resultados.CellPainter.CheckBox := TRUE;
        Resultados.CellPainter.CheckBoxHAlign := halCenter;
        Resultados.CellPainter.CheckBoxState:= cbchecked;
(Resultados is the kgrid type)

but I don't know how i can change the state from the cbchecked to cbUnchecked from one of the checkboxes with click of mouse (I make a click, but it doesn't change) and how I can detect if the user change the checked state.

Thanks in advanced
inserted: 2016-05-02 21:00:34   Reply...
From: tk
You have to instantiate a TCheckBox as inplace editor. Look in the demo how to do that.
inserted: 2016-04-28 22:53:56   Reply...
From: RobV
I tested now and that may be a temporary solution would prevent any table comes in first line, always enter a container block like this:

  TBL: TKMemoTable;
  CO: TKMemoContainer;
  CO := KMemo1.Blocks.AddContainer;
  CO.Position := mbpRelative; //important
  CO.RequiredWidth := 3;

  TBL := KMemo1.Blocks.AddTable;
  TBL.ColCount := 2;
  TBL.RowCount := 2;
  TBL.Cells[0, 0].Blocks.AddTextBlock('Table text 1');
  TBL.Cells[0, 1].Blocks.AddTextBlock('Table text 2');
  TBL.Cells[1, 0].Blocks.AddTextBlock('Table text 3');
  TBL.Cells[1, 1].Blocks.AddTextBlock('Table text 4');
  TBL.CellStyle.BorderWidth := 1;

after 15 years I am migrating from Delphi to Lazarus and user from TRichView am evaluating your (good component) for probable replacement. Do you consider the stable and consider if you or someone already use for at least 03 years?

grateful for the attention

inserted: 2016-04-29 12:01:19   Reply...
From: tk
Don't fully understand the question but KMemo should be already reasonably stable. Of course there are still important features missing as the readme states. These will be gradually implemented when I or one of the contributors have time. Now highest priority is Undo/Redo and image editing tools.
inserted: 2016-04-28 21:53:14   Reply...
From: RobV
let's see if I understand you:
once the table is created, even the way you suggested, put a block before, after this if the user navigates to the first line of kmemo1, and repeatedly typing Delete the table created will position the first line of kmemo1. OK ? So far of course, but what is not correct is that after that I can not move again this table again for any line below! Exactly this is the point. What to do or stop so that this does not happen?
Otherwise you could tell a simple example of your solution?

----->first line (create with i.e. TB := KMemo1.Blocks.AddTextBlock('Hello world!')
 _____ _____ -----> second line with table
! !
! !

after these in first line the user press some key delete:

 _____ _____ -----> first line (of memo) with table
!x !
! !
after this kmemo does not allow the user move this table (this is the point)

how to write a fix for this?

inserted: 2016-04-28 22:35:36   Reply...
From: tk
AFAIK this is same for all word processors. I remember having these problems with Word recently, in one of my documents. Had to cut the table to clipboard, enter paragraph and insert it again. Maybe newer Word solves this, been using Word 2007.

Anyway, this would need some specific fix in KMemo.
inserted: 2016-04-28 13:23:52   Reply...
From: RobV
follow these steps:
1.create a simple table in the first row of kmemo1.(Make sure the cursor is in the first cell, that is exactly the first position of the memo1)
2. you can move the entire table with the keyboard or mouse to the 10th line (or any other line) of kmemo1? how?

inserted: 2016-04-28 13:40:32   Reply...
From: Tk
Aha. Is the same as your point 2. You need to add some other block before the table. Then you can move caret to this block and move table lower with enter key.
inserted: 2016-04-27 19:21:10   Reply...
From: RobV
correction in (1) is to move the table down the first line
inserted: 2016-04-27 19:01:01   Reply...
From: RobV

in lazarus, last version, i create table in first line
procedure TForm1.SpeedButton1Click(Sender: TObject);
  TBL: TKMemoTable;
  TBL := KMemo1.Blocks.AddTable(0) ;
  TBL.ColCount := 2;
  TBL.RowCount := 2;
  tbl..FixedWidth:=false ;
  TBL.Cells[0, 0].Blocks.AddTextBlock('Table text 1');
  TBL.Cells[0, 1].Blocks.AddTextBlock('Table text 2');
  TBL.Cells[1, 0].Blocks.AddTextBlock('Table text 3');
  TBL.Cells[1, 1].Blocks.AddTextBlock('Table text 4');
  TBL.CellStyle.BorderWidth := 1;
(1) after that I can not move the table down to the first line.
(2) also can not move the cursor after the last cell in a way that goes beyond the table.

How do you suggest?
inserted: 2016-04-27 22:35:31   Reply...
From: tk
1) I don't understand this.
2) You have to add at least one other block (e.g. a paragraph block) after the table.
inserted: 2016-04-26 12:36:19   Reply...
From: Whisper
I would like align the text in two diferent ways: left and right in the same columm in KGRID.

I looked for code in the examples, but I don't get to work properly. Could you give a short example for this issue?

Thanks a lot
inserted: 2016-04-27 22:37:50   Reply...
From: tk
If you mean text justification (both left and right alignment) then neither KMemo nor KGrid's CellPainter support this yet. You would have to choose some external routine and draw the text in KGrid's OnDrawCell.
inserted: 2016-04-28 12:25:04   Reply...
From: Whisper
Thank you for your answer.

In lazarus forums one person said to me there is a HAlign property for that. Is it wrong?

Can not I align the text in the first row of the one col to the left, and the next rows, of this col, to the right?
inserted: 2016-04-28 14:05:11   Reply...
From: Tk
Now I understand. Yes you can use Halign property. You can align text in every cell differently.
inserted: 2016-04-28 16:47:27   Reply...
From: Whisper
But I don't know how I should do. Could you write a small example?
inserted: 2016-04-28 21:47:48   Reply...
From: tk
This should draw each odd row with different alignment than even row. Didn't test, written now from scratch:

procedure TForm1.KGrid1DrawCell(Sender: TObject; ACol, ARow: Integer; R: TRect; State: TKGridDrawState);
  KGrid1.CellPainter.Text := KGrid1.Cells[ACol, ARow];
  if ARow mod 2 = 0 then
    KGrid1.CellPainter.HAlign := halLeft
    KGrid1.CellPainter.HAlign := halRight;
inserted: 2016-04-29 11:50:53   Reply...
From: Whisper
Thanks a lot.

I studied your example code, I realized that I forget this line:

 Resultados.CellPainter.Text := Resultados.Cells[ACol, ARow];
(Resultados is Kgrid type)

I "lost" the text. Now, This code fixed the issue.

Thank very much

inserted: 2016-04-30 18:41:04   Reply...
From: tk
Or you could use different cell class, eg. TKGridAttrTextCell. There you can define text alignment and other features for each cell directly, without having to call OnDrawCell.

Cell classes are very powerful feature for non-virtual (typically smaller) grids, allowing you to code grid events once and use these then for many grids with just a simple assignment. Unfortunately this feature is not well documented and neither well shown in the demos.
inserted: 2016-04-24 03:04:47   Reply...
From: seci20
hex edit find and replace command help me ?
inserted: 2016-04-27 22:39:03   Reply...
From: tk
AFAIK there are such commands available, can be used in the hexeditor demo.
inserted: 2016-04-23 12:51:46   Reply...
From: jaume
Can KGrid wordwrap cells, show memo text and graphics?
inserted: 2016-04-27 22:41:06   Reply...
From: tk
It should be readily possible via the KGrid.CellPainter. Some of these features are shown in the KGrid demo, some you have to figure out yourself.
inserted: 2016-04-03 19:29:55   Reply...
what change fontname , size and color in the cells?
thank you
inserted: 2016-04-04 09:35:47   Reply...
From: tk
Everything in OnDrawCell, see the demos.
inserted: 2016-03-28 12:41:43   Reply...
From: wot
How do I set title and fieldname in kdbgrid like in dbgrid?
In Dbgrid I can use something like this:
and it works. In kdbgrid there is no fields "fieldname" and "title".
Is there any solution for dynamically do that?
inserted: 2016-04-02 20:53:55   Reply...
From: tk
As the Columns property is inherited from ancestor TKGrid class (this is the difference between TDBGrid and TKDBGrid) you must use typecast or the AS keyword here:
TKDBGridCol(DBGrid.Columns.Items[0]).FieldName := 'Id';
(DBGrid.Columns.Items[0] as TKDBGridCol).FieldName := 'Id';
inserted: 2016-03-02 10:17:15   Reply...
From: josefkoller

I use KMemo and it looks fine.
But I have one problem in preview.

For example:

I type only a sort phrase in Kmemo like: "short test". (fontname is "Consoloas", fontsoze is 9).
After clicking preview I see this short phrase, but it's to big and the phrase look's like centered.

Only I have a longer phrase in the text (width like component-with) I see the phrases in preview in correct fontsize and fontname.

What's wrong in my behavior?



Lazarus 1.6,FPC:3.0.0, win32
Kcontrols 1.7

inserted: 2016-03-08 09:47:37   Reply...
From: tk
This is normal in current state as paging has not yet been implemented.
KMemo has only basic print/preview caps now. Partial workaround is to uncheck Fit to page option in the print settings but this can cut the text on right side for bigger documents.
Older comments
My account
Recently modified

KControls Component Suite

by: tk



by: tk



by: tk



by: tk


KGrid 1.3 released.

by: tk


Recently inserted


by: tk


Grouping of comments

by: tk



by: tk


My recent work on KMemo

by: tk


Update for RAD Studio XE2

by: tk