#28 Slider no longer supports setting position

closed-fixed
nobody
None
8
2005-07-11
2004-12-29
Basgetti
No

$Window->Slider->Pos(3) used to set the slider postion.
This does not work with the 1.0 release.

Discussion

  • Basgetti

    Basgetti - 2004-12-29
    • priority: 5 --> 8
     
  • Basgetti

    Basgetti - 2004-12-30

    This small scripts demonstrates the problem.

     
  • Robert May

    Robert May - 2005-01-19

    Logged In: YES
    user_id=674651

    It looks to me like if you don't set the redraw parameter it is
    supposed to default to 1, but actually defaults to 0. Calling
    $window->Slider->Pos(3,1) works correctly.

    Fix is needed at line 685 of trackbar.xs v1.4 (from 1.0 PPM)
    where:
    RETVAL = SendMessage(handle, TBM_SETPOS, 0, (LPARAM)
    SvIV(ST(1)));

    should be:
    RETVAL = SendMessage(handle, TBM_SETPOS, 1, (LPARAM)
    SvIV(ST(1)));

    It looks like this is a bug with all methods in trackbar.xs where
    the redraw flag should default to 1, but actually defaults to
    0. I haven't looked to see if this is a general fault
    everywhere, or only in this file.

    See http://msdn.microsoft.com/library/default.asp?
    url=/library/en-
    us/shellcc/platform/commctls/trackbar/messages/tbm_setpos.
    asp for definitions and behaviour of the parameters to the
    TBM_SETPOS Message

     
  • Robert May

    Robert May - 2005-01-19

    Logged In: YES
    user_id=674651

    On further investigation this appears to be a
    common "problem" with the following methods in trackbar.xs
    only:

    Min()
    Max()
    Pos()
    SelStart()
    SelEnd()

    However, Min() and Max() seem to work correctly in my
    testing. Can't explain this.

     
  • Robert May

    Robert May - 2005-03-16

    Logged In: YES
    user_id=674651

    This example shows a problem with
    Win32::GUI::Slider/Trackbar::Pos() method. It creates 3
    sliders,
    and attempts to set them to their center point in 3
    different ways
    - Pos(50)
    - SetPos(50)
    - Pos(50,1)
    The first method does not re-draw the slider in the new position
    until the control is selected (click near the bottom right
    of the
    select area), although it's stored position is correct (can be
    confirmed with GetPos()). This appears to be because when
    called with one parameter the re-draw flag in the SendMessage
    call is set incorrectly: forcing the redraw flag to 1 with
    Pos(50,1)
    solves the problem, as does using SetPos(50) which correctly
    defaults its re-draw flag to 1.

    Workaround:
    (1) Use the 2-parameter version of Pos, forcing the redraw
    flag to 1.
    (2) Use SetPos method

    I think (but have not tried) that the
    Solution is to correct line 642 of trackbar.xs from
    RETVAL = SendMessage(handle, TBM_SETPOS, 0, (LPARAM)
    SvIV(ST(1)))
    to
    RETVAL = SendMessage(handle, TBM_SETPOS, 1, (LPARAM)
    SvIV(ST(1)))

    This 'bug' also appears in Min() (line 603) and Max() (line
    623),
    although in those functions it has no obvious visual impact.

    Attached file sliderBug.pl contains the follwoing code

    use strict;
    use warnings;

    use Win32::GUI 1.0;

    my $mw = new Win32::GUI::Window (
    -size => [200,200],
    );

    my $s1 = $mw->AddSlider (
    -width => $mw->ScaleHeight(),
    -height => 30,
    );
    $s1->Pos(50);

    my $s2 = $mw->AddSlider (
    -width => $mw->ScaleHeight(),
    -height => 30,
    -top => $s1->Top() + $s1->Height(),
    );
    $s2->SetPos(50);

    my $s3 = $mw->AddSlider (
    -width => $mw->ScaleHeight(),
    -height => 30,
    -top => $s2->Top() + $s2->Height(),
    );
    $s3->Pos(50,1);

    print "1: ".$s1->GetPos()."\n";
    print "2: ".$s2->GetPos()."\n";
    print "3: ".$s3->GetPos()."\n";

    $mw->Show();
    Win32::GUI::Dialog();

     
  • Robert May

    Robert May - 2005-03-16

    Logged In: YES
    user_id=674651

    Sorry, it appeasr that you cannot attach files to follow
    ups, so you'll have to cut and paste the code from my last
    posting.

     
  • Robert May

    Robert May - 2005-07-11
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks