View Issue Details

IDProjectCategoryView StatusLast Update
0030340LazarusLCLpublic2016-07-08 15:06
ReporterRik van KekemAssigned ToBart Broersma 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
PlatformOSWindowsOS Version
Product Version1.6.1 (SVN)Product Build 
Target Version1.6.2Fixed in Version1.6.2 
Summary0030340: TFontDialog fdLimitSize for font-size doesn't work
DescriptionWhen setting fdLimitSize in options and MaxFontSize and MinFontSize on TFontDialog you would expect the dialog to limit the font-size. Instead the font-size listbox is empty and when choosing a valid font-size the OK-button gives a "Size must be between 0 and 0 points." error.

Steps To ReproduceEmpty project with one button:
procedure TForm1.Button1Click(Sender: TObject);
var
  Fd: TFontDialog;
begin
  Fd := TFontDialog.Create(nil);
  try
    Fd.Font.Name := 'Arial';
    Fd.Font.Size := 9;
    Fd.MinFontSize := 8;
    Fd.MaxFontSize := 24;
    Fd.Options := Fd.Options + [fdLimitSize];
    if Fd.Execute then;
  finally
    Fd.Free;
  end;
end;

Press button and choose a valid (9) point size and press ok.
Additional InformationIn lazarus/lcl/interfaces/win32/win32wsdialogs.pp the fdLimitSize is implemented correctly but nowhere is the setting of MaxFontSize/MinFontSize to be found. Without it the dialog check for Min 0 and Max 0.

[code]if fdLimitSize in Options then Result := Result or CF_LIMITSIZE;[/code]
TagsNo tags attached.
Fixed in Revisionr52649
LazTarget1.6.2
WidgetsetWin32/Win64
Attached Files
  • win32wsdialogs.pp.patch (550 bytes)
    Index: win32wsdialogs.pp
    ===================================================================
    --- win32wsdialogs.pp	(revision 52619)
    +++ win32wsdialogs.pp	(working copy)
    @@ -1069,6 +1069,11 @@
           Flags := GetFlagsFromOptions(Options);
           Flags := Flags or CF_INITTOLOGFONTSTRUCT or CF_BOTH;
           RGBColors := DWORD(Font.Color);
    +      if fdLimitSize in Options then
    +      begin
    +        nSizeMin:=MinFontSize;
    +        nSizeMax:=MaxFontSize;
    +      end;
         end;
         UserResult := ChooseFontW(@CFW);
         // we need to update LF now
    
  • win32wsdialogs.pp_now_with_spaces.patch (554 bytes)
    Index: win32wsdialogs.pp
    ===================================================================
    --- win32wsdialogs.pp	(revision 52619)
    +++ win32wsdialogs.pp	(working copy)
    @@ -1069,6 +1069,11 @@
           Flags := GetFlagsFromOptions(Options);
           Flags := Flags or CF_INITTOLOGFONTSTRUCT or CF_BOTH;
           RGBColors := DWORD(Font.Color);
    +      if fdLimitSize in Options then
    +      begin
    +        nSizeMin := MinFontSize;
    +        nSizeMax := MaxFontSize;
    +      end;
         end;
         UserResult := ChooseFontW(@CFW);
         // we need to update LF now
    

Activities

Rik van Kekem

2016-07-04 12:20

reporter   ~0093527

Confirmed that adding this works:
if fdLimitSize in Options then
begin
  nSizeMin:=MinFontSize;
  nSizeMax:=MaxFontSize;
end;

I placed it below RGBColors := DWORD(Font.Color); but I'm not sure if there is a better place (or it should be done another way).

Bart Broersma

2016-07-04 13:10

developer   ~0093528

Please attach a patch.

Rik van Kekem

2016-07-04 13:24

reporter  

win32wsdialogs.pp.patch (550 bytes)
Index: win32wsdialogs.pp
===================================================================
--- win32wsdialogs.pp	(revision 52619)
+++ win32wsdialogs.pp	(working copy)
@@ -1069,6 +1069,11 @@
       Flags := GetFlagsFromOptions(Options);
       Flags := Flags or CF_INITTOLOGFONTSTRUCT or CF_BOTH;
       RGBColors := DWORD(Font.Color);
+      if fdLimitSize in Options then
+      begin
+        nSizeMin:=MinFontSize;
+        nSizeMax:=MaxFontSize;
+      end;
     end;
     UserResult := ChooseFontW(@CFW);
     // we need to update LF now

Rik van Kekem

2016-07-04 13:25

reporter   ~0093530

Last edited: 2016-07-04 13:41

View 3 revisions

Patch attached (from latest trunk). It's my first patch so I hope I did it correctly (browse to file, and choose create patch with TortoiseSVN).

Mmm, maybe should have added spaces around :=. But that's overall inconsistent in Lazarus source.

Last patch is with correct spaces around :=

Rik van Kekem

2016-07-04 13:40

reporter  

win32wsdialogs.pp_now_with_spaces.patch (554 bytes)
Index: win32wsdialogs.pp
===================================================================
--- win32wsdialogs.pp	(revision 52619)
+++ win32wsdialogs.pp	(working copy)
@@ -1069,6 +1069,11 @@
       Flags := GetFlagsFromOptions(Options);
       Flags := Flags or CF_INITTOLOGFONTSTRUCT or CF_BOTH;
       RGBColors := DWORD(Font.Color);
+      if fdLimitSize in Options then
+      begin
+        nSizeMin := MinFontSize;
+        nSizeMax := MaxFontSize;
+      end;
     end;
     UserResult := ChooseFontW(@CFW);
     // we need to update LF now

Juha Manninen

2016-07-04 13:46

developer   ~0093532

Last edited: 2016-07-04 13:47

View 2 revisions

The general rule is to use the same style with surrounding code. Thus your code should have spaces. They can be added by the committer, too.
True, there are different styles around the sources depending on the author.

Limiting the font size does not work at all with GTK2 and QT bindings. All the sizes are shown.
Could somebody look at that, too?

Bart Broersma

2016-07-08 14:43

developer   ~0093626

Applied. Thanks.
Please close.

@Juha: please open a separate report for the issue you described.

Rik van Kekem

2016-07-08 15:06

reporter   ~0093627

Confirmed and closed.
Thanks.

Issue History

Date Modified Username Field Change
2016-07-04 12:08 Rik van Kekem New Issue
2016-07-04 12:20 Rik van Kekem Note Added: 0093527
2016-07-04 13:10 Bart Broersma Note Added: 0093528
2016-07-04 13:10 Bart Broersma Assigned To => Bart Broersma
2016-07-04 13:10 Bart Broersma Status new => assigned
2016-07-04 13:18 Bart Broersma LazTarget => -
2016-07-04 13:18 Bart Broersma Status assigned => feedback
2016-07-04 13:24 Rik van Kekem File Added: win32wsdialogs.pp.patch
2016-07-04 13:25 Rik van Kekem Note Added: 0093530
2016-07-04 13:25 Rik van Kekem Status feedback => assigned
2016-07-04 13:27 Rik van Kekem Note Edited: 0093530 View Revisions
2016-07-04 13:40 Rik van Kekem File Added: win32wsdialogs.pp_now_with_spaces.patch
2016-07-04 13:41 Rik van Kekem Note Edited: 0093530 View Revisions
2016-07-04 13:46 Juha Manninen Note Added: 0093532
2016-07-04 13:47 Juha Manninen Note Edited: 0093532 View Revisions
2016-07-08 14:43 Bart Broersma Fixed in Revision => r52649
2016-07-08 14:43 Bart Broersma LazTarget - => 1.6.2
2016-07-08 14:43 Bart Broersma Note Added: 0093626
2016-07-08 14:43 Bart Broersma Status assigned => resolved
2016-07-08 14:43 Bart Broersma Fixed in Version => 1.6.2
2016-07-08 14:43 Bart Broersma Resolution open => fixed
2016-07-08 14:43 Bart Broersma Target Version => 1.6.2
2016-07-08 15:06 Rik van Kekem Note Added: 0093627
2016-07-08 15:06 Rik van Kekem Status resolved => closed