Difference between revisions of "KOL-CE/ru"

From Lazarus wiki
Jump to navigationJump to search
Line 15: Line 15:
  
 
=== Поддерживаемые платформы: ===
 
=== Поддерживаемые платформы: ===
* Все 32-битные Windows: от Windows 95 до Vista.
+
* Все 32-битные Windows: от Windows 95 до Windows 7.
 
* [[WinCE port|Windows CE]] для PocketPC и смартфонов.
 
* [[WinCE port|Windows CE]] для PocketPC и смартфонов.
  

Revision as of 09:39, 30 September 2010

Windows logo - 2012.svg

Эта статья относится только к Windows.

См. также: Multiplatform Programming Guide

WinCE Logo.png

Эта статья относится только к Windows CE.

См. также: Multiplatform Programming Guide

English (en) français (fr) 한국어 (ko) русский (ru) 中文(中国大陆)‎ (zh_CN) 中文(台灣)‎ (zh_TW)

Введение

KOL-CE - это KOL&MCK созданная Владимиром Кладовым(http://kolmck.net), портированная под free pascal/Lazarus. KOL-CE создана Юрием Сидоровым и распространяется под wxWindows Library Licence.

KOL-CE позволяет создавать очень компактные Win32/WinCE приложения с GUI (начиная от ~40KB приложения с пустой формой).

MCK это пакет Lazarus, позволяющий проектировать приложения KOL-CE визуально, используя Lazarus IDE.

Изначально KOL-CE планировался как KOL, портированный только для WinCE. Но потом было решено оставить функции Win32 и доделать его работу с FPC. Оригинальный KOL предназначалась для Delphi и работает с free pascal с ошибками. А оригинал MCK вообще нельзя было использовать для Lazarus.

Требования

  • Free Pascal compiler 2.2.0 или позже для Win32.
  • arm-wince cross compiler 2.2.0 или позже для Win32 (for WinCE development).
  • Lazarus 0.9.26 или позже для Win32.

Поддерживаемые платформы:

  • Все 32-битные Windows: от Windows 95 до Windows 7.
  • Windows CE для PocketPC и смартфонов.

Загрузка

Последний релиз KOL-CE можно скачать отсюда: here.

Также вы можете получить свежие исходники KOL-CE из svn по этой ссылке: https://kol-ce.svn.sourceforge.net/svnroot/kol-ce/trunk

Установка


Важно: После KOL-CE 2.80.2 определение DisableFakeMethods больше не требуется.

Если раньше вы использовали KOL-CE 2.80.1 или ранее, вам надо пересобрать Lazarus без определения DisableFakeMethods перед установкой пакета MCK. Иначе обработчики событий не будут работать!

Сделаем это:

  1. Запустить Lazarus.
  2. Выбрать пункт Tools > Configure "Build Lazarus"... (Сервис > Параметры сборки Lazarus...).
  3. Выбрать Clean Up + Build all(Очистить всё + собрать всё) на странице Quick Build Options (простые параметры сборки).
  4. Открыть страницу Advanced Build Options (Расширенные параметры сборки) и remove -dDisableFakeMethods из поля ввода Options .
  5. Кликнуть по кнопке Build для пересборки Lazarus.

MCK package
  1. Загрузите KOL-CE и поместите куда-нибудь рядом с Лазарусом.
  2. Запустите Lazarus и выберите пункты меню Components > Load package file. Укажите папку MCK и выберите файл MirrorKOLPackage.lpk.
  3. Появится окно содержимого пакета. Нажмите кнопку Install.
  4. Лазарус скомпилирует пакет MCK перезапустится.
  5. После этого на палитре компонентов появится вкладка KOL.

KOL components palette

СОВЕТ: Если вы видите не все компоненты KOL на палитре компонентов, увеличьте размер окна по вертикали. Появится вторая строка с недостающими копонентами (см. скриншот).

Обновить пакет MCK очень легко. Просто перезапишите обновленные KOL-CE исходники поверх (вместо) старых, откройте пакет MCK через Lazarus и нажмите Install, пакет перекомпилится, и будет вам счастье!

Особенности использования MCK

Создание нового проекта

MCK form
  1. Запустите Lazarus, выберите File > New... (Файл > Создать ...).
  2. Выберите KOL Application в секции Project и нежмите OK.
  3. Будет создан новый KOL проект.
  4. Сохраните проект под новым именем.
  5. Продукт готов к использованию, срок годности ограничен вашей фантазией =). Можете развлекаться!

Добавление формы

  1. Выберите File > New... (Файл > Создать ...).
  2. Выберите KOL Form(иногда просто Form) в секции File (Модуль) и нажмите OK.
  3. Сохраните модуль с формой под новым именем.

Особенности написания кода

Не используйте элементы из RTL/FCL/LCL, особенно из SysUtils, Classes, Forms и подобных им. Всё необходимое придётся искать в модулях KOL, Windows, Messages. А может быть, вы напишете что-то сами (или скопируете из других исходников). Если вы пишете в зеркальном проекте (mirror project) - Обычно поместите его в обработчики событий. 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:

NewForm1( TempForm1, 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

Setup

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.

NOTE: You can receive the following error while compiling your KOL-CE project for WinCE:

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

In such case you need to edit Windows PATH environment variable and add path to folder where win32 fpc binaries are located.
To find out which path to add, go to Environment options in Lazarus and see compiler path.
Quit Lazarus before editing PATH.
To edit PATH variable right click on My Computer icon go to Advanced tab and click Environment Variables button.

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.
  • Transparency and double buffering are not supported.
  • Only gsVertical, gsHorizontal gradient panel styles are supported.
  • Horizontal text alignment does not work in single line edit control. Use memo if you need text alignment.
  • Vertical text alignment does not work for panel and label.

Documentation

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

KOL-CE in real-world applications

See also

Contacts

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