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

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.72646Delphi 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.62522Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+support for RAD Studio XE6, Columns property in TKDBGrid, bugfixes...
kcontrols_1.5.zip1.5318Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+new components TKMemo, TKBitBtn, TKColorButton, some bugfixes...
kcontrols_1.4.zip1.4959Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE3-XE5, new components etc.
kcontrols_1.3.zip1.32691Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE2
kcontrols_1.2.zip1.23054Delphi 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.11069Delphi 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.01662Delphi 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-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.
inserted: 2016-02-01 05:49:30   Reply...
From: heri
how setting cell word wrap
inserted: 2016-01-31 18:05:30   Reply...
From: johnvantelli

I set ColCount = 3
and in my formCreate set col 2 not visible

but scrolling cells program freeze!!
Any ideas??


procedure TForm1.FormCreate(Sender: TObject);
inserted: 2016-02-01 11:48:27   Reply...
From: tk
Cols[x].Visible is buggy. Use ColWidths[2] := 0; as workaround.
Same for Rows.
inserted: 2016-02-01 20:35:57   Reply...
From: johnvantelli
same problem...

I set:

FixedRows := 0;
FixedCols := 0;
ColCount := 3;

ColWidths[0] := 200;
ColWidths[1] := 0;
ColWidths[2] := 0;

but moving cell cursor on right program freeze
I think the problem is that component try to set focus on an invisible cell.
inserted: 2016-02-03 16:17:25   Reply...
From: tk
I can confirm there is some bug causing KGrid to freeze, even in Delphi. Some recent update introduced this blocker. Please, give here the Lazarus version and what demo causes the crash.
inserted: 2016-02-08 19:34:07   Reply...
From: tk
This bug was not in KGrid but in another place of our application.
inserted: 2016-02-03 13:46:42   Reply...
From: tk
Is it fresh installed Lazarus and some short demo project?
inserted: 2016-02-03 21:35:41   Reply...
From: johnvantelli
Lazarus fresh installed...

Version 1.4.4
rev.SVN 49931

To test the crash I create a new project, put KGrid in main form and in formCreate insert this code;

KGrid1.FixedRows := 0;
KGrid1.FixedCols := 0;
KGrid1.ColCount := 3;

KGrid1.ColWidths[0] := 200;
KGrid1.ColWidths[1] := 0;
KGrid1.ColWidths[2] := 0;

inserted: 2016-02-08 19:55:28   Reply...
From: tk
I could reproduce now, needed more moves with keyboard. The issue should be fixed, download the repo.
inserted: 2016-02-08 19:38:39   Reply...
From: tk
Cannot reproduce the bug with the same code and same fresh Lazarus on Win7x64, with all project options set to default.
inserted: 2016-01-29 05:47:33   Reply...
From: bpranoto
Hello, is it possible to:

1. Create merged header on TKDBGrid? How to do that?
2. Create column footer?

Thank you.
inserted: 2016-01-30 19:17:57   Reply...
From: tk
1. Should be possible via CellSpan but I never tested with KDBGrid.
2. Column footer (for sums etc.) is not implemented yet.
inserted: 2016-01-31 11:03:29   Reply...
From: bpranoto
Thanks, I also notice TKDBGridCol does not have title alignment property. How do we create a center aligned column title?
inserted: 2016-02-01 11:39:39   Reply...
From: tk
Each drawing customization must be done in OnDrawCell.
Here you must set Grid.CellPainter.Attributes = halCenter. See the kgrid demo how to use CellPainter.
inserted: 2016-01-26 10:15:38   Reply...
From: JanR
I have been trying out your tkpagecontrol in Lazarus, but i cannot find any way to add tabs to this control in design time. Can you tell me where I do this?
inserted: 2016-01-30 19:15:38   Reply...
From: tk
Did you try some recent download from bitbucket? There it should be already possible.
inserted: 2016-01-25 17:45:43   Reply...
From: rdevine
Hi Tomas - I've been taking a look at your very nice grid. I currently use one from TMS and for virtual mode there is an OnGetCellData event I use. I looked at the virtual grid demo for TKGrid but can't see anything similar. The demo seems to just set fixed values in the form create - am I missing something?

BTW, I had to add the "Vcl." prefix in many of the units to get it to compile in XE7.

Thanks, Bob
inserted: 2016-01-30 19:14:28   Reply...
From: tk
KGrid has different approach for virtual mode. See the kgriddemo, 3rd page. There it is shown. Btw. read the installation notes, you do only need to modify the unit scope names in your Delphi (or project) settings.
inserted: 2016-02-01 22:55:07   Reply...
From: rdevine
Thanks - always a good idea to read the installation notes :-) I see the virtual mode now - some of my datasets have millions of rows and if I set the rowcount to even 100000 it struggles. The commercial grid I use has a type of paging where only required visible cells are created, so I can set millions of rows with no performance hit. Is a similar mode available for KGrid?

Thanks again.
inserted: 2016-02-03 13:59:27   Reply...
From: tk
No, the goVirtualGrid option in KGrid just prevents creating internal cell objects, but other algorithms (such as size calculations etc.) always iterate on all rows.
inserted: 2016-01-24 00:44:00   Reply...
From: Stefan
How to Save and Load KDBGrid's Columns Order ?
KDBGrid1.Columns.SaveToFile('DBGrid.txt') - it does not work
inserted: 2016-01-30 19:12:30   Reply...
From: tk
This is not possible with KDBgrid.
inserted: 2016-01-20 20:06:31   Reply...
From: tomsan

I am using Delphi 2010 on Windows 8. The package doesn't get compiled. Most of the problems are in kFunctions.
inserted: 2016-01-21 19:29:16   Reply...
From: tk
I was testing the 1.7 on D7, DXE and DXE8. No chance for me to test versions in between, but you can always pull the repo with TortoiseHg, fix the problems and send me a patch. I think if there are some problems, they will be with the compiler conditionals in
inserted: 2016-01-21 19:32:06   Reply...
From: tk
Actually meant their application in code, where I sometimes just guessed which Delphi version implemented what.
inserted: 2016-01-09 12:51:42   Reply...
From: gerard
FYI, I just downloaded the control set from bitbucket and installed it on Laz 1.6.0rc1 under linux X64.
There is an issue when installing under Linux: it complains that it doesn't find kdialogs.pas and kgrid.pas, and it's because of the files being there but with names partially in uppercase (KDialogs.pas & KGrid.pas)
Renaming the files to kdialogs.pas and kgrid.pas solves the problem.
Best regards,
inserted: 2016-01-10 16:28:42   Reply...
From: tk
I renamed the files on bitbucket, thank you.
inserted: 2015-12-30 20:06:03   Reply...
From: lechuDC
the problem missing function makecellspan i ver 1.7
inserted: 2015-12-30 22:44:40   Reply...
From: tk
MakeCellSpan has been moved to kfunctions.pas. This is because I needed the function in KMemo as well (because of KMemo tables).
inserted: 2015-12-31 02:00:48   Reply...
From: lechuDC
thanks; need to use kfunctions.pas with kgrid
inserted: 2015-12-28 03:42:43   Reply...
From: anhnguyen18
When I add a new record in the TKdbgird, the new record always appears above the current row, it doesn't appear at the end of the TKdbgrid as a normal dbgrid. Is there anyway to make a new record which appears at the end of the TKdbgrid? Thanks.
inserted: 2015-12-30 22:39:01   Reply...
From: tk
There was a way but with more successive commands. I made the new AppendRow method from them. You can try the repo download.
inserted: 2015-12-31 03:45:08   Reply...
From: anhnguyen18
Cool! Thanks for your effort.
inserted: 2015-12-20 01:36:04   Reply...
From: snorkel
small issue with tkmemo(repos version):
tk, the memoframe has a odd issue with the text style.
basically what happens is if you have a series of chars that is
one style and put the caret in the middle of that text and then change the font for example it instead of changing just at the caret and for new typed text it changes as if you had the whole thing selected.
inserted: 2015-12-20 16:43:14   Reply...
From: tk
This is not a bug. M$ Word does it this way so I just made it the same, see TKMemoFrame.TextStyleChanged.
inserted: 2015-12-21 18:35:54   Reply...
From: snorkel
ok, I guess I never noticed that in M$ word. (I rarely use it)
I was expecting the behavior to be more in line with the simpler wordpad.
inserted: 2015-12-21 22:10:27   Reply...
From: tk
I've checked Wordpad and Libreoffice Writer. Libreoffice Writer behaves just like Word in this regard, Wordpad does not. So I think if you want Wordpad behavior you must comment out this code in TextStyleChanged:

if not SelAvail then
  // simulate MS Word behavior here
inserted: 2015-12-18 09:12:52   Reply...
From: iru
Read-only column in TKDBGrid?
How can I mark a colum read-only so that all mouse clicks and key entry (TAB?) in such a column are ignored?
inserted: 2015-12-18 09:29:40   Reply...
From: IRU
I think I have it! I read further and an answer by Calinutz does the job,
inserted: 2016-01-07 07:07:39   Reply...
From: IRU
I do not have it! I have some TKDBGrid columns (and related FireBird table columns) in which I wish to store data. How can I do it without an editor in the column? If I have to have an editor in a column how can I make the TKDBGrid readonly?
inserted: 2016-02-08 20:19:23   Reply...
From: tk
I don't understand fully what you want to achieve but a read only column can be made through a void OnEditorCreate call. This means you handle OnEditorCreate of your KGrid but do not create any editor in this handler for read only columns. I and my colleagues use this method all the time.
inserted: 2015-12-16 17:52:26   Reply...
From: snorkel
Hi tk,
quick kmemo question.
In a standard Tmemo control in the onkeydown event I can do ignore the return key and instead save the memo to a stream for sending over tcp/ip and have the return instead be shift return.
(does not work in Kmemo)

like this:
if (key = 13) and (ssShift in shift) then
key:=13 else
 if key = 13 then

