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

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

Notes

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: In Delphi only VCL is supported. FMX will never be supported.

Donations

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. Please download and try this version if something is not working in the official release listed below.

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
downloads
Available for:Changes
kcontrols_1.7.zip1.76714Delphi 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.62719Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+support for RAD Studio XE6, Columns property in TKDBGrid, bugfixes...
kcontrols_1.5.zip1.5380Delphi 6+,Lazarus 1.2.2+, C++Builder 2007+new components TKMemo, TKBitBtn, TKColorButton, some bugfixes...
kcontrols_1.4.zip1.41029Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE3-XE5, new components etc.
kcontrols_1.3.zip1.32739Delphi 6+, Lazarus 0.9.29(SVN#21827)+, C++Builder 2007+support for RAD Studio XE2
kcontrols_1.2.zip1.23111Delphi 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.11114Delphi 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.01728Delphi 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: 2017-11-11 13:52:15   Reply...
From: ilias-bk
Hi TK

i try to install the 1.6 version in Delphi 6 and i get o errors about the GetLocaleFormatSettings

Ilias
inserted: 2017-11-07 02:55:40   Reply...
From: Davo
Having a 'refresh' issue with KMemo.

My App has grown quite big now, have been working on other aspects recently but just noticed that when I load a some content in KMemo and mark a few hyperlinks in that content, the links are not underlined until I make some arbitrary change to the text. Inserting a space (and removing it) before the links fixes both. Adding something at the end will fix one of the two links ???

I have tried a number of things programaticly such as inserting and removing a space but that does not help. Tried KMemo1.[Refresh, invalidate, repaint, update. blocks.UpdateAttributes] all with no effect.

I have noticed this phenomenon in the past but have been able to fix it by adding and removing a Paragraph marker at the end. Thats not working now.

Is there some way to ask KMemo to refresh itself ?

Davo
inserted: 2017-11-07 03:20:20   Reply...
From: Davo
Just cancel that, its a coding error on my part. Sigh ....
inserted: 2017-11-02 20:17:27   Reply...
From: Velas
Hello. Forgive for bad English and obvious questions. КGrid - Question. How to justify the text in Heading of the table and in separate cells? Whether the fixed lines and columns (headings) in any place of the table can settle down?
Thanks in advance.
inserted: 2017-11-07 20:43:06   Reply...
From: tk
You need to do this in OnDrawCell. Search for CellPainter.HAlign on this forum and you'll find a lot of examples.
inserted: 2017-10-25 08:48:02   Reply...
From: см
Hi Tk,
I wonder if you happen to have adding support for images in hyperlinks in your todo list.
You have mentioned some time ago that it should not be too hard.
Previously I had the wrong impression that I have overcome the lack of this feature (yo have helped me on this) but since it ocurred I was wrong I wonder if I should search for another alternative solution.
inserted: 2017-11-07 20:40:22   Reply...
From: tk
I can see that eg. MS Word supports them so they basically should be implemented in KMemo as well. Only I don't know the timeframe for this, now I am very busy.
inserted: 2017-11-09 14:46:59   Reply...
From: см
Thanks,
I will think what to do when I get there.
inserted: 2017-10-09 11:15:09   Reply...
From: Davo
TK, I have made a start with writing that extra information I mentioned about KMemo I mentioned a few weeks ago. Please see -

http://wiki.freepascal.org/KControls/KmemoNotes

And let me know if you don't like anything there ...

Davo
inserted: 2017-10-09 21:56:28   Reply...
From: tk
Very well done. At least you've done the basic search functionality (it would not work for tables and other nested containers). Keep moving here since I am actually very lazy at documenting and I still don't have enough time to do the big TODOs themselves (advanced search, undo/redo etc.). But it should be better soon.
inserted: 2017-10-10 08:18:17   Reply...
From: см
Well done.
I have added some info and made some fixes.
I would recommend: Do not use various names for the memo in the samples- either use KM or KMemo1, not both.

Also, similarly to what Tk mentioned, search functionality is far from working in the way you have written it.
  1. CrLf is considered by selection as a single character only, so if you want to find a string and select it, you will either have to replaces CrLf with a single character (Cr or LF) in a buffer string or will have to count occurences.
  2. Images are counted as 1 character.
  3. Special care shall be taken when creating tables.
  4. Anything always gets messed up.

The only reliable method for searhing I have found is:

//Searching backward won't be used
//Returns position at which a string is found
function CrawlSearchMemo (const SoughtString: string; var Memo: TKMemo; StartPos: integer=0; CaseSensitive: boolean=False): integer;
var
  SPos: Integer;
  SSLen: Integer;
  StepNext: byte=1;
  Found: boolean=False;
  mStartPos: integer;
begin
  Result:=0;
  SSLen:= Length(SoughtString);
  if SSLen<1 then exit;
  if UTF8Pos(SoughtString,Memo.Text)=0 then exit; //Much faster than the process below
  Memo.Blocks.LockUpdate;
  if StartPos=0
    then mStartPos:=Memo.Blocks.RealSelStart+StepNext
    else mStartPos:=StartPos;
  for SPos:=mStartPos to UTF8Length(Memo.Text)- 1 do
  begin
    Memo.Select(SPos,SSLen);
    Found:= (StringCompare(SoughtString,Memo.Blocks.SelText,CaseSensitive)=0);
    if Found then
    begin
      Result:=SPos;
      Break;
    end; //if Found
  end; //for SPos
  Memo.Blocks.unLockUpdate;
end;

The aforementined method is extremely slow, so I actually use hybrid searching (search approximately where the string is and then proceed with crawlsearch) which ai might post later.

Also, I would recommend not to use any string related function or procedure which does not start with UTF8... otherwise you are in a big trouble.
inserted: 2017-10-11 00:42:52   Reply...
From: Davo
And thanks for the correction of KMemo1.Lock.... You have highlighted the fact that I have, in fact used that in my app. Better fix that Davo !
inserted: 2017-10-11 00:36:12   Reply...
From: Davo
Thanks CM, I'm particularly interested in the UTF8 comments, something I will have to deal with soon in my real app. No experience there, I only speak English, here in Australia, thats all we do sadly.

Are you active on the Lazarus forum ? TK may not want us clogging up his help line with in depth technical discussions ....

My app does not use the search model I put on the page, as I need to search for (typically) 200 search terms on every change event, far too slow ! The model I put on the page is more about demonstrating the idea. Its important when presenting a new idea to someone to do so in as simple a way as possible. Otherwise, they get bogged down in (irrelevant to them) side issues. Perhaps I need to add a bit more saying my search is only about text, does say so at top of document but not as clear as it should ?

Thanks for picking up those typos and I agree about using KM v. KMemo1, its an artifact of me copying out of a several different units, the reader does not need to know that !

I still need to cover bullets and few other topics, I'd like to see contributions from other users, especially yourself ! The learning curve at the start is a bit steep, be great to help other users get into this excellent component set.
inserted: 2017-10-12 08:36:39   Reply...
From: см
I can be found in the Lazarus forum as cm630, but I am not much active there.
I suppose it would be a good idea to have a general thread about TKMemo ot TKControls.
There is nothing special in using UTF 8, just use:
  Utf8Length instead of Length
  Utf8Left instead of Left
  Utf8Right instead of Right
  Utf8Copy... insted of Mid
  UTFPos insted of Posx....
And it is good that a native English speaker could take for the wiki.

Are you sure (I mean have you tried) that „On Unix like systems, the position in KMemo1.Blocks.Text can be used directly as a TKMemoSelectionIndex.‟? I suppose that misusing a single character instead of CrLf happens in pure text files only, and I expect it not to happen in a specified format like RTF.

As far as my contribution to wiki is concerned- I will check my notes, but if I happen to find some spare time, the first thing to do will be working on adding support for highlighting in TKMemo.
inserted: 2017-10-13 01:43:05   Reply...
From: Davo
"Are you sure (I mean have you tried) that „On Unix like systems, the position in KMemo1.Blocks.Text can be used directly as a TKMemoSelectionIndex.‟?"

Yes, tested extensively. Sure ?, no in that that its an "undocumented" feature and could change without notice. My testing covered ONLY text content. TKMemoSelection index counts one char position for a new para (but interesting, shows its length() as 2). Same as #10. And Windows CR/LF is two char #13#10, so subtract 1 for every #13 you see. The counting #13 does no harm under Unix, there arn't any. But I ifdef it out anyway to save a bit of time.

However, I am concerned what happens if I start putting UTF8 char in there. And thats where I am on unfamiliar ground.

I have just sent my draft app out to the opensource community I'm with and we'll see some feedback I hope. If some of the auto changes to text crop up in the wrong position, then I'll know I have a problem. And it will be a big one!

Wow ! Did you say HIGHLIGHTING ??? That would be so cool. In my app, I have used red text instead of the yellow background our old app uses. And I hate it.
inserted: 2017-10-17 08:41:35   Reply...
From: см
Returning a single char as a NewLine in Linux seems prtty odd to me, but in the recent weeks I won't be able to try it. Maybe it is a bug, or maybe lazarus could be forced to work the same way under Windows.
Also one should bear in mind, that Apples also use a single charcter NL, but they do not use the same one as Linux (one uses CR and the other uses LF).
   There is no reason to be afraid of UTF8, TKMemo is using it internally.
   I *almost* had highlighting working, but I will need some assistance from TK, if he could spend the time. But first I will have to deal with bitbucket's revision system.
   Also, this thread is important: https://forum.lazarus.freepascal.org/index.php?topic=26137.0. Last time I checked, changes were not implemented in Lazarus, so I still do not dare to use its native Replace routines.

inserted: 2017-10-21 05:22:47   Reply...
From: Davo
Hi CM, I am not sure what you find odd with Linux returning a one character newline. Thats standard Unix. Both Linux and OSX use LineFeed, #10. (The old Mac OS did #13 I think, too long ago).

I would not see any aspect of this as a bug, it works pretty much as I'd expect.

yes, agree with your concern with copying large strings, in my app I use a PChar, too old to trust these self sizing structures. And PChar is almost C .....

Davo
inserted: 2017-10-09 04:12:53   Reply...
From: Davo
TK, I hope you don't mind me asking, I'm not nagging, just need to know how to proceed.

I'm asking if you have plans to fix the KMemoParagraph.Number := pnuNone bug soon ? I have a rather clumsy partial workaround, only needed on Linux. Should I keep working on that or wait for your (much better) fix ?

I'm getting to the stage where I'd like to show what I have done to a particular open source community pretty soon. Its all made possible by your brilliant package.

Thanks, David
inserted: 2017-10-09 21:47:05   Reply...
From: tk
This bug should be fixed already, see https://bitbucket.org/tkweb/kcontrols/commits/e4ec3f5e4b069f77f763c06dea0fc62fd66097c9. I just hope my fix was better than yours:)
inserted: 2017-10-10 02:02:55   Reply...
From: Davo
Indeed ! If I'd clicked refresh on my browser, I'd have seen that !
Thanks indeed, it works perfectly. And far better than my approach of following the bullets down the page, and then canceling then one by one on the way back up !

Davo
inserted: 2017-10-08 11:37:59   Reply...
From: Davo
Kmemo - another aspect of the SelStart v. RealSelStart perhaps ?

If a user selects a bit of text and then presses 'Enter', what happens depends on the direction of the selection.

(Mouse) Right to Left - the text remains, is pushed down one line.
Left to Right - the text disappears, thats what I'd expect.

If you press a normal key it all works as expected, only an issue if you press Enter.

Same on Linux, Windows and Mac.

Any suggestions ?
inserted: 2017-10-09 22:04:02   Reply...
From: tk
I can confirm this. Eg. MS Word behaves the same for both directions - selected text is deleted first. So it is a bug IMO. Thanks for reporting - I will fix this later.
inserted: 2017-09-25 12:31:27   Reply...
From: yoni
Can KDBGrid be used with dynamic queries? (i.e. the columns are not predefined)

Currently when I tested it on lazarus 1.8rc4 the grid draws one empty column.


inserted: 2017-09-25 22:10:47   Reply...
From: tk
No.
inserted: 2017-09-25 08:00:20   Reply...
From: Davo
Performance issues when adding to KMemo ?

My app reads in an XML file which I parse and poke into KMemo using functions like AddTextBlock(), AddParagraph() and property TextStyle.Font

I have determined that each of these calls take about 10mS. As the file I load needs about 500, 500 and such 350 calls, I'm seeing 14 to 15 seconds load time. And that sure won't do me any good at all I'm afraid.

Are you surprised at 10mS a call ?

I do stuff like -

var
    FT : TFont;
    TB: TKMemoTextBlock;
begin
    setup FT
    TB := KM.Blocks.AddTextBlock(InStr);
    TB.TextStyle.Font := Ft;
    if something KM.Blocks.AddParagraph;

What do you think ?



inserted: 2017-09-25 22:09:51   Reply...
From: tk
Please read the KMemo manual carefully. Thanks.
inserted: 2017-09-26 01:27:21   Reply...
From: Davo
Sigh ...

Do you mean "...the KMemo update which is often a time consuming operation..update locking has been introduced.." ? I had read and applied that.

The manual does not say if Update Locking speeds things up or just prevents user interaction while its happening. My tests indicated the latter.

So, to make my question clearer, is there anything I can do to speed up these processes ?

Thanks TK.
inserted: 2017-09-26 10:13:32   Reply...
From: tk
The manual says:
"Please note each such operation will force the KMemo update which is often a time consuming operation, especially for large documents. For such cases, update locking has been introduced. "
I think the meaning is absolutely clear. Do what CM said.
inserted: 2017-09-26 09:23:02   Reply...
From: см
Add KM.Blocks.LockUpdate before your code and KM.Blocks.UNLockUpdate after your code (after populating the ENTIRE memo). Speed will be increased dramatically.
Do NOT use KM.LockUpdate (without .Blocks) because things will get messed up.
inserted: 2017-09-26 13:04:41   Reply...
From: Davo
OK, I have ordered a large serve of humble pie !
I went back and discovered that I had put my LockUpdate / UnLockUpdate pair around the wrong line of code!
Corrected that and went from 14sec to 83mS to load my test file. Wow !

(I have an object that loads the file, I create it, tell it the file name and then to load, then free it. I put my lock/unlock pair around the filename line, not the load one.)

Thanks folks, this is turning into something pretty good !
David
inserted: 2017-09-26 15:29:33   Reply...
From: см
Just an advice- if your memo starts to behave oddly- cannot select items, or messes selection or something like that- possibly you have missed to unlock the blocks.
inserted: 2017-09-27 00:46:26   Reply...
From: Davo
Yep, that would make sense.

I did note in my simple test rig that after (lock) importing (unlock) the text was invisible until I did a addparagraph without any locking.

Thought that pretty strange but quite repeatable. In my real app, that does not happen because I write other things to kmemo after importing any way.

Right now, I don't expect to need to apply locking at any stage other than the import process but time will tell.

Thanks CM.

David
inserted: 2017-09-23 14:46:29   Reply...
From: bitsolo
Hi,

where is an help-file or how can i change the backgroundcolor of an specific cell in kgrid?
inserted: 2017-09-24 00:01:03   Reply...
From: tk
If you use non-virtual KGrid then use TKGridAttrTextCell as cell class:

KGrid1.CellClass := TKGridAttrTextCell;

Then simply use:

TKGridAttrTextCell(KGrid1.Cell[MyColumn, MyRow]).Brush.Style := MyColor;
inserted: 2017-09-23 13:20:14   Reply...
From: Davo
OK, this is a bit confronting. The values for KMemo1.SelStart and KMemo1.SelEnd can be reversed by wiping with the mouse in different directions.

Trivial to reproduce, put a KMemo on a form, a button to poke some text into it and another button to display SelStart and SelEnd when button clicked.

Wipe the mouse across text left to right, click display, then from right to left, click display again. Values are reveresed.

Wiping from right to left gives the correct result.

Bitbucket ver of KMemo, Lazarus 1.8rc4 and Linux.
inserted: 2017-09-23 23:51:56   Reply...
From: tk
Use RealSelStart/End instead.
inserted: 2017-09-22 22:03:14   Reply...
From: MVD
Got an error from the compiler for KControlsLaz in kgrids.pas

There is no method in an ancestor class to be overridden :
"DoAutoAdjustLayout(const TLayoutAdjustmentPolicy;const Double;const Double;const Boolean);"
in line (2945,15)
inserted: 2017-09-23 01:56:05   Reply...
From: Davo
MVD, just comment out the declaration and implementation of that function. Save the file and try again.
inserted: 2017-09-22 09:26:30   Reply...
From: Davo
I am having difficulties using Bullets or numbering in KMemo. While turning it on works fine, turning it off again causes a segv.

Doing a very simple model, for example, I do this -

if KMemo1.Blocks.Items[6].ClassNameIs('TKMemoParagraph') then begin
      TKMemoParagraph(KMemo1.Blocks.Items[6]).Numbering := pnuBullets;
      TKMemoParagraph(KMemo1.Blocks.Items[6]).Numbering := pnuNone;
end;

in a KMemo that has some text blocks. I point to block 6 which I know is a TKMemoParagraph and as soon as we hit the pnuNone line, segv, line 8881 of kmemo.pas !

Note that the testDemo does not turn bullets off. And the Editor demo does a range of things with Listlevels that obscures what needs to be done. Do I have to look at ListLevels where just a simple bullet on/off is all I need ?

Bitbucket ver of KMemo, Lazarus 1.8rc4 on Linux.
inserted: 2017-09-23 23:51:01   Reply...
From: tk
This is a bug, thanks for reporting. Will fix that later.
inserted: 2017-09-20 13:36:11   Reply...
From: Davo
Using the Bitbucket version of KMemo. Made a hyperlink but not able to get an 'event' fired when the link is clicked.

It does not appear on the list of events for KMemo, should I look for it somewhere else ? Or do I need register it ?
inserted: 2017-09-23 23:50:32   Reply...
From: tk
TKmemoHyperlink block has its own Onclick event.
inserted: 2017-09-24 01:28:24   Reply...
From: Davo
"TKmemoHyperlink block has its own Onclick event."

Good, any hints on how to I use it ? It does not appear in the Lazarus GUI ?

---------------

TK, this is a great package, very functional but very hard to use because nothing is documented. Would you mind if I started documenting things like this as I find them ? Obviously all credit will remain with you, I'll make that plain. Focus on new users....

Perhaps in the Lazarus wiki ? I have been studying code, browsing through the prototype list, trying to guess what a function actually does. Very time consuming, you must loose a lot of potential users because they just give up.

D
inserted: 2017-09-24 11:40:22   Reply...
From: tk
There is already a wiki page for Lazarus users:
http://wiki.freepascal.org/KControls

Of course you can add more info to it, eg. create subpage on KMemo, copy the KMemo manual to it and then you can start extending it.

Basic principles should stay, as described in the KMemo manual. But keep in mind that the control is not finished yet so some things may change in future.
inserted: 2017-09-24 10:53:59   Reply...
From: Davo
OK, solved first question. Searched older pages of this blog. In case someone else is watching -

    ... setup the Hyperlink ....
    Hyperlink.OnClick := @MyClickCommand;

Then, make the MyClickCommand procedure -

procedure TForm1.MyClickCommand(Sender: TObject);
begin
    showmessage(TKMemoHyperlink(Sender).Text);
end;

That really is too easy ! (I was distracted by the WordMouseAction(..) thinking I had to use that. Sigh...)

Thanks TK.
inserted: 2017-09-24 11:33:28   Reply...
From: tk
Well done.

Just a note: KMemo is not finished by far and not fully documented yet!
It is also written in the control when you drop it to the form at design time.
If you want to use KMemo then you HAVE TO test everything yourself (create a sandbox project) and search on this forum as well!
inserted: 2017-09-19 10:49:44   Reply...
From: 4AM
Hi I got some archaic project to fix and it is using your TKDBGrid (version 1.1) but i have problems with installing it. There is problem at compiling, error message: [C++ Error] KControls_CB6.cpp(3): E2209 Unable to open include file 'BASEPCH.H'. And I don't have any idea where to find it.

p.s.: I am not C++ programmer.
inserted: 2017-09-19 13:42:29   Reply...
From: tk
Well I don't know as well, because I haven't used C++ Builder since ca 2010. And I hope I won't be using it again. The only thing I remember is that C++ Builder packages were 'somehow' auto-generated from Delphi packages so there should not be a major problem, maybe the C++ Builder packages are wrong and need to be recreated. I guess you will have to figure it out yourself if no one here knows the answer (this is quite probable because usually only Delphi and Lazarus programmers come here to this forum).
inserted: 2017-09-14 15:28:47   Reply...
From: lafree
How can use tkprintpreview to preview xls file?
HOW can I use tkprintpreview for other controls like StringGrid?
Thinks a lot!
inserted: 2017-09-18 11:53:54   Reply...
From: tk
No way. The control must descend from TKCustomControl, such as TKGrid or TKMemo.
inserted: 2017-09-12 21:35:52   Reply...
From: MVD
I was reading the questions and answers and I put LazUTF8 in the uses
but now I get a compiler message for the KFunctions line 2565 and 2578 "identifier not found "UTF8UpperCase" and "UTF8LowerCase".
inserted: 2017-09-18 12:16:23   Reply...
From: tk
My answer is the same as for previous question.
The functions must be present in LazUTF8, update Lazarus if they are not there.
Of course I assume you also use the latest KControls trunk from bitbucket where this my support only refers to.
inserted: 2017-09-13 07:09:25   Reply...
From: см
Did you add LazUTF8 in the uses section of KFunctions, too?
inserted: 2017-09-12 21:06:03   Reply...
From: MVD
I tried to install the KControlslaz in lazarus (windows 10)but I got the compiler error on line 4032 KMemoRTF : error: identifier not found "UTF8Copy". I would appreciate if there was some solution.
Kind regards
inserted: 2017-09-18 11:52:44   Reply...
From: tk
UTF8Copy must be present in LazUTF8.
Check if LazUTF8.pas has this function. If not then you must update to newer Lazarus version (I recommend using the trunk via fpcupdeluxe).
inserted: 2017-09-12 10:49:34   Reply...
From: см
Hi TK,
kmemo.pas contains the following line:

cDefaultWordBreaks = [cNULL, cSPACE, '/', '\', ';', ':', '(', ')', '[', ']', '.', '?', '!'];

In this line the comma is missing and imho it should be there. Could you consider adding it?
inserted: 2017-09-18 11:33:05   Reply...
From: tk
I am not sure why it was missing but IMO it should be there too. I'll add it later.
inserted: 2017-09-10 18:05:35   Reply...
From: Milsa
You have UTF8- named procedures in source. Lazarus 1.8.0 or higher have full UTF8 support. These procedures not exist in new Lazarus.
inserted: 2017-09-11 09:12:32   Reply...
From: см
These procedures exist and are parts of LazUTF8 which should be added as „...uses ... LazUTF8‟ if you want to use Lazarus 1.8 RC.
You could check the tread started by tudi_x on 2017-08-03.
inserted: 2017-09-18 12:23:43   Reply...
From: tk
For latest KControls version from Bitbucket there is no need to add LazUTF8 anywhere to uses sections, it is already there. The version compiles fine in latest Lazarus (trunk). So perhaps the Lazarus 1.8 RC misses needed functions in LazUTF8 or you refer to some older versions of Kcontrols here?
inserted: 2017-09-07 08:59:56   Reply...
From: см
Hi.
Is it possible to determine the position (the X and Y coordinates) of the caret withing the TKMemo?
inserted: 2017-09-11 21:14:38   Reply...
From: tk
There is a protected field FCaretRect which you can use now by creating a TKmemo descendant and adding a getter for it. I'll make it publicly accessible later.
inserted: 2017-09-12 08:55:56   Reply...
From: см
Thanks,
I have modified kMemo, until you make FCaretRect public.
inserted: 2017-09-05 07:49:13   Reply...
From: см
Hi. Is it possible to have titles in hyperlinks?
(Title is shown when the hyperlink is pointed by the mouse in a pop-up text area).
MS Word supports it, but still I am not sure if it is a standard property of hyperlinks or it is something extended).
inserted: 2017-09-11 21:04:19   Reply...
From: tk
No, with current version of KMemo not.
inserted: 2017-09-04 23:27:43   Reply...
From: Josh
I have been using TKGrid, with windows and OSX ( carbon ) without issue.

As Apple are discontinuing 32bit this means only COCOA should now be used.

When I compile for a cocoa I get numerous errors.

I have latest SVN of LAZARUS and FPC, if I create a new Project withan empty form, and place a TKGRID ( Latest one from bitbucket) and compile for 64 cocoa widgetset, I get an error
FPIMAGEEXCEPTION failed to create handle.
in file intfgraphics.pas at line 3634: then raise exception FPIMAHEEXCEPTION.CREATE('Failed to create handles');

Any ideas of a fix?

Thanks in advance.
inserted: 2017-09-11 21:01:36   Reply...
From: tk
I am not sure Cocoa widgetset is ready for reasonable use. I remember having numerous problems when just trying it but it was a year ago or two.
inserted: 2017-09-11 23:25:00   Reply...
From: Josh
Hi TK,

The Cocoa widgetset has come a long way since then, and is actively being developed.
So far most components I have tried now have worked flawlessly, stringgrid is even working now, even though I don't use it.(latest trunk required as fixes seem to be applied nearly daily).
It would be a shame if KGRID could not be used with cocoa, as I think we have less than a year before Apple drop 32bit hence carbon; in favour of 64bit.
inserted: 2017-09-18 11:17:10   Reply...
From: tk
I am sorry but it seems TLazIntfImage is not ready for the Cocoa widgetset. If you need to use KGrid with Cocoa then push towards the Cocoa widgetset developer(s) to make the needed format work.

FYI: I just updated Laz from trunk on my El Capitan and tried various KControls components with Cocoa. The numerous problems I spoke about persist so I still deem the Cocoa widgetset absolutely unprepared for solid usage.
inserted: 2017-08-10 13:01:50   Reply...
From: см
Hi Tk,
I found some odd things in the behaviour of TKMemo.

Case 1. If the code below is executed as it is, it will be executed without a crash, but there will be a delay (in my case 2,5 s) shown in line
    ShowMessage ('Unlock done in ' + IntToStr(dotime) + ' ms');
    Results will be similar, if line ...//CommentLine1 is commented.

Case 2. If the code is executed after commenting the following two lines:
   NestedTable.Cells[0,0].Blocks.Text:=IntToStr(Random(10000)); //CommentLine1
   KMemo1.blocks.unLockUpdate; //CommentLine2
the entire code will be executed much faster (NestedTable.Rows[0].Cells[0].BlockStyle.Brush.Color:= clred; will take less that 16 ms).

Case 3. If line ...//CommentLine2 is commented and line ...//CommentLine1 is NOT commented
the application crashes.

So what bothers me:
  in Case 1:
    Since KMemo1 is not visible, there is no reason to perform any unlock activities. But such activities are obviously done, since 2,5 s are spent on them.
  in Case 2:
    Probably there is no reason to spend whole 2,5 seconds for performing
NestedTable.Rows[0].Cells[0].BlockStyle.Brush.Color:= clred;
    because in this case it is executed and shown properly for less than 16 ms. I suppose execution could be sped up?
  in Case 3:
    A crash is always a reason to worry.

Code is executed in Lazaruis1,8RC3 with KControls from 06.VII.2017.


function RandomString:String;
var
  Len: integer;
  i: integer;
  RetVal: string='';
begin
  Len:=trunc(Random*1000);
  for i:=0 to Len do
  begin
    RetVal:=RetVal+ char(trunc(Random*125)+30);
    if len mod (trunc(random*50)+1)=0 then RetVal:=RetVal+#13#10;
  end;
  Result:=RetVal;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
   row, clm: integer;
   MergeSpan: TKCellSpan;
   StartTime,DoTime: Int64;
   NestingTable: TKMemoTable;
   NestedTable: TKMemoTable;
begin
  KMemo1.blocks.LockUpdate;
  KMemo1.Blocks.Clear;
  KMemo1.Blocks.AddTextBlock ('1');
  KMemo1.Blocks.AddTextBlock ('2');
  NestingTable:=KMemo1.Blocks.AddTable;
  NestingTable.ColCount:=1;
  NestingTable.RowCount:=1;
  NestingTable.CellStyle.BorderColor:=clRed;
  NestingTable.CellStyle.BorderWidth:=1;
  NestingTable.RequiredWidth:=500;
  NestingTable.FixedWidth:=True;
  NestingTable.ApplyDefaultCellStyle;

  NestedTable:=NestingTable.Cells[0,0].Blocks.AddTable;
  NestedTable.ColCount:=3;
  NestedTable.RowCount:=2*300;
  for row:=0 to NestedTable.RowCount-1 do
    for clm:=0 to NestedTable.ColCount-1 do
        begin
           NestedTable.Cells[clm,row].Blocks.AddTextBlock('Ln'+IntToStr(row)+';'+'C'+IntToStr(clm));
           NestedTable.Cells[clm,row].Blocks.AddParagraph;
           NestedTable.Cells[clm,row].Blocks.AddTextBlock(RandomString);
           NestedTable.Cells[clm,row].Blocks.AddParagraph;
           NestedTable.CellStyle.BorderColor:=clBlue;
           NestedTable.CellStyle.BorderWidth:=1;
           if ((clm=0) and (row in [4,5])) then NestedTable.Cells[clm,row].Blocks.Clear;
           if (row mod 3=0) and (row>2) then
             begin
               MergeSpan.ColSpan:=1;
               MergeSpan.RowSpan:=3;
               NestedTable.CellSpan[0,row]:=MergeSpan;
             end;
        end;

   NestedTable.ColWidths[0]:=50;
   NestedTable.ColWidths[1]:=50;
   NestedTable.ColWidths[2]:=200;

   NestedTable.ApplyDefaultCellStyle;
   KMemo1.blocks.unLockUpdate;
   ShowMessage ('Memo populated');
   KMemo1.Visible:=False;
   KMemo1.blocks.LockUpdate;
   NestedTable.Rows[0].Cells[0].BlockStyle.Brush.Color:= clred;
   NestedTable.Cells[0,0].Blocks.Text:=IntToStr(Random(10000)); //CommentLine1
   StartTime:=GetTickCount64;
   KMemo1.blocks.unLockUpdate; //CommentLine2
   DoTime:=GetTickCount64-StartTime;
   ShowMessage ('Unlock done in ' + IntToStr(dotime) + ' ms');

   StartTime:=GetTickCount64;
   KMemo1.Visible:=True;
   DoTime:=GetTickCount64-StartTime;
   ShowMessage ('Set visible done in ' + IntToStr(dotime) + ' ms');
end;
inserted: 2017-08-11 13:47:28   Reply...
From: tk
All 3 cases are normal/not a bug:
1. UnlockUpdate always forces the calculation of entire memo content to determine block positions, extents, etc., regardless of the memo visibility.
2. Changing font color has the same consequences as changing font size or font name. Entire memo content will be recalculated, although in this case it is not really necessary. Reason is VCL TFont class offers only generous OnChange event and not eg. OnNameChange, OnColorChange etc.
3. If you miss UnlockUpdate call after a LockUpdate, the memo behavior will be unpredictable, causing possibly exceptions/crashes. You must always pair them in your code, preferably using a try-finally section.

To speed it up now there are only 2 options as I said already:
1. Use smaller tables/documents.
2. Use another control for tables, eg. KGrid.
inserted: 2017-08-11 16:35:03   Reply...
From: см
Thanks for the clarification.

Currently I am doing the following trick:
  Code1:
    MyMemo.Visible:=false;
    DisplayTable.Blocks.LockUpdate;
    DisplayTable.BlockStyle.Brush.Color:=NewColour;
    MyMemo.Visible:=true;
and it works literally a thousand times faster than with the following code:
  Code2:
    DisplayTable.BlockStyle.Brush.Color:=NewColour;
or with:
  Code 3:
    DisplayTable.Blocks.LockUpdate;
    DisplayTable.BlockStyle.Brush.Color:=NewColour;
    DisplayTable.Blocks.UnLockUpdate;

Actually both Code2 and Code3 are equally slow.

Currently (with the trick from above and with your latest fix), I can rather say that I do not have speed issues when working with RTFs, but I use TKMemo mostly in view mode.
During generation conversion of PNGs to RTFs seems quite slow (>200 ms for image 400x325 pixels), other items seem fine from the viewpoint of speed.
inserted: 2017-08-13 11:39:39   Reply...
From: tk
You could also use some cleaner solution to circumvent the problem with generous Brush/Font OnChange event when just changing the color. For example:

var OnChangeOld: TNotifyEvent;

OnChangeOld := DisplayTable.BlockStyle.Brush.OnChange;
try
  DisplayTable.BlockStyle.Brush.OnChange := nil;
  DisplayTable.BlockStyle.Brush.Color := NewColor;
  KMemo1.Repaint;
finally
  DisplayTable.BlockStyle.Brush.OnChange := OnChangeOld;
end;
inserted: 2017-08-16 09:51:12   Reply...
From: см
Thanks,
I didi it this way, so far it seems just fine.
inserted: 2017-08-03 17:46:22   Reply...
From: tudi_x
hi,
are there any plans to release a new version of KControls that would be compiling with no issues on Lazarus 1.8RC3?
currently i added {$IFDEF FPC}LazUTF8,{$ENDIF} in order to compile.
also border style on KMemo does not seem to work.

thank you
inserted: 2017-08-03 17:53:02   Reply...
From: tudi_x
{$IFDEF FPC}
property BorderStyle default cBorderStyleDef;
{$ELSE}
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default cBorderStyleDef;
{$ENDIF}

how would the borderstyle be set in Lazarus/FPC?
inserted: 2017-08-06 11:34:54   Reply...
From: tk
To be honest, I don't know why things like 1.8 RCx come when the trunk already has 1.9. Haven't used these (IMO useless) intermediate versions so far. KControls should compile fine in latest stable version (currently 1.6.4) and recent trunk (1.9). If you cannot live with latest stable (1.6.4) then I strongly recommend using the trunk and update it through fpcupdeluxe in case some problems arise. The same for FPC.

BorderStyle normally works for me in some older trunk (1.7) and recent trunk (1.9). In Delphi I had to re-implement this property for TKCustomControl, for Lazarus default LCL behavior is used. If it does not work in Lazarus then there is clearly a bug in your 1.8 RC or your own code.
inserted: 2017-08-01 13:55:12   Reply...
From: см
Hi Tk,
I have come across the following problem- when updating elements in a form, containing a TKMemo, this action takes very long time.
The elements themselves are not related with the TKMemo.
I have created a thread with a sample in https://forum.lazarus.freepascal.org/index.php/topic,37704.0.html

I suppose something gets triggered in TKMemo without a reason. I hope you could check if the issue is fixable?
inserted: 2017-08-06 15:24:13   Reply...
From: tk
I've tested your sample (labellag.zip) and your table is very big. This causes delays even when building the table. KMemo is not suitable for such a big table. It takes a long time to calculate extents for all cells, characters in them etc. It is not like KGrid which is ready for even bigger tables and fast enough. Please use StringGrid or KGrid for bigger tables to avoid such delays. Some speed-up optimization could be implemented in KMemo in future, though, but do not count with massive speed up.

The delay in TForm1.Button2Click (changing the label caption) is caused by LCL which silently invokes TKMemo.Resize as a result of its internal autosizing operations, forcing the memo to recalculate its entire content like after resizing just the memo. I've modified the KControls trunk to ensure that each TKCustomControl descendant like KMemo only recalculates its content after its client area has really been modified. Hopefully this fix did not break anything else.
inserted: 2017-08-07 08:51:46   Reply...
From: см
Thanks for the fix, now the lag is gone...
but there is some problem with content of memo not showing at all.
I will try to reproduce separately and feedback.

If this could be a hint:
I have noticed (before) that
  KMemo1.Lockupdate.....some code....KMemo1.UNLockupdate
results in the contents of the memo not shown, so I use
  KMemo1.blocks.Lockupdate.....some code....KMemo1.blocks.UNLockupdate
which works fine.
Behaviour I observed now seems quite similar (memo not shown, scrollbar displayed as if there is content).


BTW, I have made a greater table, to demonstrate the lag better, but indeed I am fullly aware that bigger RTFs are a problem.
inserted: 2017-08-07 09:04:07   Reply...
From: см
The hint happened to be a hint for me. I tracked down all ..memo.(un)lockupdate and replaced them with ..memo.blocks.(un)lockupdate and behaviour seems okay.

You wrote „..The delay in TForm1.Button2Click (changing the label caption) is caused by LCL...‟. If this behaviour is not observed in Delhi, probably there is a bug in LCL?
inserted: 2017-08-07 09:33:15   Reply...
From: tk
I am not sure if this happens in Delphi as well, will test it later. But according to http://docwiki.embarcadero.com TControl.Resize should be called automatically immediately after the control's dimensions change. I am pretty sure the same meaning should be in LCL so we might consider this to be a bug.
inserted: 2017-07-28 22:57:44   Reply...
From: inferno
How to change the checkbox state (Checked property) for new created or cleared rows - TKGrid.RowCount:=X, KGridDiskClips.ClearRow(X), etc.
inserted: 2017-07-28 23:10:02   Reply...
From: inferno
I found it - in initialization of the cell :)
inserted: 2017-07-27 11:15:49   Reply...
From: Silvio
Hi,

i want to use Borderspacing-property of KGrid. If i change the property it is shown in IDE until closing the IDE. In the lfm-File it changes the Top and Left property instead of inserting Borderspacing-property. After restart of IDE Anchor-Property overwrites the Top and Left property. Also in the User-program Anchor without Borderspacing overwrites the Top and Left property.

I this a known problem? Is there any solution?

Silvio
inserted: 2017-08-01 10:07:59   Reply...
From: tk
Well, it is a Lazarus only property. Haven't used this so far. Please first check it works well for some standard LCL controls, such as TStringGrid. If not then there might be bug in LCL, from your description it sounds probable.
inserted: 2017-07-25 13:07:55   Reply...
From: Davo
Hi Folks, I'm back ....
I am trying to change the style of text in a TKMemo.
I have tried KMemo1.SelectionTextStyle.Font.Style but it changes the whole block where the end of the selection is. If selection spans blocks, the first part is unchanged.

Am I misunderstanding just how this function works or is it not implemented yet ?
I assume this operation must break up existing blocks so is quite complicated.

Functions like ClearSelection and SelText behave as I'd expect, work on exactly
what is selected.
inserted: 2017-08-01 09:56:50   Reply...
From: tk
Look in kmemofrm.pas how this property should be used.
inserted: 2017-08-05 10:41:04   Reply...
From: Davo
Thanks tk. Not clear enough for me I'm afraid. I guess I have to accept I'm not quite ready to use a package like this yet. Pity, it really seems to have everything I want (except, perhaps documentation suited to a user like me).
Thanks anyway.
inserted: 2017-08-09 10:27:47   Reply...
From: tk
Since KMemo is not a simple control and it is not completed yet including its docs, it needs lot of studying and testing if you want to do something more specific. Plus you should have enough experience with common VCL/LCL principles as well.

