Lazarus
Programming => Packages and Libraries => KOL => Topic started by: yuriy_sydorov on October 19, 2007, 12:51:15 am
-
I finally made the first public release of KOL-CE library.
Here is a project page: http://wiki.freepascal.org/KOL-CE
KOL-CE is ideal for WinCE development. EXE size of project with empty form starts from 47KB.
I hope it will be useful for all.
-
That's a gret news, really! I have just dropped a WinCE project because its big size :D
Just a question: do you think it could be possible to use KOLCE and SQLite in the same project?
-
Sure. You can use database access components from FCL in KOL project. It will add 300-500KB to exe.
Also you can use some lightweight SQLite units which is not based on TDataSet. In such case there will be less footprint on exe size.
Also dont forget KOL does not have specialized DB controls (TDataSet based). You need to display data from tables using standard listview or something else.
-
Great news, Yuri, that you ported KOL to wince.
-
Yes. Currently it is the first production ready GUI toolkit for FPC and WinCE. :)
P.S: I already created commercial product using KOL-CE: http://www.cp-lab.com/windows-mobile.html
If you look at screenshots you will see how powerful KOL-CE.
-
I have installed Lazarus v0.9.23 fpc 2.2.1 with cross arm wince.
I have installed a KOL-CE without problems.
I have tried to compile a program under arm-wince but I got the next error:
C:\lazarus\components\kol\KOL.PAS(57901) Error: Error while linking
If I compile a Win32 application it works well.
Some idea to fix this?
Thanks.
-
You need to edit Windows PATH environment variable and add path to folder where win32 fpc binaries are located.
-
I do not understand you.
You can help me more?
Thanks.
-
Do you have the same version of cross arm-wince and fpc from lazarus (which is 2.2.1)?
-
kakarotv5: Read here about editing PATH: http://wiki.freepascal.org/KOL-CE#Usage
-
Do you have the same version of cross arm-wince and fpc from lazarus (which is 2.2.1)?
Yes, I have installed Lazarus (Lazarus-0.9.23-fpc-2.2.1-20071017-win32.exe) with cross arm wince (Lazarus-0.9.23-fpc-2.2.1-20070916-cross-arm-wince-win32).
-
kakarotv5: Read here about editing PATH: http://wiki.freepascal.org/KOL-CE#Usage
Thank you very much, I have solved the problem.
KOL-CE is a very good tool for the programmers of pocket computers.
-
After trying to install Kol-ce since it was released a week ago without any luck, I though I would do a clean reinstall of everything. However, I still can't get the package to install. This is what I have done:
Installed FPC 2.2.0 and Lazarus 0.9.2.23 to default directories.
Installed Lazarus cross arm to default.
Copied Kol-ce dir. to Lazarus directory.
Started Lazarus.
Opened MirrorKOLPackage
Entered install:
"The package "MirrorKOLPackage 2.80" was marked for installation. Currently lazarus only supports static linked packages. The real installation need rebuilding and restarting of lazarus. Do you want to rebuild Lazarus now?"
Answering yes => "C:\lazarus\kol-ce-2.80\mck\MIRROR.PAS(88,15) Fatal: Can't find unit Forms used by mirror"
Removed package from installation
Recompiled Lazarus via tools rebuild. No errors.
Tried opening MirrorKOLPackage again, installed. It asks to rebuild lazarus:
=> "Unable to find file "forms.pp"
Check search path in Project->Compiler Options...->Search Paths->Other Unit Files."
Added path to forms.pp and wslclclasses.pp and tried install again.
=> "C:\lazarus\lcl\actnlist.pas(342,2) Fatal: Can't open include file "containedaction.inc""
Added path to include in include files under compiler action.
=> same error.
Added absolute path to include file =>
"Unable to find file "componenteditors.pas" Check search path in Project->Compiler Options...->Search Paths->Other Unit Files."
Added paths to ideintf and lcl\forms.=>
"Ambiguos unit found.
The unit baseideintf exists twice in the unit path of the IDE:
1."C:\lazarus\kol-ce-2.80\mck\lib\i386-win32\baseideintf.ppu"
2. "c:\lazarus\ideintf\units\i386-win32\baseideintf.ppu"
Hint: Check if two packages contain a unit with the same name."
Abort or ignore, Entered ignore. Same errors with
+ checkgroupeditordlg.ppu, checklistboxedirodlg.ppu, columndlg.ppu
componenteditors.ppu, frmselectprops.ppu, ideexterntoolintf.ppu,
dewindowintf.ppu,lazideintf.ppu +75 others.
Entered ignore on all. =>
Unable to find mirror.pas
I tried to add the path to this under compiler options, other units, but
after selecting it and clicking ok, it didn't show up on the path line. I
also tried typing it in, but it disappeared when I went out of compiler
options.
I guess I'm really stuck. Any ideas? I was really hoping that I could use
this to program for my Pocket PC, so that the exe file wasn't so big.
Thanks!
-
I made it to compile at the first time compilation simply by putting the kol-ce directory under components. Maybe this will help:
1. Copy all and hidden messages to clipboard, and check with a text editor (messages tab doesn't show everything). This message: "C:\lazarus\kol-ce-2.80\mck\MIRROR.PAS(88,15) Fatal: Can't find unit Forms used by mirror"
possibly not the real error.
2. This one: "C:\lazarus\lcl\actnlist.pas(342,2) Fatal: Can't open include file "containedaction.inc""
menas that Lazarus tries to recompile LCL, which shouldn't happened.
3. Don't add path to LCL source, it will only complicate the errors. That's why "Ambiguos unit found.
The unit baseideintf exists twice in the unit path of the IDE:
1."C:\lazarus\kol-ce-2.80\mck\lib\i386-win32\baseideintf.ppu"
2. "c:\lazarus\ideintf\units\i386-win32\baseideintf.ppu"
Hint: Check if two packages contain a unit with the same name."
Abort or ignore, Entered ignore. Same errors with
+ checkgroupeditordlg.ppu, checklistboxedirodlg.ppu, columndlg.ppu
componenteditors.ppu, frmselectprops.ppu, ideexterntoolintf.ppu,
dewindowintf.ppu,lazideintf.ppu +75 others.
Entered ignore on all.
appears, because kol-ce package has also compiled the LCL, and if you see under its compiler options, in unit output directory you'll see "lib\$(TargetCPU)-$(TargetOS)". This means EVERYTHING that this package compiles will be in that directory.
4. Read this (http://wiki.freepascal.org/KOL-CE) before going any further.
-
Installed FPC 2.2.0 and Lazarus 0.9.2.23 to default directories.
I suspect FPC versions conflict. Lazarus comes with some version of FPC already. Usually you dont need to install fpc separately. Maybe you downloaded Lazarus with fpc 2.2.1 bundled with it, but MCK package is compiled by fpc 2.2.0 or vice versa...
-
Thanks to everyone!
I tried to remove the path references and removed the separate Free Pascal installation, but got the same errors. So again I removed Lazarus completely, deleted the Lazarus and Free Pascal directories, restarted the computer and reinstalled Lazarus and the crossarm version.
Everything compiled to a WIN32 application, so I tried the Wince version. I added the environment paths in Windows and compiled to a 54kb application (only one component)!
Thanks again!
-
How I add a text in new line?
I do it for example:
KOLMemo1.Add('Hello' + #13 + 'This is a newline');
But I obtain this:
(http://i8.tinypic.com/6bogmft.jpg)
EDIT: I have solved this with:
KOLMemo1.Add('Hello' + #13#10 + 'This is a newline');
-
Free Pascal comes with a constant that represents a line end on all platforms, use that instead:
'Hello' + LineEnding + 'This is a newline'
-
Hi! i have small problem with kol-ce. Every build is successfull but.. my aplication has only one form and after compile have over 1MB and harder problem is in wince. if i run my aplicaion on my PDA i dont see form. ony name of program is visible. do you now where is the error ? thx
-
Set form's defaultSize and defaultPosition to True.
Turn on "Strp symbols..." option and you should have exe 40-50KB.
-
Hey, great work, I'm still having some problems though.
I create a project with form and KOLProject, KOLForm, KOLApplet, defaultSize/Position = True, and a few components that have the correct anchors set. However, when opening on my PPC, everything stays the same size/position as design time, instead of correctly scaling to screen size. In other words, it looks like the anchors don't work. Solution?
-
You need to use the following trick to make anchors work:
Put borderless panel on a form. Do not align the panel. Then place all your gui to this panel.
Then align the panel to caClient using code in OnCreate event handler for a form.
-
Thanks, works like a charm. Convert one of my pet projects from LCL-CE to KOL-CE with only minor inconveniences. If you care to check it out: WMWifiRouter (http://www.jongma.org/WMWifiRouter/). Next up is KaiserTweak (http://www.jongma.org/KaiserTweak/), but it will probably be quite a bit more work :)
-
Congratulations :) You can add link to WMWifiRouter to KOL-CE wiki :)
-
Hey, great work, I'm still having some problems though.
I create a project with form and KOLProject, KOLForm, KOLApplet, defaultSize/Position = True, and a few components that have the correct anchors set. However, when opening on my PPC, everything stays the same size/position as design time, instead of correctly scaling to screen size. In other words, it looks like the anchors don't work. Solution?
On the KOLForm component, set defaultposition and defaultsize both to true.
I've found that when my form is 204 high by 319 wide, it's the exact size that it will be when it's maximized on my landscape device. I'm only sharing that so you can see where you'll be able to place your components on the form.
-
I feel really stupid, and it's not the first time in my life. I can't figure out what code I'm supposed to put in the menu click to exit my application. On my physical phone, I can always run task manager, but on my emulator, I don't have task manager.
-
I can't figure out what code I'm supposed to put in the menu click to exit my application.
Application.Terminate;
-
I can't figure out what code I'm supposed to put in the menu click to exit my application.
Application.Terminate;
It is not LCL. :)
You need to call Form.Close;
-
u
Application.Terminate;
See, that's why I feel stupid about it. I tried that, and it won't compile:
unit1.pas(58,14) Error: Identifier not found "Application"
-
You need to call Form.Close;
I thought for sure that would work, but I get:
unit1.pas(58,10) Error: identifier idents no member "close"
unit1.pas(58,15) Error: Illegal expression
-
Hmm, strange...
Try Form^.Close;
Are this errors from compiler or IDE code explorer?
-
Same error. I'm seeing them in the message box of the compiler. I am, of course, using Form1.Close; and Form1^.Close, as my form is called Form1. When I change it to Form.Close, that works. See, I'm still feeling stupid!
-
Read this: http://wiki.freepascal.org/KOL-CE#IMPORTANT
You need to use Form field to access form's propertied. Like this: Form1.Form.Close;
or simply Form.Close; if the code is placed inside form's method.
-
I have just installed KOL-CE on my computer and I cannot compile my test project because of error that were described here before:
Compiling resource D:\Projects\Lazarus\!Packages\KOL\kol\KOL-CE.rc
gcc: Warning: `-x c' after last input file has no effect
gcc: No input files
C:\lazarus\fpc\2.2.0\bin\i386-win32\arm-wince-windres.exe: no resources
D:\Projects\Lazarus\!Packages\KOL\kol\KOL.pas(57901) Error: Error while linking
D:\Projects\Lazarus\!Packages\KOL\kol\KOL.pas(57901) Fatal: There were 1 errors compiling module, stopping
I have added directory
C:\lazarus\fpc\2.2.0\bin\i386-win32\
to the PATH system variable, restarted Lazarus several times, but no success - the error is still here. I have checked that PATH is correct by typing in console "set PATH" and it shows that the directory above is in PATH variable.
Is there anything I can do in this situation? I ran out of ideas... :(
-
Try to execute arm-wince-windres.exe from command prompt when current directory is C:\
I bet it will not be found.
-
No, I just tried to launch arm-wince-windres.exe from other directories (including C:\)and it worked, so the PATH variable is correct.
-
Maybe windres do not like "!Packages" folder name. Try to rename it to "Packages"...
-
Yes, it works now! Thank you, Yuri! :)
-
Hello Yury,
I have one suggestion with KOL&MCK on WinCE (CePlatform = cpWinCE). I think that devices with WinCE 4.2 core does not have aygshell.dll. When I create simple project in MCK (or KOL) without menu always is called AYGSHELL.SHCreateMenuBar - solution of this allow using KOL&MCK in devices which does not have aygshell.dll - WinCE 4.2 cores in Symbol BarCode scanners.
Is it possible?
Regards
jabu
-
KOL-CE supports only PocketPC and Smartphone editions of wince. I will add support for "pure" wince later. You can try to add such support by yourself and send patches to me...
-
This KOL-CE really rocks, but you have to be really careful NOT to drop any LCL components on your form.
That mistake is easily made... I think Yury should describe the steps to take when it happens... when the question pops up what to do with the LCL-component, what happens when the MCK TKolForm dissapears from the form, when things are Locked...
I did manage to resolve, but it took some time to figure out...
John
-
also:
TKolEditbox seems to forget its TextAlign.
If set to taRight or taCenter, it looks ok at designtime, but it reset to taLeft at runtime.
John
-
Hi,
If I set TKolDateTimePicker to my local dateformat (e.g. Format:='dd-mm-yyyy', I get a couple of squares instead of a date. How to to set the dateformat?
At runtime, DateTimePicker1.DateTimeFormat:='dd-mm-yyyy' gives the same result.
tia!
John
-
Hmmm, quite active with the KOL-CE package, so more issues arise while at work... ;-)
What about the fonts? If I change the color property of a TKollabels font, the size changes too... is this by design?
tiaa !
John
-
By default there is no font set at all. System default font is used. If you want to use fonts you need to set proper font name and font height for TKOLForm. Then you can adjust fonts for child controls.
I suspect that it is a bug in dateformat handling in TKolDateTimePicker. Please submit bug on KOL-CE page at SourceForge.
WinCE does not support text align in single line edot control. Try to use TKOLMemo.
-
Hi,
Using KOL-CE, I can no longer set the Borderstyle to bsDialog to make the x-button change into ok and close the application.
Is there a way to achieve this using KOL-CE (or to get rid of the x-button at all?)
John
-
ok-button is displayed for modal froms, which are called using ShowModal.
-
I'm using kol-ce to write an app for a wm5 smartphone. It works great! Thank you!!
I had problems with the installation - the usual
---------
Compiling resource KOL-CE.rc
arm-wince-windres.exe: no resources
KOL.PAS(57901) Error: Error while linking
KOL.PAS(57901) Fatal: There were 1 errors compiling module, stopping
----------
errors. After many install-remove cycles, it now finally works. I'm not sure what I did right this time. It could be that It was the following: when opening the environment variables dialog, there are two setting for "path": one for the user, one for the system (1st called PATH, 2nd one is called Path). I also set the system Path to point to the right place, not only the user PATH.
Anyway - now it works.
I have a question:
As recommended, I use defaultPosition=true, defaultSize=true, so that the form is full screen on the device.
Inside the form I have labels, for which I set AnchorBottom=true. Indeed, when I resize the window, they move with the bottom of the window.
The problem is the original resize. The window is resized to the default size, but the Labels don't move. So they get somewhere random in the window
(not random, really, just not where I want them), and then resize moves them relative to that place.
Is it somehow possible to have the original resize of the TKOLForm also affect widgets?
-
It is known issue.
Put all controls into panel. Do not align panel at design time. Set panel alignment to caClient in OnCreate event of the form.
-
Thank you! That works. (I still have to figure out how to make all the alignments work...)
I have a second question: for my app (a calculator...) I needed to use more math functions, and exceptions. When I put "err" in "uses", I could not compile for winCE, because it seems that the library includes some code in x86 assembly in the exceptions part.
Instead I put "Math" and "SysUtils" as units, and everything seems to work fine. The program compiles to be somewhat larger (140KB - it used to be 50KB once), but it is still much smaller than the original 10MB that it was with LCL....
Should I have used KOL? How?
-
"Err" unit is not ported to fpc yet.
The only solution for now is to use sysutils for exception handling.
-
ok-button is displayed for modal froms, which are called using ShowModal.
Right. The reason I asked was because for the average user it is hard to see if a program is still running in the background.
I solved the issue by putting this code in the the project_1.inc file:
hWnd := FindWindow(nil, 'Formname');
if hWnd <> 0
then
begin
SetForegroundWindow(hWnd);
halt(0);
end;
and that solves my problem. If the program is restarted, the first instance is brought to front. Seems to work ok!
ps and thanks for fixing the date-format! :-)
John
-
It is more reliable to use JustOneActivate function to activate running instance.
Add the following code ProjectName_1.inc file:
if JustOneActivate(Form1.Form, 'MyProg') <> 0 then begin
Form1.Form.Free;
Halt;
end;
-
It is more reliable to use JustOneActivate function to activate running instance.
Add the following code ProjectName_1.inc file:
if JustOneActivate(Form1.Form, 'MyProg') <> 0 then begin
Form1.Form.Free;
Halt;
end;
?? This gives me an AV when calling JustOneActivate.
-
Did you put this code into ProjectName_1.inc file and replaced Form1 with name of your main form?
-
Did you put this code into ProjectName_1.inc file and replaced Form1 with name of your main form?
Yes I did. It seems I cannot access Form1. If I force the program to stop in any circumstances this way:
if TRUE // JustOneActivate(Form1.Form, 'MyProg') <> 0
then
begin
Form1.Form.Free;
Halt;
end;
the same AV occurs.
If I change the code to:
if JustOneActivate(applet, 'MyProg') <> 0
then
begin
Applet.Free;
Halt;
end;
it seems to work ok, but is this the right way?
John
-
Hi Yury,
In my application I need to give the user the possibility to draw a little picture using the stylus. This works Ok using TKolPaintbox. However, do you have a suggestion as how to load/save the drawing?
thanks in advance!
John
-
You can use Applet for JustOneActivate as well.
You need to paint on bitmap canvas and use paintbox for accepting stylus input and displaying bitmap contents.
bitmap can be loaded/saved using corresponding methids.
-
Set form's defaultSize and defaultPosition to True.
Turn on "Strp symbols..." option and you should have exe 40-50KB.
hello guys,
cant seem to find the "Strp symbols..." option!
where is it?
OK, fount it! COMPILER OPTIONS -> LINKING -> STRIP SYMBOLS FROM EXECUTABLE (-Xs)
but my EXE is still about 1MB... what am i missing??
ok, found it again :D LOL
i just have to use:
arm-wince-strip.exe and upx.exe
my app is 33KB now ;)
-
KOL-CE is a good good good develper tool.
how can it support the WEB Browser component?
-
but my EXE is still about 1MB... what am i missing??
AFAIK -Xs doesn't work quite well. I always recompile EVERYTHING (rtl, fcl, lcl, etc) without -gl, turns on smartlinking, and optimize the code (make smart STRIP=1 OPTIMIZE=1, the drawback is I can't quickly find out a problem if there's a bug).
-
Q1 - im having problems putting an image in a KOL project form... when i try to use Timage i get compilation errors... is it possible to use other VCLs appart from KOL ones?
Q2 - Filecopy / copyfile doenst work. The reply is TRUE but the file isnt coppied !? how can i make it work?
Q3 - I want my memo to focus on the last line and this doesnt work (sendmessage(Memo1.Handle,WM_VSCROLL,SB_BOTTOM,0);). How can i do it?
thank you guys!
:D
-
In plain Delphi: screen.cursor:=crHourGlass;
Howto set cursor in KOL-CE? I tried assigning a lot of different values to variabele screencursor, but the rotating windows screencursor never appears... can it be done using KOL-CE?
tia John
-
User the following code to get wait cursor:
ScreenCursor:=LoadCursor(0, IDC_WAIT);
SetCursor(ScreenCursor);
and back to normal cursor:
ScreenCursor:=0;
SetCursor(LoadCursor(0, IDC_ARROW));
-
Hi Yury, thanks for the cursor-code. I'll try that out. In the mean-time:
It happens a couple of times during a session.
Doubleclick on a button jumps to the eventhandler in the sourcecode. Same thing for menus, events etc.
Usually it works, a nice frame is written and I can type the code. If code is already there, cursor jumps to code.
But every now and then I get an error when doubleclick an event (on the button itself or in the objectinspector), that says (in the messages pane):
C:\lazarus\fpc\2.2.0\source\rtl\arm\arm.inc(294,36) Error: : expected, but name found
And the caret jumps to the file arm.inc (which I had NOT open, but now is opened) and points to line 294:
var
fpc_system_lock: longint; export name 'fpc_system_lock';
If I just stop Lazarus, save changes Yes, and restart, all works fine again...
John
-
Code below doesn't set Penwidth, no matter what I set it. Reading it back always shows Penwidth = 0
with abitmap.Canvas^ do
begin
pen.color := clRed;
pen^.Penwidth := 4;
moveto(StartX,StartY);
lineTo(Mouse.X,Mouse.Y);
end;
How to set Penwidth?
John
-
Doubleclick on a button jumps to the eventhandler in the sourcecode. Same thing for menus, events etc.
.....
Please report IDE bugs on the bug tracker. No one will pay attention to them on the forum.
-
Doubleclick on a button jumps to the eventhandler in the sourcecode. Same thing for menus, events etc.
.....
Please report IDE bugs on the bug tracker. No one will pay attention to them on the forum.
I would if I could make a case to reproduce the bug. And I somehow was under the impression that it had to do with KOL-CE.
-
I fixed pen width problem.
Lazarus CodeTools do not handle this code:
var
fpc_system_lock: longint; export name 'fpc_system_lock';
Please post bug report about it.
-
I may be completely overlooking this, but how do I use Unicode text with KOL components ?
-
KOL-CE uses KOLString type for strings. KOLString = widestring on wince.
-
I see. I had set this manually by now by defining UNICODE, but if you say that is not needed :)
Another question you may know the answer to: what is a good unicode font to use? I am specifically looking for one that supports CJK characters, seems "Arial Unicode MS" is not available on WinCE.
-
Hi Yury,
At runtime I like to change some captions of KOL-objects.
Most work fine, however:
TabControl1_Tab1.Caption:='test';
gives Access Violation
Is this a bug or is there another way to change the caption of a tabsheet at runtime?
tia!
John
-
Try this:
TabControl1.TC_Pages[0].Caption:='test';
-
Yuri,
I'm having strange problems with freeing objects, I get AV's.
Here's some code ($mode delphi):
var List: TStrList;
begin
List := RegEnum(OptionsKeyBase + '\Profiles')^;
// RegEnum returns PStrList
try
if List.Count > 0 then
for i := 0 to List.Count - 1 do begin
S := List.Items[i];
while (Pos('\', S) > 0) do
S := Copy(S, Pos('\', S) + 1, Length(S));
if S <> DefaultProfileName then begin
with AddProfile do begin
Name := S;
LoadFromRegistry;
end;
end else begin
Profile[DefaultProfile].LoadFromRegistry;
end;
end;
finally
List.Free; // <---- AV HERE
end;
end;
Ofcourse I have also tried with removing the code between try/finally. Seems it happens as soon as List has a string inside. Stack trace:
An unhandled exception occurred at $03F700BC :
EAccessViolation : Access violation
$03F700BC
$00011B80 fpc_help_destructor, line 423 of C:/lazarus/source/fpcbuild/2.1/fpcsrc/rtl/inc/generic.inc
$0001F574 TOBJ__REFDEC, line 14517 of E:/SoftDev/kol-ce-2.80/kol/KOL.PAS
$00029DB8 TWMWROPTIONS__LOADFROMREGISTRY, line 539 of cwmwroptions.pas
$00027590 TFORM1__KOLFORM1FORMCREATE, line 99 of unit1.pas
$0002743C NEWFORM1, line 63 of unit1_1.inc
$0001165C main, line 10 of skeleton.lpr
This is not the only place it happens either, I get it when freeing other lists as well (TList). Cannot determine what causes it, but I can't get the error to disappear either. It works if I comment out the "List.Free", but then I won't be freeing memory.
Any help, advice, etc ?
-
Can you provide complete code example which triggers this error?
-
Trying to whip something up for you :) It'll be a couple of hours.
EDIT:
I'm having a freakishly hard time reproducing the issue outside the project... Of course I'm still going to continue trying, but here is another piece of info you may find interested / could be a hint:
var
List: TStrList;
begin
List := RegEnum(...)^; // returns PStrList
try
if List.Count > 0 then
....
finally
List.Free; <---- AV HERE
end;
end;
I changed this to:
begin
with RegEnum(...)^ do
try
if Count > 0 then
....
finally
Free; <---- WORKS ?!
end;
end;
I tried to do this several different ways, and this was the only one that worked, completely removing the List variable.
Unfortunately, I still have PList's in 5 other places that are having the same issue, for which I have not yet found a way to free them correctly (ie, without throwing the same exception as quoted in my previous post).
-
I just noticed that you declared var as:
var
List: TStrList;
But it is totally wrong. It explains why you get the errors.
You should use PStrList varaible.
with RegEnum(...)^ do
is correct.
-
Ok, I'm not following that.
In KOL.pas is declared:
PStrList = ^TStrList
so:
var List: TStrList;
List := NewStrList^;
why exactly is this not correct ?
I use the above all over the place, and it usually works.
EDIT: Ok, I adjusted it everywhere and indeed the problem disappears. Thanks a bunch! As for what I said ^^^, is that because you are using 'poor' objects ?
-
Yes. It is because 'poor' objects in KOL library. Class instances are always pointers, while objects can be static instances TXXX or dynamic instances PXXX (pointers).
In this code you copy contents of dynamic instance of StrList to static instance in variable List:
var List: TStrList;
List := NewStrList^;
Then you are trying to release static instance and get the error.
All KOL objects are designed to be dynamic and you must work with pointers only...
P.S. 'poor' objects are just records with methods. So use record rules for them.
-
Sometimes, on the WM6-pda,
Date2Strfmt('dd-MM-yyyy',date)
returns an empty string.
I traced into KOL.pas and found function SystemDate2Str;
Here an empty string is returned if GetMem fails or if GetDateFormat fails. Could this ever happen?
On subsequent calls, the result remained empty. The rest of the program just kept working. After a restart, the result was ok, so the problem is not easy to reproduce.
Any ideas?
tia!
John
-
This afternoon I freshly reinstalled a new daily snapshot.
After that I copied a complete KOL-projectdir from my dev machine to this new machine. Compiles fine on the dev-machine, both to WinCE and to Win32 targets.
- Open Project, ok.
- Build All, ok
- Run : no events fired.
Paths are all the same. All events have dissapeared from the object-inspector and are not fired at runtime either (e.g. OnClick-event on a button). Doubleclicking the button does not create event. Doubleclicking in object-inspector does not create new event or find existing event in unit.
If I drop a NEW TKolbutton on the form, I can define its onclick-event (partly) the usual way: doublleclick the TKolbutton creates an event in the codeeditor, but it does NOT appear in the OI.
Even if I select the still existing event in the dropdownlist in the object-inspector, the editbox in the OI stays empty...
If I create a new KOL-project, everything works fine. So I suspect there is something in the files that I copied from the other machine. [EDIT] Oooops, disregard this... the event appeared once in th OI, but after adding another TKolbutton, everything was gane again... [/EDIT]
If I copy a projectsource from Laz 0.9.25/fpc 2.2.0 to Laz 0.9.25/fpc 2.2.1, should I make precautions to some files? Or setup some parameters in the IDE?
tia!
John
[EDIT2]
Weird... a second time CleanUp+BuildAll did the job. It now works as expected. Still curious what could have been the problem!
[/EDIT2]
-
If you are using Lazarus 0.9.25 or later you need to rebuld Lazarus with DisableFakeMethods defined before installing MCK package.
To do that:
1. Run Lazarus.
2. Choose Tools > Configure "Build Lazarus"... menu item.
3. Choose Clean Up + Build all on Quick Build Options page.
4. Open Advanced Build Options page and add -dDisableFakeMethods into Options input field.
5. Click Build button to rebuild Lazarus.
-
Sometimes, on the WM6-pda,
Date2Strfmt('dd-MM-yyyy',date)
returns an empty string.
I traced into KOL.pas and found function SystemDate2Str;
Here an empty string is returned if GetMem fails or if GetDateFormat fails. Could this ever happen?
On subsequent calls, the result remained empty. The rest of the program just kept working. After a restart, the result was ok, so the problem is not easy to reproduce.
Any ideas?
It seems that GetDateFormat fails. Are you sure that date value is correct?
You need to debug this problem by yourself and find what exactly fail.
-
Yes. It is because 'poor' objects in KOL library. Class instances are always pointers, while objects can be static instances TXXX or dynamic instances PXXX (pointers).
In this code you copy contents of dynamic instance of StrList to static instance in variable List:
var List: TStrList;
List := NewStrList^;
Then you are trying to release static instance and get the error.
All KOL objects are designed to be dynamic and you must work with pointers only...
P.S. 'poor' objects are just records with methods. So use record rules for them.
Wow, I can't believe I've been developing in Object Pascal for 8 years now and didn't know that. That's very useful information, and it being just a record with methods explains a lot. Also opens up for some C++ header translations I thought before were impossible.
Thanks again for your hard work, your assistance and the information!
-
Hi Yury,
In my CE-appl I dynamically create forms the user has to fill in. I have a TKolPanel on which there are an editbox and 2 buttons.
The editbox accepts numeric input only.
The Buttons have a plus and a minus as caption.
If a user presses - , the value should be increased.
If the user presses [-], the value in the editbox should be decreased. Something like a spinedit.
This TKolpanel is created at runtime, maybe 1 instance, maybe 10 instances on a form, used and freed.
When creating the buttons and the editbox, I want to attach the buttons Onclick to a generic eventhandler. In Delphi/VCL I would search Sender.Parent (which is the panel) for an editbox and adjust its textvalue. How to write something like that using KOL?
Is there a way to do something like:
for n:=1 to (sender as tkolbutton).parent.Childcount-1 do
if (sender as tkolbutton).parent.Children[n] is TKolEditbox
then ...do something...
??
tia!
John
-
[/Quote]
It seems that GetDateFormat fails. Are you sure that date value is correct?
You need to debug this problem by yourself and find what exactly fail.[/quote]
You won't believe it... it only happens on sundays!!
date2Strfmt('dd-MM-yyyy',date) returns an empty string and GetLastError (in KOL.PAS, function SystemDate2Str) says 87, which is ERROR_INVALID_PARAMETER, but only when date returns a date that is a sunday.... ???
Beats me..... any suggestions appreciated!
kind regards
John
-
Function DayOfWeek should return 0..6 as stated in the comment below the function declaration. The systemtime-structure also needs 0..6.
But the formula in the function returns 1..7
If I remove the +1 at the end of the formula, all seems to work ok, but I'm not sure if this could possibly break other code?
tia!
John
-
Indeed, DayOfWeek was wrong. It is fixed now. Thanks.
Since all KOL standard controls implemented in single TControl object, you need to use Tag property to identify controls. Set Tag of edit boxes to some value and the code will be:
for n:=1 to sender.parent.Childcount-1 do
if sender.parent.Children[n].Tag = SomeValue
then ...do something...
P.S. You can use real updown control to create spinedit:
http://www.kolnmck.ru/files/kolce/comp/kolce_updown.7z
-
Hi Yury,
Thanks.
Other things:
1. Is it possible to implement and publish OnEnter and OnLeave for TKolDateTimePicker? I'd like to change color when receiving or losing focus.
2. Does exist any documentation (in English) on how to use TKolFrame?
thanks again,
John
-
I published OnEnter and OnLeave for TKolDateTimePicker, but color can not be changed for TKolDateTimePicker for some unknown reason :(
TKOLFrame. It is intended to use in place of TKOLForm, and allows to create and adjust at design time a panel with child controls and objects on a standalone designer form. At run time, instances of such panel together with its children can be put onto another parent control or form dynamically.
-
Hi,
I have been testing KOL components for a few days, looking forward for integrating it to my Windows CE development kit. Amazing job, thanks for it.
However, I have a little problem: on a Windows CE 5.0 device, I´m getting a grayed area below the form, as you may see in the following image
(http://i26.tinypic.com/2vlw30i.jpg)
If I turn off the "Always on top" property in the taskbar the gray area is hidden (the taskbar area almost fits).
(http://i26.tinypic.com/ngyb8z.jpg)
The properties defaulPosition and defaultSize are set to True, according to documentation.
I'm guessing that this problem has to do with the fact that in other versions of Windows CE (Windows Mobile 5 on mi iPaq) another bar exists, where you can choose menu options and showing/hiding keyboard.
Is there a way to get rid of this area?
Thanks in advance
Ivan
-
Hi Yury,
In the Object Inspector I can attach a popupmenu.
But howto attach a popupmenu to a dynamically created object (at runtime)?
[Edit]
Ok, I found SetAutoPopupMenu and it works. However, if I have connected this popupmenu to several PObjects, how to dermine from which Object the popupmenu was fired?
"Sender" and "Item" don't tell nothing about the originating object that fired the popup, am I right?
[/Edit]
cheers,
John
-
ivanf, this area is menu area and you notice it because you areusing non-standaed app-bar.
To hide menu area insert the following code in OnCreate event of a form:
Form.CreateWindow;
DestroyWindow(SHFindMenuBar(Form.Handle));
Form.BoundsRect:=GetWorkArea;
Form.HasBorder:=False;
-
Define for your project USE_MENU_CURCTL and make sure that KOL.pas is recompiling.
Then use CurCtl property of popup menu object.
P.S. Study KOL sources better. All interfaces are well commented. :)
-
Define for your project USE_MENU_CURCTL and make sure that KOL.pas is recompiling.
Then use CurCtl property of popup menu object.
Right, that works!
P.S. Study KOL sources better. All interfaces are well commented. :)
Right again! However, its not like "find it in the source" but rather "first read the source" to find out how KOL works... It 's an approach I have to get used to, since it's not the way I used to find help in delphi or lazarus.
But I learn everyday... ;-)
Kind regards,
John
-
ivanf, this area is menu area and you notice it because you areusing non-standaed app-bar.
To hide menu area insert the following code in OnCreate event of a form:
Form.CreateWindow;
DestroyWindow(SHFindMenuBar(Form.Handle));
Form.BoundsRect:=GetWorkArea;
Form.HasBorder:=False;
Thank you very much, it worked like a charm...
Best regards,
Ivan
-
Yuri,
I seem to be unable to get my controls (panels and labels) to work in transparent mode. I've set Transparent to true, EraseBackground to false and DoubleBuffered to true, to no avail.
Is this not supported on WinCE or am I doing something wrong?
Thanks!
-
I did not test transparency on wince. Therefore it is not supported yet...
-
I did not test transparency on wince. Therefore it is not supported yet...
Ah ok. Too bad. Any plans to test it? (or do I need to make a bounty, or...?)
By the way, another comment:
TOnBitBtnDraw = function( Sender: PControl; BtnState: Integer ): Boolean of object;
{* Event type for TControl.OnBitBtnDraw event (which is called just before
drawing the BitBtn). If handler returns True, there are no drawing occure.
BtnState, passed to a handler, determines current button state and can
be following: 0 - not pressed, 1 - pressed, 2 - disabled, 3 - focused.
Value 4 is reserved for highlight state (then mouse is over it), but
highlighting is provided only if property Flat is set to True (or one
of events OnMouseEnter / OnMouseLeave is assigned to something). }
Probably related to BITBTN_DISABLEDGLYPH2 define (I did not define this manually, just out-of-the-box KOL), but 1 = disabled and 2 = pressed currently with KOL-CE. May be worthy of an added comment in the source.
(note I am using the 2.80 download from SF from some time ago, not from SVN)
Thanks again for your great work!
-
I fixed description of TOnBitBtnDraw handler.
Also I looked at double buffering and transparency code. Unfortunately this code can not be reused for wince due to OS behavior differences :( It is not possible to create general purpose transparency and double buffering support for standard controls in wince like in win32.
You can achieve transparency for your custom needs manually.
Read details here:
http://www.codeproject.com/KB/mobile/transparent_controls.aspx
-
Yuri,
KOL application do not work right on 320x320 devices. Seems to be an infinite loop to do with SetWindowPos and the handling of the resulting messages, but I was unable to figure it out.
I have made a small test application, you can download at http://www.jongma.org/tmp/320x320-kol.rar. It has the container panel and two subpanels that are aligned bottom and top. I'm not 100% sure if these are required, but changing the alignment in the real application we are building with KOL seemed to move the error from one point in the code to another.
First people reported in about this problem because of the new Treo800w, which has a 320x320 display. I've tried on the Windows Mobile 6 "Square QVGA" emulator and indeed it gives problems. 240x240, 240x320, 480x640, all work fine, just not 320x320.
If you change the application to be resolution aware it does work, but of course then we'd have to modify our complete interface. I hope there is anything you can do to fix this! (We pretty much depend on the 240x320 compatibility mode)
Thanks
-
Yuri,
After some more investigation, it seems like 240x320 compatibility mode mucks with sizes a bit here and there. As a result (I think) WM_SIZE gets a slightly different value as response to SetWindowPos calls than was originally used in the SetWindowPos call itself. This creates in infinite loop of calls of SetBoundsRect, which loops back to itself, because:
if RectsEqual( Value, Rect ) then Exit;
in SetBoundsRect is never satisfied.
I've adjusted the RectsEqual function as following:
//[FUNCTION RectsEqual]
{$IFDEF ASM_VERSION}
{$ELSE ASM_VERSION} //Pascal
function RectsEqual( const R1, R2: TRect ): Boolean;
begin
// Result := CompareMem( @R1, @R2, Sizeof( TRect ) );
Result :=
(Abs(R1.Top - R2.Top) <= 1) AND
(Abs(R1.Left - R2.Left) <= 1) AND
(Abs(R1.Bottom - R2.Bottom) <= 1) AND
(Abs(R1.Right - R2.Right) <= 1);
end;
{$ENDIF ASM_VERSION}
//[END RectsEqual]
This fixes the issue on the emulator, though it is ofcourse not an elegant solution (I will send it to someone with a Treo800w to see if it fixes the issue there too). Maybe a DEFINE should be used to turn this functionality on and off ?
-
It should be fixed now. I hope I did not break alignment in some rare cases :)
-
It should be fixed now. I hope I did not break alignment in some rare cases :)
Nice. Could you tell me what you fixed exactly? I hate upgrading files that 'just work' right now ;)
-
You can check svn logs and diffs at any time :)
* Optimized control alignment code. Alignment is faster now. Also it fixes problems when program is run in compatibility mode on devices with square QVGA screen (320x320).
Due to optimized logic alignment is not looped as before.
-
More trouble here, yury.
If you create a main menu with many items and submenus and again items, then you change all their captions, a fair number of times the entire menu will get screwed up. Submenu's will be under a different submenu, or in the main menu list itself, etc.
Been scratching my head at this one for hours. I can make you a test app, though it's pretty easy to reproduce.
-
Yes. Please e-mail me a test app.
-
Heh sorry, I solved my problem another way (fairly big workaround, though). I'll still be making that test app though :)
-
When I drop a Tsqlite3dataset on the form in a Kolwince its add 16.000Kb to then footprint...
And not the "300-500KB" a read about on this forum...
Apparently the Tsqlite3dataset component the work fine on the emulator.
When I reinstall the component for WinCE the compiler give me the following error:
"propedits.pp(22,54) Fatal: Can't find unit PropEdits used by registersqlite3"
If I add the followin path to the other units path, it seems to compile..
"-$(LazarusDir)\lcl\interfaces\$(TargetOS)\;-$(LazarusDir)\ideintf\"
Mis I something ? Glad white anny help :-)
Groetjes,
Jos.
-
Do not drop database components to a form.
I recommend to create Tsqlite3dataset using code and set all needed properties via code.
-
Yuri another issue for your information including fix:
I was seeing all kind of weird stuff while using TKOLThread, so decided to try out my own thread routines, etc, issues still there.
After some conversation with some fpc compiler guys, turned out you must use FreePascal BeginThread (and EndThread) instead of WinAPI CreateThread (and ExitThread). I tried this in my own code and it solved these weird issues. Looking at the version of KOL I have, it also uses CreateThread instead of BeginThread.
Even setting IsMultiThread to true as KOL does, does not really put the memory manager into multithreaded mode, which BeginThread does do. This results in everytime you try to allocate or free memory in a thread there's a possibility of the thread throwing and thus terminating the application (which is why the crashes and exits seemed random and difficult to reproduce).
-
Memory manager is not a problem here, since fpc on wince have custom memory manager which is simple wrapper over wince C runtime memory manager. It is multithreaded by default.
Threadvars can cause problems. I'll fix KOL to use BeginThread and EndThread.
-
I get the next error when I try to add a new form:
Cli_2.inc(6,11) Error: Identifier not found "NewForm2"
Why?
My files:
Unit1
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit1;
interface
uses Windows, Messages, KOL {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TForm1 }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TForm1 = class; PForm1 = TForm1; {$ELSE OBJECTS} PForm1 = ^TForm1; {$ENDIF CLASSES/OBJECTS}
TForm1 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Form: PControl;
KOLApplet1: TKOLApplet;
KOLForm1: TKOLForm;
KOLProject1: TKOLProject;
private
{ private declarations }
public
{ public declarations }
end;
var
Form1 {$IFDEF KOL_MCK} : PForm1 {$ELSE} : TForm1 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm1( var Result: PForm1; AParent: PControl );
{$ENDIF}
implementation
{$IFDEF KOL_MCK}
{$I unit1_1.inc}
{$ENDIF}
initialization
{$IFNDEF KOL_MCK} {$I unit1.lrs} {$ENDIF}
end.
Unit2
{ KOL MCK } // Do not remove this line!
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit2;
interface
uses Windows, Messages, KOL, {place your units here->} LResources
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TForm2 }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS} PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS}
TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Form: PControl;
KOLForm1: TKOLForm;
private
{ private declarations }
public
{ public declarations }
end;
var
Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm2( var Result: PForm2; AParent: PControl );
{$ENDIF}
implementation
{$IFDEF KOL_MCK}
{$I unit2_1.inc}
{$ENDIF}
initialization
{$IFNDEF KOL_MCK} {$I unit2.lrs} {$ENDIF}
end.
Cli
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
program Cli;
uses
KOL,
Unit1, Unit2;
begin // PROGRAM START HERE -- Please do not remove this comment
{$IFNDEF LAZIDE_MCK} {$I Cli_0.inc} {$ELSE}
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.CreateForm(TForm2, Form2);
Application.Run;
{$ENDIF}
end.
Cli_2.inc
{ KOL MCK } // Do not remove this line!
{ Cli_2.inc
Do not modify this file manually - it is generated automatically. }
NewForm1( Form1, Pointer( Applet ) );
NewForm2( Form2, Pointer( Applet ) );
Best regards.
-
You do not have
{$DEFINE KOL_MCK}
in Unit2 for some unknown reason.
-
Now my project run.
Thanks!
-
I want to create a form in run-time. I follow this steps:
Run-time form creation
It is possible to create several instances of the same form at run-time. And at least, it is possible to make form not AutoCreate, and create it programmatically when needed. Use global function NewForm1 (replacing Form1 with your mirror form name), for instance:
TempForm1 := NewForm1( Applet );
To make this possible, NEVER access global variable created in the unit during conversation, unless You know why You are doing so. Refer to Form variable instead.
This is my code:
unit1.pas
...
implementation
uses Unit2;
procedure TForm1.N1Menu(Sender: PMenu; Item: Integer);
var
Modal: TForm2;
begin
Modal := NewForm2( Applet );
try
Modal.Form.ShowModal;
finally
Modal.Form.Free;
end;
end;
but I get then next error message: Unit1.pas(59,28) Error: Wrong number of parameters specified for call to "NewForm2"
Why?
Regards.
-
The correct code is:
NewForm1( TempForm1, Applet );
I corrected wiki page.
-
Which is the type of TempForm1?
Which is the correct way?
NewForm1( TempForm1, Applet );
or
<Something> := NewForm1( TempForm1, Applet );
Thanks
-
The correct code in your case is:
procedure TForm1.N1Menu(Sender: PMenu; Item: Integer);
var
Modal: PForm2;
begin
NewForm2( Modal, Applet );
try
Modal.Form.ShowModal;
finally
Modal.Form.Free;
end;
end;
-
My application is bad when I add a secondary form.
Why?
This is my code:
Cli.lpr
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
program Cli;
uses
KOL,
Unit1, Unit2;
begin // PROGRAM START HERE -- Please do not remove this comment
{$IFNDEF LAZIDE_MCK} {$I Cli_0.inc} {$ELSE}
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
{$ENDIF}
end.
Unit1.pas
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit1;
interface
uses Windows, Messages, KOL {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TForm1 }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TForm1 = class; PForm1 = TForm1; {$ELSE OBJECTS} PForm1 = ^TForm1; {$ENDIF CLASSES/OBJECTS}
TForm1 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Button1: TKOLButton;
Button2: TKOLButton;
Form: PControl;
KOLApplet1: TKOLApplet;
KOLForm1: TKOLForm;
KOLProject1: TKOLProject;
MainMenu1: TKOLMainMenu;
procedure N1Menu(Sender: PMenu; Item: Integer);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1 {$IFDEF KOL_MCK} : PForm1 {$ELSE} : TForm1 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm1( var Result: PForm1; AParent: PControl );
{$ENDIF}
implementation
uses Unit2;
{$IFDEF KOL_MCK}
{$I unit1_1.inc}
{$ENDIF}
{ TForm1 }
procedure TForm1.N1Menu(Sender: PMenu; Item: Integer);
var
Modal: PForm2;
begin
NewForm2( Modal, Applet );
try
Modal.Form.ShowModal;
finally
Modal.Form.Free;
end;
end;
initialization
{$IFNDEF KOL_MCK} {$I unit1.lrs} {$ENDIF}
end.
Unit2.pas
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit Unit2;
interface
uses Windows, Messages, KOL {place your units here->}
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TForm2 }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TForm2 = class; PForm2 = TForm2; {$ELSE OBJECTS} PForm2 = ^TForm2; {$ENDIF CLASSES/OBJECTS}
TForm2 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Button1: TKOLButton;
Form: PControl;
KOLForm1: TKOLForm;
procedure Button1Click(Sender: PObj);
private
{ private declarations }
public
{ public declarations }
end;
var
Form2 {$IFDEF KOL_MCK} : PForm2 {$ELSE} : TForm2 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm2( var Result: PForm2; AParent: PControl );
{$ENDIF}
implementation
{$IFDEF KOL_MCK}
{$I unit2_1.inc}
{$ENDIF}
{ TForm2 }
procedure TForm2.Button1Click(Sender: PObj);
begin
Form.Close;
end;
initialization
{$IFNDEF KOL_MCK} {$I unit2.lrs} {$ENDIF}
end.
-
Did you remove form2 from autocreation list?
Did you set defaultSize and defaultPosition properties to True for form2?
-
Did you remove form2 from autocreation list?
Yes
Did you set defaultSize and defaultPosition properties to True for form2?
No. That was the problem, thanks.
-
Whithout KOL-CE componentes I normally use a TDataModule and I access to its properties, methods and attributes by means of the DataModule1 variable.
Which is the correct way to use a TKOLDataModule?
Best regards.
-
If I put a lNet component onto KOL-CE application I get the run-time error: Project raised exception class 'External: SIGSEGV'.
Why?
-
If you are using Lazarus 0.9.25 or later you need to rebuld Lazarus with DisableFakeMethods defined before installing MCK package.
To do that:
1. Run Lazarus.
2. Choose Tools > Configure "Build Lazarus"... menu item.
3. Choose Clean Up + Build all on Quick Build Options page.
4. Open Advanced Build Options page and add -dDisableFakeMethods into Options input field.
5. Click Build button to rebuild Lazarus.
Although I have followed these steps, I can't get events working at design time. However, adding events on form create, they are fired :?:
EDIT
The patch provided here (http://bugs.freepascal.org/view.php?id=12248) solves the problem after a Lazarus rebuild
-
I can´t assign callbacks in the unit DataModule.pas, I get the error: datamodule.pas(48,28) Error: Variable identifier expected
The problem is in the KOLForm3BeforeCreateWindow method of the datamodule unit.
This is my code:
{ KOL MCK } // Do not remove this line!
{$DEFINE KOL_MCK}
{$ifdef FPC} {$mode delphi} {$endif}
unit DataModule;
interface
uses Windows, Messages, KOL {place your units here->}, lNet
{$IFDEF LAZIDE_MCK}, Forms, mirror, Classes, Controls, mckCtrls, mckObjs, Graphics;
{$ELSE} ; {$ENDIF}
type
{ TForm3 }
{$I MCKfakeClasses.inc}
{$IFDEF KOLCLASSES} TForm3 = class; PForm3 = TForm3; {$ELSE OBJECTS} PForm3 = ^TForm3; {$ENDIF CLASSES/OBJECTS}
TForm3 = {$IFDEF KOLCLASSES}class{$ELSE}object{$ENDIF}({$IFDEF LAZIDE_MCK}TForm{$ELSE}TObj{$ENDIF})
Form: PControl;
KOLForm3: TKOLForm;
procedure KOLForm3BeforeCreateWindow(Sender: PObj);
procedure OnDs(aSocket: TLSocket);
procedure OnRe(aSocket: TLSocket);
procedure OnEr(const msg: string; aSocket: TLSocket);
private
{ private declarations }
public
{ public declarations }
Conexion: TLTcp;
end;
var
Form3 {$IFDEF KOL_MCK} : PForm3 {$ELSE} : TForm3 {$ENDIF} ;
{$IFDEF KOL_MCK}
procedure NewForm3( var Result: PForm3; AParent: PControl );
{$ENDIF}
implementation
{$IFDEF KOL_MCK}
{$I datamodule_1.inc}
{$ENDIF}
{ TForm3 }
procedure TForm3.KOLForm3BeforeCreateWindow(Sender: PObj);
begin
Conexion := TLTCP.Create(nil); // create new TCP connection with no parent component
Conexion.OnError := @OnEr; // assign callbacks
Conexion.OnReceive := @OnRe;
Conexion.OnDisconnect := @OnDs;
Conexion.Timeout := 100; // responsive enough, but won't hog cpu
ShowMessage('Componente para la conexión creado');
end;
procedure TForm3.OnDs(aSocket: TLSocket);
begin
ShowMessage('Lost connection');
end;
procedure TForm3.OnRe(aSocket: TLSocket);
var
s: string;
begin
if aSocket.GetMessage(s) > 0 then
ShowMessage(s);
end;
procedure TForm3.OnEr(const msg: string; aSocket: TLSocket);
begin
ShowMessage(msg); // if error occured, write it
end;
initialization
{$IFNDEF KOL_MCK} {$I datamodule.lrs} {$ENDIF}
end.
The solution:
Delphi mode is used for MCK generated source files.
Assign event without @
Conexion.OnError := OnEr;
-
Hello Yury,
do you have any news on VGA support on KOL-CE that you mention on 12th Nov?
regards
jabu
-
Sorry,
It don't work.
This is my error:
Compiling resource C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol\KOL-CE.rc
C:\lazarus\fpc\2.2.2\bin\i386-win32\arm-wince-windres.exe: no resources
C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol\KOL.PAS(57970) Error: Error while linking
C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol\KOL.PAS(57970) Fatal: There were 1 errors compiling module, stopping
I read all Documentation and add this PATH in the Env. System.
c:\lazarus\fpc\2.2.2\source\;c:\lazarus\fpc\;C:\lazarus\fpc\2.2.2\bin\i386-win32\;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\mck;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\mck\lib\i386-win32;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\mck\lib\arm-wince;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol
someone can help me?
-
Sorry,
It don't work.
This is my error:
Compiling resource C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol\KOL-CE.rc
C:\lazarus\fpc\2.2.2\bin\i386-win32\arm-wince-windres.exe: no resources
C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol\KOL.PAS(57970) Error: Error while linking
C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol\KOL.PAS(57970) Fatal: There were 1 errors compiling module, stopping
I read all Documentation and add this PATH in the Env. System.
c:\lazarus\fpc\2.2.2\source\;c:\lazarus\fpc\;C:\lazarus\fpc\2.2.2\bin\i386-win32\;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\mck;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\mck\lib\i386-win32;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\mck\lib\arm-wince;C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\KOL-CE\kol
someone can help me?
You have installed kol-ce in a folder with spaces ("C:\Documents and Settings\lisa\Documenti\_LAZARUS\kol-ce-2.80.2\"). Try to put all kol-ce stuff in a folder without spaces.
-
Now Work.
Thank you
-
I thought I understand Kolce, but when I use 2.80.2
I make a new application but the onshow event of kolform is nog fired.
Other events like onbutton click does work.
Lazarus 9.2.7 fpc 2.2.3
I added also an example in test2.zip
-
My exe with empty form have 180kB. Why? Strip.exe doesn't help.
-
......
I make a new application but the onshow event of kolform is nog fired.
Other events like onbutton click does work.
......
I have same problem. So I forced "Form.Show" on "OnFormCreate" event:
procedure TForm1.KOLForm1FormCreate(Sender: PObj);
begin
Form.Visible := false;
Form.CreateWindow;
Form.Show;
end;
and It works fine~ :)
-
I make a new application but the onshow event of kolform is nog fired.
Other events like onbutton click does work.
Please report bugs on KOL-CE project page on sourceforge: http://sourceforge.net/projects/kol-ce