inserted: 2015-12-17 14:30:54   Reply...
From: tk
This is not possible (yet). I don't know your application, but maybe you could try some workaround like form's KeyPreview or make a TAction and specify a shortcut for it? You should be also able to catch specific key and then send another key to KMemo programmatically (not tested, took from some other forum): SendMessage(KMemo1.Handle,WM_KEYDOWN,0,Integer(PChar(#13)));
inserted: 2015-12-20 01:40:52   Reply...
From: snorkel
Hi tk,
I did try changing the key in the onkeydown etc and when I send back a key it puts in a space instead of a new paragraph.
I kind of got it to work by checking if the shift key is down and the key is 13 to return a key of 0 and then add a new paragraph block.
This does not work exactly right and some odd behavior is exhibited at the caret.

If you have time, maybe as a feature request you could had a property to the control to have shift enter as the default instead of enter.
Would be super handy for chat applications.
inserted: 2015-12-20 19:00:00   Reply...
From: tk
Maybe my previous advice was wrong. Did you also play with KMemo1.ExecuteCommand(ecInsertNewLine) or KMemo1.InsertNewLine ?
inserted: 2015-12-21 18:38:14   Reply...
From: snorkel
nope I didn't try those :-)
I will try them and let you know.
inserted: 2015-12-21 18:57:00   Reply...
From: snorkel
KMemo1.ExecuteCommand(ecInsertNewLine) works, the other methods don't move the caret.

In case anyone else is interested:

in the keydown event do:

if (key=13) and (ssShift in Shift) then
end else
if key = 13 then
       //do something else like send tcp/ip message etc.

inserted: 2015-12-11 21:08:25   Reply...
From: snorkel
(KMEMO) Sorry to be a pest.. having another issue.
I am trying to insert a image/emoticon and no matter what I set the index to it always puts it on the next line, the only way I can get it to work is if I call kmemo1.blocks.clear, this then gets rid of the carriage return linefeed and then I can insert at the end of the typed text.

rve2.Select(rve2.SelectableLength, 0);

I turned on show formatting and as long as there is a CRLF symbol the block insert always goes to the next line.

If I do a blocks.clear before I do the insert it inserts where I want it, but then any new typed text the caret is off by one char.

even if I set the index for the block adds to selectablelenght it gives a index out of bounds error.

Not sure if this is a bug or I am just doing it wrong.
inserted: 2015-12-12 09:26:16   Reply...
From: tk
The AddAt(imageblk) always inserts at the end. If there is already a TKMemoParagraph block at the end then it is obvious that the image will be inserted on next line. You have to determine if TKMemoParagraph is the last block (KMemo1.Blocks[KMemo1.Blocks.Count - 1] is TKMemoParagraph) and if this expression is true then insert the image before it: KMemo1.Blocks.AddAt(imageblk, KMemo1.Blocks.Count - 2).
inserted: 2015-12-15 16:47:09   Reply...
From: Snorkel
Thanks tk,
That works except the index has to be KMemo1.Blocks.Count - 1
The block concept is pretty unique, I am getting used to it though :-)
inserted: 2015-12-16 01:42:18   Reply...
From: Tk
Yes of course, thanks for correction.
inserted: 2015-12-11 18:46:47   Reply...
From: Snorkel
Hi tk (tkmemo question),
I just noticed that the SaveRTFStream method does
not include image blocks in the saved stream.
When the stream is loaded into another kmemo the images are missing.
inserted: 2015-12-12 09:19:03   Reply...
From: tk
Maybe you are using unsupported image format?
Supported in RTF are PNG, JPG, EMF and WMF. Metafiles only on Windows.
If some png/jpg is not working, then try with KMemoDemo example, procedure LoadFiles.
Make test.rtf file.
Then comment out KMemo1.LoadFromRTF('kmemo_manual.rtf'); and uncomment KMemo1.LoadFromRTF('test.rtf');
If it does not work send the test.rtf to my email.

inserted: 2015-12-15 18:11:17   Reply...
From: snorkel
Just a FYI,
I changed my code to:

and the small emoticons are showing in the saved stream.
it does not like the image.bitmap I was using.
inserted: 2015-12-12 18:57:14   Reply...
From: Snorkel
Hi tk, I am inserting them from
A image list, they where added to
The list as bmp. I will do some more testing.
inserted: 2015-12-13 10:01:22   Reply...
From: tk
I hate TImageList implementations, both in Lazarus and Delphi they are really crappy. I don't understand, why in 2015 TImageLists do not have direct import/export functions for PNG/JPG... SVG should be supported as well now. Who uses some stupid BMP now?
inserted: 2015-12-15 16:24:42   Reply...
From: snorkel
Lazarus does allow you to export them as other formats and load other formats.
I guess the timagelist internal storage method in the DFM/LFM is tbitmap though.
I did look at the method that writes the stream/file and it did not appear to write imageblocks.
Was the imageblock export missing in kcontrols 1.7?

I actually have my project ported to Lazarus I just had to comment out a bunch of stuff that was for trichview. The only functionality I really need for the project to be fully functional is images in the stream.
inserted: 2015-12-16 01:35:27   Reply...
From: Tk
It was missing in 1.6. In 1.7 and later it was already present. But bmp is not supported as I said. I did not know Lazarus can export images from imagelist to png directly. Must have been added recently or I missed sth. Then Lazarus is better than Delphi where I've always been fighting with image lists, their correct painting and exporting of images...
inserted: 2015-12-11 05:43:47   Reply...
From: snorkel
TKmemo feature request/idea

Hi tk,
would it be possible to add a loadrtffromstream to a block object?
Then it would be possible to load a stream into a table cell like this:


I figured out how to do it by loading the RTF sent over the socket into a hidden tkmemo and then do:


inserted: 2015-12-11 15:16:39   Reply...
From: tk
See below, TKMemo.LoadFromRTFStream could have been extended to accept specific blocks as parameter.
inserted: 2015-12-11 17:27:56   Reply...
From: snorkel
Ok, I will take a look at that, I would of course prefer not to use a hidden kmemo.
Do you have a example on that?
inserted: 2015-12-13 10:17:55   Reply...
From: tk
See recent repo snapshot. I've found some time to make that change and it was not difficult. See Test24 method in KMemoDemo example for further info about how to use this.
inserted: 2015-12-20 01:33:03   Reply...
From: snorkel
tk, that change you made works perfectly. Thanks a bunch.
inserted: 2015-12-15 16:27:15   Reply...
From: snorkel
Thanks tk, will grap the repos and try it out.
inserted: 2015-12-10 20:04:04   Reply...
From: Snorkel
(Kmemo question)
Would it be possible to insert the contents of a stream into a table cell?
What I want to do id have a 3 column table and have a username in the left column, the middle column would have the RTF message from the stream and the right column would have the time the message came in.
inserted: 2015-12-11 06:38:42   Reply...
From: snorkel
I think I figured this out:
what I did was to load the stream into a hidden tkmemo.
Then I assigned the blocks from the hidden control to the cell I wanted to display the RTF that came in from the tcp/ip stream.

Don't know if that's best practice or not, seems to work fine though.
inserted: 2015-12-11 15:06:02   Reply...
From: tk
Never tried, but if it works for you then OK. Another way seems not to be supported yet, TKMemoRTFReader.LoadFromStream would need to be enhanced to accept specific TKMemoBlocks where to insert the objects from RTF.
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