View Issue Details

IDProjectCategoryView StatusLast Update
0001542JEDI VCL00 JVCL Componentspublic2004-04-10 06:18
ReporterMarkus SpoettlAssigned Tomarcelb 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001542: JvInspector scrollbar flickering with non-xp style
DescriptionAssume you have an inspector with items and plenty of space left so that you wouldn't need a scrollbar. If you now resize the host window (Inspector.align = client) the scrollbar becomes visible briefly.

The strange thing is that when it flickers it is in the old Windows style (gray), not displayed as a blue XP standard scrollbar. This is strange because the scrollbar is displayed correctly once it is really necessary. I assume that there is something left behind uninitialized when it's just shown for testing if it needs to be shown (assuming this is the reason for briefly displaying it).

Using XP Pro with SP1, Delphi 6, not using themes.
TagsNo tags attached.

Activities

marcelb

2004-03-30 02:26

manager   ~0003511

Hmm, I can't really pinpoint the cause here. The size of the item tree is calculated and depending on that value the scrollbar is either shown or hidden.
  This is done in the UpdateScrollBars method, which is called when the bounds of the control are changed (DoBoundsChanged, which I assume will also be called during a resize).
  Anyone else able to see what's wrong here?

marcelb

2004-04-06 03:41

manager   ~0003661

Changed status to feedback in the hope of someone else willing to take a look.

hasse42g

2004-04-06 04:53

reporter   ~0003668

I found the problem. Basically the call to SetScrollInfo makes the scrollbar flicker although it is hidden. The fix is easy: don't Set ScrollInfo if the scrollbar is not visible.

Below are the updated UpdateScrollBars that works for me (I marked my changes with HEG-tags)

Regards

Hans-Eric Grönlund


Code:

procedure TJvCustomInspector.UpdateScrollBars;
var
  DrawHeight: Integer;
  ClHeight: Integer;
  ScFactor: Extended;
  {$IFDEF VCL}
  ScrollInfo: TScrollInfo;
  {$ENDIF VCL}
  BCount: Integer;
  BPerPage: Integer;
  ShowVertSB: Boolean; //HEG
  ShowHorzSB: Boolean; //HEG
begin
  if csDestroying in ComponentState then
    Exit;

  if not UseBands then
  begin
    ShowScrollBars(SB_HORZ, False);
    // Cache the image height, client height and scroll factor
    DrawHeight := ImageHeight;
    ClHeight := ClientHeight;
    ScFactor := ScrollfactorV;
    { Needed to redisplay the scrollbar after it's hidden in the CloseUp method
      of an enumerated item's combobox }
    //HEG:
    ShowVertSB := Round((DrawHeight) / ScFactor) >= Round(ClHeight / ScFactor);
    ShowScrollBars(SB_VERT, ShowVertSB);
    if ShowVertSB then
    begin
      {$IFDEF VCL}
      with ScrollInfo do
      begin
        cbSize := SizeOf(ScrollInfo);
        fMask := SIF_ALL;
        nMin := 0;
        nMax := Round((IdxToY(Succ(YToIdx(ImageHeight - ClientHeight))) + ClientHeight) / ScFactor);
        nPage := Round(ClHeight / ScFactor);
        nPos := Round(IdxToY(TopIndex) / ScFactor);
        nTrackPos := 0;
      end;
      SetScrollInfo(Handle, SB_VERT, ScrollInfo, True);
      {$ENDIF VCL}
      {$IFDEF VisualCLX}
      with FVertScrollBar do
      begin
        Min := 0;
        try
  // Max := Round((IdxToY(Succ(YToIdx(ImageHeight - ClientHeight))) + ClientHeight) / ScFactor);
  // LargeChange := Round(ClHeight / ScFactor);
  // Position := Round(IdxToY(TopIndex) / ScFactor);
          if ImageHeight > ClientHeight then
            Max := ImageHeight-Clientheight;
          LargeChange := Self.ClientHeight;
          Position := IdxToY(TopIndex);
        except
          on E: Exception do ShowMessage(E.Message);
        end;
      end;
      {$ENDIF VisualCLX}
    end;
  end
  else
  begin
    ShowScrollBars(SB_VERT, False);
    { Needed to redisplay the scrollbar after it's hidden in the CloseUp method
      of an enumerated item's combobox }
    BCount := BandStarts.Count;
    BPerPage := ClientWidth div BandWidth;
    //HEG:
    ShowHorzSB := BCount > BPerPage;
    ShowScrollBars(SB_HORZ, ShowHorzSB);
    if ShowHorzSB then
    begin
      {$IFDEF VCL}
      with ScrollInfo do
      begin
        cbSize := SizeOf(ScrollInfo);
        fMask := SIF_ALL;
        nMin := 0;
        nMax := BCount - 1;
        nPage := BPerPage;
        nPos := GetBandFor(TopIndex);
        nTrackPos := 0;
      end;
      SetScrollInfo(Handle, SB_HORZ, ScrollInfo, True);
      {$ENDIF VCL}
      {$IFDEF VisualCLX}
      with FHorzScrollBar do
      begin
        Min := 0;
        Max := BCount - 1;
        LargeChange := BPerPage;
        Position := GetBandFor(TopIndex);
      end;
      {$ENDIF VisualCLX}
    end;
  end;
  Invalidate;
end;

marcelb

2004-04-06 05:11

manager   ~0003669

Well, that seems to be working. Thanks! Will add to CVS shortly.

marcelb

2004-04-09 12:21

manager   ~0003758

Markus, could you confirm this solved the issue for you?

Markus Spoettl

2004-04-10 06:10

reporter   ~0003782

Yes, that's fixed. The strange scrollbar behaviour (mixed style) still exists though.

Issue History

Date Modified Username Field Change
2004-03-29 05:30 Markus Spoettl New Issue
2004-03-29 23:56 marcelb Status new => confirmed
2004-03-30 02:26 marcelb Note Added: 0003511
2004-04-06 03:41 marcelb Note Added: 0003661
2004-04-06 03:41 marcelb Status confirmed => feedback
2004-04-06 04:52 anonymous Note Added: 0003667
2004-04-06 04:52 anonymous Note Deleted: 0003667
2004-04-06 04:53 hasse42g Note Added: 0003668
2004-04-06 05:11 marcelb Note Added: 0003669
2004-04-09 12:21 marcelb Note Added: 0003758
2004-04-10 06:10 Markus Spoettl Note Added: 0003782
2004-04-10 06:18 marcelb Status feedback => resolved
2004-04-10 06:18 marcelb Resolution open => fixed
2004-04-10 06:18 marcelb Assigned To => marcelb