Recent

Author Topic: [SOLVED] Do I Need This For Linux  (Read 1193 times)

Sandstone

  • New Member
  • *
  • Posts: 11
[SOLVED] Do I Need This For Linux
« on: October 29, 2020, 11:37:58 pm »
I am working on porting some code to Linux and came across this issue. There is this initialization procedure to get the default font:

procedure Initialize;
var
  NCM: TNonClientMetrics;
begin
  NCM.cbSize := SizeOf(NCM);
  if SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, @NCM, 0) then
    GDefaultFontName := NCM.lfMessageFont.lfFaceName;
end;

Can I comment this out for Linux or is there a better "system agnostic" way to do it? Right now I get the compiler message Error: Identifier not found "TNonClientMetrics"
« Last Edit: November 06, 2020, 10:15:26 pm by Sandstone »

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: Do I Need This For Linux
« Reply #1 on: October 29, 2020, 11:48:48 pm »
you can do that but I am sure the rest of the code requires some data from that structure.

 That structure holds the information about the form border icons, scrollbars, border width etc and so on..

 you can find the define for the structure on the net, just leave out the "t" at the start and you will see it at $MS.


 Just use the equivalent of Linux when extracting data.
The only true wisdom is knowing you know nothing

dbannon

  • Hero Member
  • *****
  • Posts: 2792
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Do I Need This For Linux
« Reply #2 on: October 30, 2020, 07:18:06 am »
Don't have access to my system here but from memory, I do something like this in Linux -

DefaultFont := Label1.Canvas.Font.Name

Label1 is just a label thats there anyway, just see what its font is set to.

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Do I Need This For Linux
« Reply #3 on: October 30, 2020, 11:17:23 am »
Isn't SystemParametersInfo() Windows-specific anyway? I suspect that the TNonClientMetrics error is hiding a more important one a couple of lines down.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

winni

  • Hero Member
  • *****
  • Posts: 3197
Re: Do I Need This For Linux
« Reply #4 on: October 30, 2020, 03:11:51 pm »
Hi!

SystemParametersInfo exist in win32, gtk, qt, carbon, cocoa ...

Winni

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: Do I Need This For Linux
« Reply #5 on: October 30, 2020, 03:46:48 pm »
Ok then maybe the lcltype and   lclintf units need to be added
The only true wisdom is knowing you know nothing

Sandstone

  • New Member
  • *
  • Posts: 11
Re: Do I Need This For Linux
« Reply #6 on: October 30, 2020, 04:04:28 pm »
I do have LCLIntf and LCLType in the uses. I was looking into it further and it appears that this is part of a Free Pascal package winunits-base.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6683
Re: Do I Need This For Linux
« Reply #7 on: October 30, 2020, 04:30:11 pm »
SystemParametersInfo exist in win32, gtk, qt, carbon, cocoa ...

Thanks, I did phrase it as a question :-)

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Sandstone

  • New Member
  • *
  • Posts: 11
Re: Do I Need This For Linux
« Reply #8 on: October 30, 2020, 05:34:21 pm »
Thanks everyone. I solved it with a few ifdef's. Also used your suggestion of DefaultFont := Label1.Canvas.Font.Name for Linux.

 

TinyPortal © 2005-2018