But in your case things should be rather simple. Just select some text in the memo and use:

Editor.SelectionTextStyle := MyTextStyle;

This will change the text style for any text blocks within current selection. It will split existing text blocks where the selection begins or ends, if necessary. Again this applies for the most recent KControls version from the bitbucket, there might be bugs in older code.
inserted: 2017-07-25 00:08:44   Reply...
From: wes
I had trouble compiling in Delphi 2010, getting error in KFunctions.GetFormatSettings on the line Result := TFormatSettings.Create.

In Delphi2010 SysUtils.TFormatSettings is a record not a class.

Changing the define from COMPILER12_UP to COMPILER15_UP solved the problem for me.
inserted: 2017-08-01 09:53:25   Reply...
From: tk
Thanks, I'll fix this in the trunk.
Older comments
My account
Recently modified

KControls Component Suite

by: tk

2015-11-16

KHexEditor

by: tk

2010-11-08

KGrid

by: tk

2010-11-08

KIcon

by: tk

2009-11-24

KGrid 1.3 released.

by: tk

2009-08-10

Recently inserted

ONEinspect

by: tk

2016-04-12

Grouping of comments

by: tk

2015-11-16

KMemo

by: tk

2015-08-12

My recent work on KMemo

by: tk

2015-07-28

Update for RAD Studio XE2

by: tk

2012-04-03