Конференция "KOL" » KOL v 3.00 [Delphi, Windows]
 
  • Jon © (05.11.10 19:19) [260]
    http://kolmck.net/Components/KolCCtrls.zip does not compile with UNICODE_CTRLS:


    dcc32.exe -b KOLCCtrls.pas -dUNICODE_CTRLS;

    Borland Delphi Version 15.0
    Copyright (c) 1983,2002 Borland Software Corporation
    KOLDEF.INC(281)
    KOLDEF.INC(281)
    delphidef.inc(48)
    delphicommctrl.inc(1569)
    KOL_unicode.inc(1278)
    KOL_unicode.inc(1278)
    KOL_ASM.inc(14822)
    KOL.pas(65529)
    KOLCCtrls.pas(846) Warning: Variable 'fImgIndex' might not have been initialized
    KOLCCtrls.pas(959) Error: Incompatible types: 'Char' and 'WideChar'
    KOLCCtrls.pas(960) Error: Incompatible types: 'Char' and 'WideChar'
    KOLCCtrls.pas(1023) Error: Incompatible types: 'Char' and 'WideChar'
    KOLCCtrls.pas(1035) Error: Incompatible types: 'Char' and 'WideChar'
    KOLCCtrls.pas(1109) Warning: Suspicious typecast of WideString to PAnsiChar
    KOLCCtrls.pas(1436) Warning: Suspicious typecast of WideString to PAnsiChar
    KOLCCtrls.pas(1444) Warning: Suspicious typecast of WideString to PAnsiChar
    KOLCCtrls.pas(1671) Error: Incompatible types: 'Char' and 'WideChar'
    KOLCCtrls.pas(1769)
    KOLCCtrls.pas(168) Hint: Private symbol 'DoChange' declared but never used

  • Vladimir Kladov © (05.11.10 19:29) [261]
    I just tried, it is compiled OK with Delphi7.

    KOLCCtrls size    - 8 149 bytes.
    KOL_unicode.inc - 81 369 bytes.
    KOL v 3.00.Z4
  • Jon © (05.11.10 19:50) [262]
    Ah, you are quite right. My KOLCCtrls.pas was different version of size 51kb which included SPC CONTROLS (SPCDirectoryEdit, SPCFileList, SPCDirectoryList, SPCDriveCombo, SPCFilterCombo, SPCStatus). Get it here: http://zalil.ru/29922711
  • Vladimir Kladov © (05.11.10 20:23) [263]
    I think this would not be a big problem for you to fix it. These are not my components, moreover these are components of different authors (my is only KOLTrackbar, I created it just to demonstrate how to create components for KOL, and it seems has no problems with UNICODE_CTRLS).
  • Jon © (05.11.10 21:13) [264]
    My apologies, I had assumed that it was your component.
  • Jon © (07.11.10 04:46) [265]
    This code creates a runtime error when compiled with UNICODE_CTRLS defined:


    program Test;

    uses
     Windows, Messages, KOL;

    begin
     Applet := NewForm(Applet, '');
     with Applet^ do
     begin
       Font.ReleaseHandle;
       Font.AssignHandle(GetStockObject(DEFAULT_GUI_FONT));
       Font.FontHeight := -11;
     end;
     with NewLabel(Applet, 'Test')^ do
       Width := Canvas.TextWidth(Text) + 10;
     Run(Applet);
    end.



    The issue seems to be with the Font properties, but I cannot see why UNICODE_CTRLS would affect it.
  • Vladimir Kladov © (07.11.10 12:54) [266]
    program Test;

    uses
    Windows, Messages, KOL;

    begin
    Applet := NewForm(Applet, '');
    with Applet^ do
    begin
      Font.ReleaseHandle;
      Font.AssignHandle(GetStockObject(DEFAULT_GUI_FONT));
      Font.FontHeight := -11;
    end;
    with NewLabel(Applet, 'Test')^ do
    begin
      CreateWindow;
      Width := Canvas.TextWidth(Text) + 10;
    end;
    Run(Applet);
    end.



    Add CreateWindow; before any works with Canvas.
  • Jon © (07.11.10 20:22) [267]

    > Add CreateWindow; before any works with Canvas.

    Indeed, but I am curious why is it only necessary when using UNICODE_CTRLS and not without.
  • pingyu (08.11.10 10:17) [268]
    is there a way to compile KOL on FreePascal?(not on Lazarus)
  • Dufa © (08.11.10 12:53) [269]
    Vladimir Kladov, В NormalizeUnixText по-моему есть баг..
    Сейчас там (строка 22641, 22642):

                   S[J] := #13;
                   S[J-1] := #10;



    так вот если взять unix текст (строки разделены LF) то при обращении к .Items[] каждый элемент содержит LF на конце... а если поменять код на:


                   S[J] := #10;
                   S[J-1] := #13;



    то все в норме
  • Jon © (08.11.10 13:42) [270]

    > pingyu   (08.11.10 10:17) [268]
    >
    > is there a way to compile KOL on FreePascal?(not on Lazarus)

    Use conditional define symbol FPC


    Following conditional symbols can be used in a project (Project | Options | Directories/Conditional Defines) to change code generated a bit. There are following:

    FPC - Free Pascal version. KOL can be used with such compiler to create Win32 applications. To create Win-CE applications (with FPC compiler), use the separate version of KOL specially designed for it.

  • Vladimir Kladov © (08.11.10 17:05) [271]
    Indeed, but I am curious why is it only necessary when using UNICODE_CTRLS and not without.
    It is always necessary but this leads to memory corruption which consequences not always lead to immediate consequences. In this case hopefully in UNICODE_CTRLS the bug appeared very fast, without UNICODE it would appear much later and give very strange results.

    Actually problem is following. We call TCanvas.TextExtent, which require Canvas.Handle, which require TControl.Handle. While CreateWindow is working, its Canvas is destroyed, still execution returns to the method of non-existing more object. Any further changes in its structure made from the method corrupt memory which either is not allocated for objects or may be already is reallocated for objects. Either corruption can be found for free memory blocks or for its headers so further working of memory manager becomes impossible.

    Correct decision in this case is to add a call to CreateWindow into TControl.GetCanvas. But this is a rare situation (using Canvas before window creation), so I think I'll add it within {$IFDEF SAFE_CODE} ... {$ENDIF} brackets.

    And this is not 3.00 issue, it was existing very long time from the KOL's burning age.
  • Vladimir Kladov © (08.11.10 17:10) [272]
    is there a way to compile KOL on FreePascal?


    1) You should read a message from Thaddy de Koning in koldef.inc near
    {$IFDEF FPC} section.
    2) You should use Windows.pas and other \win units from earlier
    Borland Delphi, e.g. from Delphi 3. May be it is working for units
    from Delphi 5 too but I did not check it.
    3) Some small changes are necessary in KOL.pas.
    A set of assembler procedures starting from EAX2PChar were uncommented
    in last versions for some reasons by commenting directives {$IFDEF
    ASM_VERSION}
    with a mark //22 - just remove the mark //22 and allow
    the directive work. This section was changed in later versions, so may be other changes are necessary or no changes needed at all.
    4) To check that it works I used Free Pascal 2.2.1 but I think that
    all is the same for 2.4.0. Use following options (I just write [X] and
    (*) items, other items are not marked, but you may experiment):

    Syntax
    [X] Allow label and goto {default}
    [X] Use ANSI strings
    (*)
    Delphi compatible

    Generated code
    [X] Range checking
    [X] I/O checking
    [X] Integer overflow checking
    [X] Create smartlinkable units
    [X] Generate smaller code

    Processor
    (*) Pentium2/PentiumM/AMD
    (*)
    i386/i486

    Verbose - for your decision
    Browser - for your decision

    Assembler
    (*) Intel style assembler
    (*)
    Use default output

    Conditional defines
    NOT_USE_RICHEDIT;WIN

    Directories - change to your paths
    Units
    D:\FPC\2.2.4\units\i386-Win32\*
    D:\FPC\2.2.4\units\i386-Win32\rtl
    D:\FPC\2.2.4\units\i386-Win32
    c:\Borland\Delphi 3\Source\Rtl\Win
    D:\KOL

    Include files
    D:\KOL

  • Vladimir Kladov © (08.11.10 17:15) [273]
    Dufa ©   (08.11.10 12:53)

    Vladimir Kladov, В NormalizeUnixText по-моему есть баг..
    Сейчас там (строка 22641, 22642):

                  S[J] := #13;
                  S[J-1] := #10;


    Так давно это не проверял... Но ведь когда-то же проверял, и даже работало. Сейчас поищу, как сделать unix-текст для проверки. Это у которого #10 единственный используется, без #13. Вообще-то должно быть #13#10 в обычном тексте. Может и баг.
  • Vladimir Kladov © (08.11.10 17:51) [274]
    Точно баг. Забавно, что для тех целей для которых делал - работает все верно. После открытия и "исправление" этой функцией, текст сохраняется, и он дальше нормально открывается блокнотом. Но порядок управляющих символов не тот.

    Выложил 2 последних исправления как 3.00.Z6.
  • Dufa © (08.11.10 20:12) [275]

    > Выложил 2 последних исправления как 3.00.Z6.

    Отлично!


    > Забавно, что для тех целей для которых делал - работает
    > все верно


    Забавно и то, что когда-то и у меня работало %)
  • Jon © (09.11.10 16:05) [276]

    > Correct decision in this case is to add a call to CreateWindow
    > into TControl.GetCanvas. But this is a rare situation (using
    > Canvas before window creation), so I think I'll add it within
    > {$IFDEF SAFE_CODE} ... {$ENDIF} brackets.


    I tried the program from [265] with conditional defines UNICODE_CTRLS;SAFE_CODE; using KOL v3.00.Z6

    It seems that TControl.GetCanvas is never called, so therefore the SAFE_CODE/CreateWindow fixes are not used.
  • Vladimir Kladov © (09.11.10 16:39) [277]
    Jon, you are joking? :)

    Width := Canvas.TextWidth(Text) + 10;

    - is it in your code?


    function TControl.GetCanvas: PCanvas;
    asm
           PUSH     EBX
           PUSH     ESI
           {$IFDEF  SAFE_CODE}
           MOV      EBX, EAX
           CALL     CreateWindow --- press F5 here to make a breakpoint
           {$ELSE}
           XCHG     EBX, EAX
           {$ENDIF}



    In PAS_VERSION, KOL line 44774.
  • Jon © (09.11.10 16:52) [278]
    PAS_VERSION is correct. But ASM_VERSION is not.
    File KOL_ASM.inc is the same in both Z4 and Z6.

    function TControl.GetCanvas: PCanvas; // line 8910
    asm
           PUSH     EBX
           PUSH     ESI
           XCHG     EBX, EAX

           MOV      ESI, [EBX].fCanvas
           TEST     ESI, ESI
           JNZ      @@exit
    ...

  • Vladimir Kladov © (09.11.10 17:36) [279]
    Indeed, I forgot to update kol_asm.inc in the archine. Fixed now.
 
Конференция "KOL" » KOL v 3.00 [Delphi, Windows]
Есть новые Нет новых   [120345   +9][b:0.001][p:0.004]