Change progressbar color - delphi

I have a progressbar in my form and I need to change its color. I need it to be Yellow and so I am using this code:
SendMessage(ProgressBar5.Handle, PBM_SETBARCOLOR, 0, clYellow);
I am using Lazarus and I couldn't use the SendMessage(); procedure. Then I have googled a bit and I found that I need to include in the uses the lclintf library.
Now I have another hassle because Lazarus can't recognize the parameter PBM_SETBARCOLOR. In fact it states:
unit5.pas(245,50) Error: Identifier not found "PBM_SETBARCOLOR";
I see that the first line of code that I wrote is the only way to change the color of a ProgressBar from green to the one I need.
Any help? I am using the latest version of Lazarus.

The PBM_SETBARCOLOR is declared in the commctrl.pp unit of freepascal, same as in Delphi.
You could also declare it as a constant with value 1033 (WM_USER + 9).

Related

Delphi tesseract wrapper does not recognize font names

I'm using Delphi Tesseract wrapper which is available at https://github.com/CloudDelphi/TTesseractOCR4. Based on example here: Get font of recognized character with Tesseract-OCR I should call api.GetIterator() method to get WordFontAttributes(). As I see Delphi wrapper does not support api.GetIterator() directly but has TTesseractPageLayout.AnalyseLayout function to access GetIterator().
In OnRecognizeEnd I call AnalyseLayout, which returns words' texts but not font names:
Tesseract.PageLayout.AnalyseLayout;
for TesseractWord in Tesseract.PageLayout.Words do
begin
memo1.Lines.Add(TesseractWord.Text);
memo1.Lines.Add(TesseractWord.FontName);
end;
Could you please help me to resolve the issue?
It seems that you are using tesseract version >= 4.0.0.0.
On those versions, the recognition is done with neural networks (LSTM engine), so the font name is not available. The latest version that you can get the font name, is version 3, which uses the old engine.
You can read about it in the following links (user summited issues on official github repo):
https://github.com/sirfz/tesserocr/issues/292
https://github.com/tesseract-ocr/tesseract/issues/3820
https://github.com/tesseract-ocr/tesseract/issues/1074

TListView truncate hints when using styles

I have a problem with TListView when using Application styles.
Sometimes the hints are truncated. It depends on spaces and length of words in the string.
For example:
'1518 ZL Danovy doklad odeslany' is truncated
'1518ZLDaňový doklad odeslaný' ' is OK
This is happening in Delphi 10.2.1! In Delphi XE7, it was all OK! So I think it must be some kind of bug in this version.
Is there any way of fixing it, or a workaround?
ScreenShot of problem:
Simple project:
https://www.dropbox.com/s/q30i9vlejt1vst7/ListViewTest.7z?dl=0
Things I tried:
removing the LVS_EX_INFOTIP flag (with ViewStyle.vsIcon not working):
ListView_SetExtendedListViewStyle(
ListView1.Handle,
ListView_GetExtendedListViewStyle(LV.Handle) and not LVS_EX_INFOTIP
);
Removing the style from TListView as here:
How to disable VCL styles in Delphi

Why Cocos Creator engine file is not called on the browser?

Non-Latin characters are not truncated properly so I modified the fragmentText() function to truncate on white space. file is in:
"C:\CocosCreator\resources\engine\cocos2d\core\label\CCTextUtils.js"
fragmentText: function (stringToken, allWidth, maxWidth, measureText) {
return "function called";
}
The problem is that I see the changes in Cocos Creator editor and the text is truncated as I want, but I see no effect on the browser as the function is never called.
Why the function is not called when I build?
P.S: I use Cocos Creator 1.10 but also have 2.1.1 installed in C:\CocosCreator_2.1.1
I guess you forget to recompile the engine.
Check the step 1.3 on the website and try again.
1.3 Change and Build

Ng-Tag-input minLength not set property

