Difference between revisions of "KOL-CE"

From Free Pascal wiki
m (Introduction)
(Installation)
Line 26: Line 26:
 
# Download KOL-CE sources and put them on some folder on your filesystem.
 
# Download KOL-CE sources and put them on some folder on your filesystem.
 
# Run Lazarus and choose '''Components > Load package file''' menu item. Then navigate to '''MCK''' folder and choose <tt>'''MirrorKOLPackage.lpk'''</tt> file.
 
# Run Lazarus and choose '''Components > Load package file''' menu item. Then navigate to '''MCK''' folder and choose <tt>'''MirrorKOLPackage.lpk'''</tt> file.
# Package window will apper. Press '''Install''' button.
+
# Package window will appear. Press '''Install''' button.
 
# Lazarus will compile MCK package and IDE will be restarted.
 
# Lazarus will compile MCK package and IDE will be restarted.
 
# After restart KOL tab will appear on components palette.
 
# After restart KOL tab will appear on components palette.

Revision as of 12:41, 20 October 2007

Introduction

KOL-CE is Free Pascal/Lazarus port of KOL&MCK devloped by Vladimir Kladov (http://kolmck.net). KOL-CE is developed by Yury Sidorov and distributed under wxWindows Library Licence.

KOL-CE allows to create very compact Win32/WinCE GUI applications (starting from ~40KB executable for project with empty form).

MCK is Lazarus package wich allows VISUAL development of KOL-CE projects in Lazarus IDE.

Initially KOL-CE was planned as KOL port for WinCE only. But later it was decided to keep Win32 functionality and made it work with FPC smoothly. Original KOL is targeted for Delphi and does not work with FPC very well. Original MCK can not be used with Lazarus at all.

Requirements

  • Free Pascal compiler 2.2.0 or later for Win32.
  • arm-wince cross compiler 2.2.0 or later for Win32 (for WinCE development).
  • Lazarus 0.9.23 or later for Win32.

Supported targets

  • All 32-bit Windows: from Windows 95 to Vista.
  • Windows CE based PocketPC and Smatphones.

Download

Download the latest release of KOL-CE here.

Also you can check out the freshest KOL-CE sources from svn using this link: https://kol-ce.svn.sourceforge.net/svnroot/kol-ce/trunk

Installation

MCK package
  1. Download KOL-CE sources and put them on some folder on your filesystem.
  2. Run Lazarus and choose Components > Load package file menu item. Then navigate to MCK folder and choose MirrorKOLPackage.lpk file.
  3. Package window will appear. Press Install button.
  4. Lazarus will compile MCK package and IDE will be restarted.
  5. After restart KOL tab will appear on components palette.

KOL components palette

Upgrade is very simple as well. Just overwrite KOL-CE sources with new version, open MCK package and press Install button to recompile the package.

Using MCK

Creating MCK project

MCK form
  1. Start Lazarus and create new Application using File > New... menu item.
  2. DO NOT place any components on the form at this stage. Choose File > Save All and select the destination folder for your project. Note that ALL FILES of your project ALWAYS HAVE TO BE PLACED IN THE SAME FOLDER! You may change the name of the form's unit, but do not change the name of the project file. Leave project name default as project1.lpi
  3. Place the TKOLProject component onto the form.
  4. Set the name of the resulting MCK project by changing the ProjectDest property (path MUST NOT be included). If you type MyKOLProg, for instance, then the resulting MCK project will be named MyKOLProg.lpi. The EXE file's name will be (as you might have guessed already) MyKOLProg.exe.
    ProjectDest property
  5. Drop the TKOLForm component onto the form.
  6. Save current project.
  7. Open the resulting project which you specified in ProjectDest property (it should be found in the same directory). Delete all project1.* files - these files are no longer necessary.
  8. Play with your new KOL/MCK Project (adjust Parameters, drop TKOL... components, compile, run, debug, etc.) Enjoy!

Adding a form

  1. Select File > New form menu item.
  2. Save the form IN THE SAME directory where project is located.
  3. Drop TKOLForm object onto it.
  4. Be sure that you have TKOLApplet component dropped on the main form.
  5. If AutoBuild is turned off: select TKOLProject component in main form and double click its property Build. (Otherwise, all should be done already, isn't it?).

Writing code

Do not use names from RTL/FCL/LCL, especially from SysUtils, Classes, Forms, etc. All what you need, you should find in KOL, Windows, Messages units. And may be, write by yourself (or copy from another sources). When You write code in mirror project - usually place it in event handlers. You also can add any code where you wish but avoid changing first section of your mirror LCL form class declaration. And do not change auto-generated inc-files. Always remember, that code, that you write in mirror project, must be accepted both by LCL and KOL. By LCL - at the stage of compiling mirror project (and this is necessary, because otherwise converting mirror project to reflected KOL project will not be possible). And by KOL - at the stage of compiling written code in KOL namespace.

IMPORTANT

To resolve conflict between words LCL.Self and KOL.@Self, which are interpreted differently in KOL and LCL, special field is introduced - Form. In LCL, Form property of TKOLForm component "returns" Self, i.e. form object itself. And in KOL, Form: PControl is a field of object, containing resulting form object. Since this, it is correctly to change form's properties in following way:

Form.Caption := 'Hello!'; 

(Though old-style operator Caption := 'Hello!'; is compiled normally while converting mirror project to KOL, it will be wrong in KOL environment). But discussed above word Form is only to access form's properties - not its child controls. You access child controls and form event handlers by usual way. e.g.:

Button1.Caption := 'OK';
Button1Click(Form);

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.

WinCE

arm-wince target

You need to install arm-wince cross compiler for Win32 to compile WinCE executables. Get it here.

To compiler for arm-wince target open compiler options of your project using Project > Compiler options... menu item. Open Code tab and change target platform to arm-wince.

Hints and notes

  • To make form fullscreen as most Pocket PC applications have, don't change the form position and size. If form size and/or position was changed the form will look like dialog with caption and close button. In MCK set defaultSize and defaultPosition of TKOLForm to True to make form fullscreen.

Known issues

  • The following components are not supported: RichEdit, TrayIcon.
  • Only gsVertical, gsHorizontal gradient panel styles are supported.

Documentation

  • Visit official KOL&MCK website for documentation and information: http://kolmck.net
  • Read MCK documentation in KOLmirrorReadme.txt file inside MCK folder.

See also

Contacts

Report bugs, submit patches and ask questions at project's page at SourceForge: http://sourceforge.net/projects/kol-ce/