View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0005871 | JEDI VCL | 00 JVCL Components | public | 2012-05-01 09:00 | 2014-12-04 16:35 |
Reporter | dkgnt | Assigned To | obones | ||
Priority | normal | Severity | crash | Reproducibility | always |
Status | resolved | Resolution | suspended | ||
Product Version | 3.45 | ||||
Target Version | Fixed in Version | ||||
Summary | 0005871: TjvDateEdit not working with DPI<>96 | ||||
Description | When I run a program with higher DPI (larger font size in windows 7) the popup calendar is not being showed correctly. The font size is not adapted and the days are very big so you see only half a day. | ||||
Tags | No tags attached. | ||||
|
Please use the latest SVN version and provide the zipped sources of a sample application showing this. Also, please try to provide a patch for this |
|
TopicStarter is a bit wrong. The condition required is not high DPI but any custom font of windows "message" area. That can be set even in Win95 using Display properties. Surely Win98 Themes made thsi even easier, and modern monitors with 120+ PPI made it yet more frequent. RxLib scrin size was calculated by hands and set for MS Sans Serif font sz 8 height -11 default for early Delphi and Windows 3.x. Then someone smart changed it to request font from OS instead. And the calculation made for fixed SansSerif 8 became irrelevant... I made a crude fox for it, but well... it is just crude. using non-standard component in RxLib is reasonable - there was no DateTime Picker in 16-bit Win 3.1, But today is almost 20 years after Win95 release... |
2013-04-19 17:57
|
|
2013-04-19 17:57
|
|
2013-04-19 17:57
|
|
2013-04-19 17:57
|
|
|
JvPickDate.pas changes are: 1) adding a variable 2) commenting out SetFont call in the beginning 3) setting Anchors for buttons 4) adding ScaleBy in the very end constructor TJvPopupCalendar.Create(AOwner: TComponent); .......... {$ENDIF JVCLThemesEnabled} tmpF: TFont; // need to get PPI for Windows default font for text, since // global VCL.TScreen PPI may be different from this one, since // user theme may have different fonts for different form elements. begin inherited Create(AOwner); ............... Color := clBtnFace; // FontSetDefault(Font); // moved to bottom if AOwner is TControl then FBtns[0] := TJvTimerSpeedButton.Create(Self); with FBtns[0] do begin ....... Anchors := [akLeft, akTop]; // for ScaleBy later end; FBtns[1] := TJvTimerSpeedButton.Create(Self); with FBtns[1] do begin ....... Anchors := [akLeft, akTop]; // for ScaleBy later end; ....... FBtns[2] := TJvTimerSpeedButton.Create(Self); with FBtns[2] do begin ....... Anchors := [akRight, akTop]; // for ScaleBy later end; FBtns[3] := TJvTimerSpeedButton.Create(Self); with FBtns[3] do begin ....... Anchors := [akRight, akTop]; // for ScaleBy later end; tmpf := TFont.Create; try FontSetDefault(tmpF); // controls coordinates are hardcoded for MS Sans Serif sz 8 ht -11 if tmpF.Height <> -11 then begin // default for sz 8 font if tmpF.Height < 0 // MSDN LOGFONT: >0 and <0 are different beasts, can not be compared then ScaleBy(tmpF.Height, -11) else ScaleBy(tmpF.Size, 8); // much less precision FBtns[1].Left := FBtns[0].Left + FBtns[0].Width + HorzOffset; FBtns[2].Left := FBtns[3].Left - FBtns[2].Width - HorzOffset; end; Font.Assign(tmpF); finally tmpF.Free; end; //Polaris CheckButton; end; |
2013-04-19 18:02
|
Unit3.pas (532 bytes) |
2013-04-19 18:02
|
Unit3.dfm (1,493 bytes) |
|
for Edit.csDialog == csDialog we need to make analogue fix in constructor TJvSelectDateDlg.Create 1) add var tmpF: TFont; 2) in the beginning disable // FontSetDefault(Font); - doing it below, when all controls created 3) add to the bottom of contructor: tmpf := TFont.Create; try FontSetDefault(tmpF); // controls coordinates are hardcoded for MS Sans Serif sz 8 ht -11 if tmpF.Height <> -11 then begin // default for sz 8 font if tmpF.Height < 0 // MSDN LOGFONT: >0 and <0 are different beasts, can not be compared then ScaleBy(tmpF.Height, -11) else ScaleBy(tmpF.Size, 8); // much less precision end; Font.Assign(tmpF); finally tmpF.Free; end; OnKeyDown := FormKeyDown; Calendar.CalendarDate := Trunc(Now); ActiveControl := Calendar; end; This is not a proper fix, but proper one would be complete remaking of the whole dialogs... |
|
Thanks, it works but only if in TJvSelectDateDlg.Create I make this changes:if tmpF.Height <> -12 then begin // default for sz 8 font if tmpF.Height < 0 // MSDN LOGFONT: >0 and <0 are different beasts, can not be compared then ScaleBy(tmpF.Height, -9) else ScaleBy(tmpF.Size, 8); // much less precision |
|
this would work somewhat differently with Classic/Aero/Glass and 96/120/150 and XP/Vista-7 did not tried on win8 or win2k "magic constants" are bad thing, especially in problematic area like VCL scaling (a lot of quantization errors, different on different machines) If you would make proper implementation, rather than quick and dirty hack, then everyone may benefit from it. Or a reliable approach would be to remove this function all together, and come back to initial layout assumption that everithing is "MS Sans Serif font sz 8 height -11 default for early Delphi and Windows 3.x." |
|
if tmpF.Height <> -12 then begin // default for sz 8 font then ScaleBy(tmpF.Height, -9) Actually this should not work. The constant should be the same. My code does ScaleBy from default "-11" if the actual value is "not default -11" But your code looks plain wrong. For example it would make no scaling if Height == -9 <> -12 |
2013-05-15 08:31
|
|
|
Thank for your comment. With your code the numbers where also cut. See Screenshot1. I tried a little bit in the numbers and found, that changing it in this way it worked. It works also with if tmpF.Height <> -11 but as the default with 96dpi was -12 I changed it, but it is not necessery. The only change that give me a good result is ScaleBy(tmpF.Height, -9). Do you have an Idea, what I can change? I develope under Windows 8 with 96 dpi. The font of the control is Tahoma 8. I test it with windows 7 in a VirtualBox with 125% Font size. |
|
i was developing on win7 125% natively and my co-workers developed on XP 96dpi i just note that your code should have no sense, that all i can do. perhaps it is affected by the parent form's scaling or whatever |
2013-08-22 19:00
|
0001-TJvPopupCalendar-used-by-TRxDateEdit-is-a-custom-dat.patch (4,420 bytes)
From dfb1849df8c37a07a40dc32a761c740e1f212e59 Mon Sep 17 00:00:00 2001 From: the-Arioch <the_Arioch@nm.ru> Date: Tue, 20 Aug 2013 19:40:32 +0400 Subject: [PATCH 1/3] TJvPopupCalendar - used by TRxDateEdit - is a custom date selecting window, created using pre-calculated coordinates. Someone then enabled scaling for non-96DPI fonts... without re-calculating coords. More details at: http://issuetracker.delphi-jedi.org/view.php?id=5871 This is partial fix. Proper fix would be either removing this and using TDateTimePicker instead (our customers are against) or reworking the window out of using any pre-defined numbers. --- jvcl/run/JvPickDate.pas | 51 ++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/jvcl/run/JvPickDate.pas b/jvcl/run/JvPickDate.pas index 454032a..16bd8a2 100644 --- a/jvcl/run/JvPickDate.pas +++ b/jvcl/run/JvPickDate.pas @@ -955,6 +955,12 @@ const var Control, BackPanel: TWinControl; {$ENDIF JVCLThemesEnabled} + + tmpF: TFont; + // need to get PPI for Windows default font for text, since + // global VCL.TScreen PPI may be different from this one, since + // user theme may have different fonts for different form elements. + begin inherited Create(AOwner); FFourDigitYear := IsFourDigitYear; @@ -962,7 +968,7 @@ begin Width := Max(PopupCalendarSize.X, 180); Color := clBtnFace; - FontSetDefault(Font); +// FontSetDefault(Font); // moved to bottom if AOwner is TControl then ShowHint := TControl(AOwner).ShowHint else @@ -975,7 +981,7 @@ begin begin VertOffset := 0; HorzOffset := 0; - BtnSide := 16 + BtnSide := 16; end else begin @@ -1025,6 +1031,7 @@ begin CreateButtonGlyph(Glyph, 0); OnClick := PrevYearBtnClick; Hint := RsPrevYearHint; + Anchors := [akLeft, akTop]; // for ScaleBy later end; FBtns[1] := TJvTimerSpeedButton.Create(Self); @@ -1035,6 +1042,7 @@ begin CreateButtonGlyph(Glyph, 1); OnClick := PrevMonthBtnClick; Hint := RsPrevMonthHint; + Anchors := [akLeft, akTop]; // for ScaleBy later end; FTitleLabel := TLabel.Create(Self); @@ -1057,6 +1065,7 @@ begin CreateButtonGlyph(Glyph, 2); OnClick := NextMonthBtnClick; Hint := RsNextMonthHint; + Anchors := [akRight, akTop]; // for ScaleBy later end; FBtns[3] := TJvTimerSpeedButton.Create(Self); @@ -1067,6 +1076,25 @@ begin CreateButtonGlyph(Glyph, 3); OnClick := NextYearBtnClick; Hint := RsNextYearHint; + Anchors := [akRight, akTop]; // for ScaleBy later + end; + + tmpf := TFont.Create; + try + FontSetDefault(tmpF); + // controls coordinates are hardcoded for MS Sans Serif sz 8 ht -11 + if tmpF.Height <> -11 then begin // default for sz 8 font + if tmpF.Height < 0 // MSDN LOGFONT: >0 and <0 are different beasts, can not be compared + then ScaleBy(tmpF.Height, -11) + else ScaleBy(tmpF.Size, 8); // much less precision + + FBtns[1].Left := FBtns[0].Left + FBtns[0].Width + HorzOffset; + FBtns[2].Left := FBtns[3].Left - FBtns[2].Width - HorzOffset; + end; + + Font.Assign(tmpF); + finally + tmpF.Free; end; //Polaris CheckButton; @@ -1268,6 +1296,7 @@ type constructor TJvSelectDateDlg.Create(AOwner: TComponent); var Control: TWinControl; + tmpF: TFont; begin inherited CreateNew(AOwner, 0); // BCB compatible Caption := RsDateDlgCaption; @@ -1276,7 +1305,7 @@ begin BorderIcons := [biSystemMenu]; ClientHeight := 158; // Polaris ClientWidth := 222; - FontSetDefault(Font); +// FontSetDefault(Font); - doing it below, when all controls created Position := poScreenCenter; ShowHint := True; KeyPreview := True; @@ -1427,6 +1456,22 @@ begin OnDblClick := CalendarDblClick; end; + + tmpf := TFont.Create; + try + FontSetDefault(tmpF); + // controls coordinates are hardcoded for MS Sans Serif sz 8 ht -11 + if tmpF.Height <> -11 then begin // default for sz 8 font + if tmpF.Height < 0 // MSDN LOGFONT: >0 and <0 are different beasts, can not be compared + then ScaleBy(tmpF.Height, -11) + else ScaleBy(tmpF.Size, 8); // much less precision + end; + + Font.Assign(tmpF); + finally + tmpF.Free; + end; + OnKeyDown := FormKeyDown; Calendar.CalendarDate := Trunc(Now); ActiveControl := Calendar; -- 1.8.3.msysgit.0 |
|
So, what do we do here? |
|
No news, suspending the issue |
Date Modified | Username | Field | Change |
---|---|---|---|
2012-05-01 09:00 | dkgnt | New Issue | |
2012-06-11 17:31 | obones | Note Added: 0019863 | |
2012-06-11 17:31 | obones | Status | new => feedback |
2013-04-19 17:56 | Arioch | Note Added: 0020465 | |
2013-04-19 17:57 | Arioch | File Added: RxDateTime_1_MSS8.png | |
2013-04-19 17:57 | Arioch | File Added: RxDateTime_2_Current.png | |
2013-04-19 17:57 | Arioch | File Added: RxDateTime_3_Fixed.png | |
2013-04-19 17:57 | Arioch | File Added: RxDateTime_4_Fixed_Classic.png | |
2013-04-19 18:01 | Arioch | Note Added: 0020466 | |
2013-04-19 18:02 | Arioch | File Added: Unit3.pas | |
2013-04-19 18:02 | Arioch | File Added: Unit3.dfm | |
2013-04-19 18:33 | Arioch | Note Added: 0020467 | |
2013-05-14 22:59 | dkgnt | Note Added: 0020478 | |
2013-05-14 23:10 | Arioch | Note Added: 0020479 | |
2013-05-14 23:17 | Arioch | Note Added: 0020480 | |
2013-05-15 08:31 | dkgnt | File Added: screenshot1.png | |
2013-05-15 08:37 | dkgnt | Note Added: 0020481 | |
2013-05-15 10:22 | Arioch | Note Added: 0020482 | |
2013-08-22 19:00 | Arioch | File Added: 0001-TJvPopupCalendar-used-by-TRxDateEdit-is-a-custom-dat.patch | |
2013-09-02 14:52 | Arioch | Status | feedback => confirmed |
2013-12-18 16:07 | obones | Note Added: 0020887 | |
2013-12-18 16:07 | obones | Status | confirmed => feedback |
2014-12-04 16:35 | obones | Note Added: 0021125 | |
2014-12-04 16:35 | obones | Status | feedback => resolved |
2014-12-04 16:35 | obones | Resolution | open => suspended |
2014-12-04 16:35 | obones | Assigned To | => obones |