View Issue Details

IDProjectCategoryView StatusLast Update
0001361JEDI VCL00 JVCL Componentspublic2004-04-22 01:10
ReporterogiesenAssigned Toogiesen 
PrioritynormalSeveritymajorReproducibilityrandom
Status closedResolutionfixed 
PlatformOSWindows 2000 ProOS VersionSP4 + Hotfixes
Product Version3.00 BETA 
Target VersionFixed in Version 
Summary0001361: Painting issues in TJvDatePickerEdit
DescriptionAs discussed already on bug 0001345, there appears to be an issue with the control painting for TJvDatePickerEdit and descendants. To summarize, the problem is that for some users (e.g. Peter) the button is overpainted when typing in the control or when clicking the button unless the button is wrapped in a dummy TWinControl parent. This fix however for me has the effect that there suddenly is an extra right margin of 7 pixels in the text area which is bad if the control has to be sized rather narrowly. I never ever saw the symptom that the button holder is supposed to cure myself nor has it ever been reported by any of our numerous users. I am attaching screenshots of both the extra margin that I see with the button holder and the overpainting that Peter reported without it.

BTW: Funny thing about the margin issue is that it doesn't happen at designtime. It only appears at runtime and even then it is rather unpredictable: I have one form with a TJvDatePickerEdit on it that consistently shows the text clipping seen in the attached screenshot. If I copy and paste this same control onto another form for testing, the text will not be clipped but the last digit will merely be invisible (scrolled off to the right). Without the button holder the date will fit into the visible text area completely. I tested this with both Delphi 5 and 7.
TagsNo tags attached.

Activities

2004-02-24 01:41

 

extra-margin.png (763 bytes)
extra-margin.png (763 bytes)

2004-02-24 01:43

 

JvDBDatePickerEdit.gif (1,146 bytes)
JvDBDatePickerEdit.gif (1,146 bytes)

user72

2004-02-24 03:43

  ~0003025

Maybe it's just a width calculation that isn't correct anymore when the button holder is in place?

user72

2004-02-24 03:46

  ~0003026

I think the solution is here (i.e remove the method):

procedure TJvCustomDatePickerEdit.GetInternalMargins(var ALeft, ARight: Integer);
begin
  inherited GetInternalMargins(ALeft, ARight);
// ARight := ARight + FDropButton.Width;
end;

ogiesen

2004-02-24 04:03

developer   ~0003027

Well, this does indeed remove the extra margin but now the cursor vanishes under the button instead of scrolling the text if the control is too narrow. The whole purpose of the GetInternalMargins code is exactly to avoid the problem you keep experiencing and I can only say that it is working perfectly for me and always has been on all machines I ever distributed this to (0000140:0000150 around the world on all kinds of platforms and locales). I am totally at a loss why the two of us see such different behaviour. Could maybe someone else comment on this as well? BTW: I am working off the very latest CVS sources.

user72

2004-02-24 04:34

  ~0003029

> I can only say that it is working perfectly for me
> and always has been on all machines I ever distributed this to

It only takes one :)

Anyway, I've looked into this in more detail and it turns out that the FDropButton's Width is 23 pixels although the FButtonHolder is 17px wide (sset by the GetSystemMetrics call) and FDropButton.Align = alClient. Very strange.

The easiest solution is probably to change:

procedure TJvCustomDatePickerEdit.GetInternalMargins(var ALeft, ARight: Integer);
begin
  inherited GetInternalMargins(ALeft, ARight);
  ARight := ARight + FButtonHolder.Width;
end;

but you could also uncomment:
...
  FDropButton := TSpeedButton.Create(Self);
...
  // uncomment this line:
  Width := GetSystemMetrics(SM_CXVSCROLL) + 1;

user72

2004-02-24 04:35

  ~0003031

Swapping the Align and Parent calls, sets the button's width correctly as well:

  with FDropButton do
  begin
    Align := alClient;
    Parent := FButtonHolder;

ogiesen

2004-02-24 04:45

developer   ~0003033

Right, exchanging Parent and Align AND making the proposed change to GetInternalMargins finally solved it for me. I have checked in the new revision now. Does this work for you as well this time (just to make sure ;) )?

user72

2004-02-24 04:47

  ~0003034

Works for me as well. Glad we solved that one<g>. Now, on to the next one...

PS
You can close this bug now, I guess

ogiesen

2004-02-24 04:48

developer   ~0003035

Yay! Thanks again! :]

...but we still don't know why the previous version didn't work for you... ;)

Issue History

Date Modified Username Field Change
2004-02-24 01:41 ogiesen New Issue
2004-02-24 01:41 ogiesen File Added: extra-margin.png
2004-02-24 01:43 ogiesen File Added: JvDBDatePickerEdit.gif
2004-02-24 03:43 user72 Note Added: 0003025
2004-02-24 03:46 user72 Note Added: 0003026
2004-02-24 04:03 ogiesen Note Added: 0003027
2004-02-24 04:34 user72 Note Added: 0003029
2004-02-24 04:35 user72 Note Added: 0003031
2004-02-24 04:45 ogiesen Note Added: 0003033
2004-02-24 04:47 ogiesen Assigned To => ogiesen
2004-02-24 04:47 ogiesen Status new => feedback
2004-02-24 04:47 ogiesen Resolution open => fixed
2004-02-24 04:47 user72 Note Added: 0003034
2004-02-24 04:48 ogiesen Status feedback => resolved
2004-02-24 04:48 ogiesen Note Added: 0003035
2004-04-22 01:10 user72 Status resolved => closed