Конференция "KOL" » Scrollbox event error
 
  • Jon © (23.03.11 00:33) [0]
    Adding a resource to a program with a scrollbox breaks the OnSBScroll event.

    Here is a example to demonstrate the problem:


    program Test;

    {$R 'test.res' 'test.rc'} // Remove this line and it works!

    uses KOL;

    procedure ScrollbarChange(Dummy: Pointer; Sender: PControl; Cmd: Word);
    begin
     Sender.Parent.Caption := Int2Str(Sender.SBPosition);
    end;

    begin
     Applet := NewForm(nil,'');
     with NewEditbox(Applet,[eoNumber])^ do
     begin
       Color := clWindow;
       Text := '5';
     end;
     with NewScrollBar(Applet.Children[0],sbVertical)^ do
     begin
       Align := caRight;
       OnSBScroll := TOnSBScroll(MakeMethod(nil,@ScrollbarChange));
       SBMax := 1000;
       SBPosition := 5;
     end;
     InitCommonControls;
     Run(Applet);
    end.



    The resource contains the following:


    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
     <assemblyIdentity
       name="test"
       processorArchitecture="*"
       version="1.0.0.0"
       type="win32"
     />
     <description>test</description>
     <dependency>
       <dependentAssembly>
         <assemblyIdentity
           type="win32"
           name="Microsoft.Windows.Common-Controls"
           version="6.0.0.0"
           processorArchitecture="*"
           publicKeyToken="6595b64144ccf1df"
           language="*"
         />
       </dependentAssembly>
     </dependency>
    </assembly>



    Tested with Win XP, D7, KOL v3.pi and v2.x
  • Thaddy © (23.03.11 13:16) [1]
    Did you do a full rebuild?
    Otherwise the resource trick will not work.
    It works only for complete builds.
    Also, which Delphi version are you using?
    There are big differences, specially in recognizing manifest resources.
    I did about the same test. No problemos...
  • Dufa © (23.03.11 13:19) [2]
    В каком месте ломает?

    может надо было сделать:

    procedure ScrollbarChange(Dummy: Pointer; Sender: PControl; Cmd: Word);
    begin
    Applet.Caption := Int2Str(Sender.SBPosition);
    end;

  • Jon © (23.03.11 14:18) [3]
    Thanks for the replies guys.

    > Did you do a full rebuild?
    > Also, which Delphi version are you using?

    Yes, I've been doing this for a while now ;-)
    The version used was at the bottom of my post - D7.

    > Dufa ©   (23.03.11 13:19) [2]

    I tried too. The problem is that any caption is incorrect.
    The control sends 0 or 1 on mouse down and 0 on mouse up.
    -
    Download my test files from here: http://files.mail.ru/JUOGA5
    It contains compiled builds of both bad and good tests (19kb).
  • Dufa © (23.03.11 15:09) [4]
    Не могу понять в чём ошибка.. Сделал скриншоты
    http://img820.imageshack.us/g/bad0q.jpg/
  • thaddy © (23.03.11 15:23) [5]
    Even with the download I cannot reproduce it.
    It simply works as expected here: win xp sp3,
    tried d5,d7 and both unicode and ansi.
    btw: why initcommonctrls? it is called by the startup code anyway.
  • Jon © (23.03.11 17:03) [6]
    Thanks for testing guys. I found the problem. My system was missing this file:

    c:\WINDOWS\WinSxS\Policies\x86_policy.6.0.Microsoft.Windows.Common-Controls_6595b64144ccf1df_x-ww_5ddad775\6.0.2600.6028.Policy



    When you both confirmed that it worked, I went to find another computer to try it.
    It worked there so I used Process Explorer to dump the dll usage of the executable.
    The difference was that my system was using an older version of the resource:

    [bad] comctl32.dll - User Experience Controls Library - Microsoft Corporation - 6.0.2600.0
    [ok.] comctl32.dll - User Experience Controls Library - Microsoft Corporation - 6.0.2900.6028



    I copied over the above file from the good system - now problem is gone.

    I appreciate your time with the testing.

    BTW: does this show that KOL needs a minimum version of comctl32.dll to work correctly?


    > btw: why initcommonctrls? it is called by the startup code anyway.


    Yes - that was just me troubleshooting. I forgot to remove it.
  • Thaddy © (23.03.11 18:26) [7]
    It even works with fpc 2.5.1 (somewhat - not very much - tweaked kol)

    Interested?

    If you are reading this Vladimir, don't make any fixes yet, I am being thorough this time. Completely overhauling fpc support.
  • Jon © (24.03.11 00:12) [8]

    > Interested?


    Indeed! Do you still have my email address?
  • Thaddy © (24.03.11 11:06) [9]
    Just to be sure, send me an email, I'll give you a link to a complete setup that works.

    To publish it as a beta is too early, because I am cleaning up FPC derictives and replace them with VER150 or Delphi7AndUp. Then I still have to check what's missing and adapt a few sources, but almost nothing in kol.pas itself.
    Basically most of the work is done (replacing"W;" with "A;" in kol_unicode.inc to create a new and more complete version of kol_ansi.inc ;-) ) that kind of stuff.
    And yes, the kol sources work for both unicode and ansi.
    Since the fpc compiler is more strict, there are only 9 very small patches to be made in kol.pas itself without breaking any delphi version. that is 8 casts for TMsg and one removal of a forward in the interface section. All really small kol bugs that delphi - basically unmerited - ignores.
    Only thing is, you will need the windows sources from one of the original delphi versions. I have finished D5 translations (so basically fpc works) but I am translating more current and complete versions of the windows units.
    The FPC supplied version is utterly useless with kol.
    (Were to lazy to translate pointers into var when applicable)
  • thaddy © (24.03.11 11:14) [10]
    BTW this also works for 2.4.2/3 but you will get more errors.
    The current trunk is even more compatible.
    I just discovered another little change:
    FPC chokes on POS in unicode mode. Easy fix in the implementation section like this(doesn't cost a byte):

    Just after implementation of PosW:

    Type
    TPos =function(const s1,s2:KolString):integer;
    Const
    Pos:Tpos = PosW;

    This doesn't even break delphi, since posw is both ansi and unicode....

    It is most of the time these small things.
  • thaddy © (24.03.11 11:20) [11]
    BTW 2:

    What does the community think?
    Should I support older versions of FPC or just 2.4.2 (current stable release) and up?

    My vote would be only 2.4.2 and up, since fpc is free anyway.
    And for the KOL community there's not much loss in exe size.

    It will clean up KOL.pas a lot. (which is a good thing imnsho)
  • Dy1 (25.09.11 16:20) [12]
    помогите пожалуйста прокрутить ScrollBox колёсиком.

    function TForm1.KOLApplet1Message(var Msg: TMsg; var Rslt: Integer): Boolean;
    begin
     Result := False;
     if(SB.GetWindowHandle = Msg.hwnd)AND(Msg.message = WM_MOUSEWHEEL)then
     begin
       if Msg.wParam > 32767 then
         SB.Perform( ???
 
Конференция "KOL" » Scrollbox event error
Есть новые Нет новых   [120350   +22][b:0][p:0.002]