I use this library in my ionic project (Cross platform mobile application), And I try to set minLength : 1 but it takes default value (i.e. 3). How can i achieve this?
Set the min-length="1" property to the <auto-complete> instead of <tags-input> to get suggestions for every character.
like this:
<tags-input ng-model="vm.tags">
<auto-complete source="vm.loadTags($query)"
min-length="1"
highlightMatchedText="true">
</auto-complete>
</tags-input>
Even I spent a few hours figuring out how to do it, it later flashed me when I read the documentation of autoComplete again.
http://mbenford.github.io/ngTagsInput/documentation/api#autoComplete

Delphi: EReadError with message 'Property Persistence does Not Exist'

My program written with Delphi 7 compiles OK, but when I run it it gives me the error message:
Project1.Exe raised exception class EReadError with Message 'Property Persistence does Not Exist'. Process Stopped.
This only started after I installed the TMS Component Pack to use with this project. Thanks for any help.
Open the Form in Delphi IDE
Use Alt + F12 to edit the .DFM source
Search the "Persistence" property
Delete the line with "Persistence" property
DFM example:
SomeComponent1 = TSomeComponent
OtherProperty = OtherValue
Persistence = True
AnotherProperty = AnotherValue
end
Also you can use the great DFMCheck 1.4 tool, by Andreas Hausladen. To check any other missing property like that:
http://andy.jgknet.de/blog/?page_id=177
This is most likely caused by the compiled & installed package being out of sync with the actual .pas file. If you have source code then rebuilding the packages will probably fix it.
Set a breakpoint(F5) and step the program(F7/F8).Get to the location where you get that exception and then give us more information about it(show some code).
This error means that it's trying to load something (usually a form) from a DFM resource and it comes up with a value for a property that the component it's creating doesn't have.
If it only happened when you started using TMS components, the solution is simple: don't use them. Send as much information as you can about the error and the project that caused it to the authors and see if they can find a way to fix it. Until then, use something else.
If you're using text DFMs (right click on the form, check "Text DFM", save), you can use Search|Find in Files to find all instances of Persistence in your DFM files. Just set the search string to "Persistence" (I usually tell it to ignore case), the file mask to "*.dfm", and check the "All files in project" checkbox.
If you're not already using text DFMs and don't want to manually open all forms and check the box and then resave them, you can use CONVERT.EXE (in the ($DELPHI)\Bin folder) to convert them en-masse. Run CONVERT with no parameters from any command prompt to see the options. By default, CONVERT will save .DFM as .txt, but you can have it work in-place (rewriting the binary .DFM as the text .DFM) by using the -i switch. (I usually back up the .DFMs to a different folder first, then convert them. If no errors are reported, I can then delete the backed up .DFMs later.)
I had similar problem with TMS when I upgraded to a new version:
If you think that some particular component is causing the problem,
delete it , compile project without it, place it on the form/frame again.
If that doesn't work for you:
Things you need to do in order to fix the problem , so you can use Designer and new properties, because that's what you really want , don't you ? :-) :
Uninstall TMS Component Pack ( or whatever you're using )
Re-Install TMS Component Pack
Build & Install the packages
Add appropriate TMS .lib files to your Application Project ( I'm using C++ Builder )
Add appropriate TMS .pas files to your Application Project . For example I had a problem with TAdvSmoothCalendar component , so I've added the AdvSmoothCalender.pas to my project.
Cheers!
I hope it works for everyone with a similar problem :)
I had similar problem with nuiGui Delphi Framework,
To Solve this, create a include file with some properties and use it in your class.
/// include class 'Basic.inc'
private
function GetWidth: Integer;
published
property ClientHeight : Integer Read FHeight Write FHeight;
//property ClientWidth : Integer Read FWidth Write FWidth;
//property OldCreateOrder : Boolean Read FOldCreateOrder Write FOldCreateOrder;
end;
...
/// main class like this
TuMemoFrame = class(TUniFrame)
UniMemo1: TUniMemo;
UniMemo2: TUniMemo;
UniButton1: TUniButton;
procedure UniButton1Click(Sender: TObject);
private
public
{$Include Basic.inc } // <---
end;

Resources