Re: [Lazarus] Setting a groupbox caption bold?

2019-04-01 Thread Werner Pamler via lazarus
You did not say that you want to have bold caption for several controls. 
In order to "bold" all controls on a form, I use another procedure which 
is called from the OnCreate event of a form and recursively iterates 
through all controls and their children, seeks for TCustomGroupBox 
controls and calls "BoldGroup" for them. Just look at the attachment to 
see how it works; the demo contains a hierarchy of various levels of 
groupbox containers.
<>
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Setting a groupbox caption bold?

2019-04-01 Thread Bo Berglund via lazarus
On Mon, 1 Apr 2019 00:42:45 +0200, Werner Pamler via lazarus
 wrote:

>procedure BoldGroup(AControl: TWinControl);
>var
>   i: Integer;
>   propinfo: PPropInfo;
>   cntrl: TControl;
>   fnt: TFont;
>begin
>   for i:=0 to AControl.ControlCount-1 do begin
>     cntrl := AControl.Controls[i];
>     propinfo := GetPropInfo(cntrl, 'ParentFont');
>     if propinfo <> nil then
>   SetOrdProp(cntrl, propinfo, Longint(false));
>     propinfo := GetPropInfo(cntrl, 'Font');
>     if propinfo <> nil then begin
>   fnt := TFont(GetObjectProp(cntrl, 'Font'));
>   fnt.Style := [];
>   SetObjectProp(cntrl, 'Font', fnt);
>     end;
>   end;
>   AControl.Font.Style := [fsBold];

So I tried to put this into Lazarus 2.0.0...
After struggling with illegal whitespace characters when copy pasting
from the news reader into Lazarus I put it into a text editor and
cleaned up these before copy-paste into Lazarus again.

procedure BoldGroup(AControl: TWinControl);
var
i: Integer;
propinfo: PPropInfo;
cntrl: TControl;
fnt: TFont;
begin
for i:=0 to AControl.ControlCount-1 do
begin
cntrl := AControl.Controls[i];
propinfo := GetPropInfo(cntrl, 'ParentFont');
if propinfo <> nil then
SetOrdProp(cntrl, propinfo, Longint(false));
propinfo := GetPropInfo(cntrl, 'Font');
if propinfo <> nil then
begin
fnt := TFont(GetObjectProp(cntrl, 'Font'));
fnt.Style := [];
SetObjectProp(cntrl, 'Font', fnt);
end;
end;
AControl.Font.Style := [fsBold];
end;

I also had to add typinfo to uses.

Now it did work but only after rearranging the calls from OnCreate:

This works:
  BoldGroup(gbxValues);
  BoldGroup(gbxDHT);
  BoldGroup(gbxNetwork);
  BoldGroup(gbxAPmode);
  BoldGroup(gbxStationmode);

But this does not work:
  BoldGroup(gbxDHT);
  BoldGroup(gbxNetwork);
  BoldGroup(gbxAPmode);
  BoldGroup(gbxStationmode);
  BoldGroup(gbxValues);

gbxValues is a container groupbox for all of the others.
In the nonworking case the ONLY groupbox that get bold caption is the
gbxValues box...

Seems like the call to bold the caption of the gbxValues container
removes the bold already set on the internal groupboxes...


-- 
Bo Berglund
Developer in Sweden

-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] sharing units between lazarus and delphi

2019-04-01 Thread Andrea Mauri via lazarus
Dear all,
I have a project fully developed on Lazarus. It is a desktop application
running on win, linux and mac.
I would like to test Delphi in order to try to build a mobile application
using my lazarus units.
I can suppose to divide my units in those that should act exactly the same
and those that should be modified.
The first group belongs to not graphical units, the second group includes
units that uses the canvas.
What should be the preferable way to make my units compilable both by
fpc/Lazarus and Delphi?
Is it better to use MODE DELPHI or is it better to introduce IFDEFs all
along the code? (e.g. for different usage of @ between fpc and delphi).
What are the pros and cons of the two strategies?
Code compiled using MODEL DELPHI is comparable, e.g. in terms of
performance, to code compiled using OBJFPC?

Any hint is really appreciated.
Andrea
-- 
___
lazarus mailing list
lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus