Window and gadgets building and SystemMetrics constants

Windows specific forum
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Window and gadgets building and SystemMetrics constants

Post by boddhi »

Hello,

Does anyone know where I could find docs that details how windows and gadgets are graphically built in relation to the SystemMetrics constants?

I've spend time to find this kind of informations without results.

Thanks.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: Window and gadgets building and SystemMetrics constants

Post by BarryG »

Not sure what you mean, but maybe this? -> https://www.purebasic.fr/blog/?p=336

It explains what the gadgets are behind the scenes on each OS.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Window and gadgets building and SystemMetrics constants

Post by boddhi »

BarryG wrote: Not sure what you mean, but maybe this? -> https://www.purebasic.fr/blog/?p=336
Hi BarryG,

Thanks for your reply but it's not really what I'm searching.

It's something like that for windows and gadgets:
Image

I've tried many times to understand how they are built but, for example, for a window or gadget I've created, when I add up the various values retrieved via the constants, I can't find the global values defined programmatically. I'm sure there are other “constants” I'm not taking into account...
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: Window and gadgets building and SystemMetrics constants

Post by BarryG »

boddhi wrote: Fri Jul 26, 2024 11:01 amI can't find the global values defined programmatically
So are you asking what the values are for each "SM_*" constant?
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Window and gadgets building and SystemMetrics constants

Post by boddhi »

BarryG wrote: So are you asking what the values are for each "SM_*" constant?
Not at all! This, this isn't a problem.

It's how Windows graphically builds a window and gadgets.
E.g for width window, it uses two outer borders (left and right, i.e. 2 SM_CXBORDER), two inner margins ? (2 SM_CX????), etc, etc.
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: Window and gadgets building and SystemMetrics constants

Post by BarryG »

Oh, I see. Sorry for misunderstanding. :(
User avatar
spikey
Enthusiast
Enthusiast
Posts: 767
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: Window and gadgets building and SystemMetrics constants

Post by spikey »

boddhi wrote: Fri Jul 26, 2024 11:30 am It's how Windows graphically builds a window and gadgets.
It's ... complicated. There's no single "windows are drawn here" location where everything is worked out monolithically. In fact there's no distinction between a window and a gadget. Everything is a "window", it's just that not every window has identical features or behaviours.

More specifically everything is a class object which contains code that actions messages from and generates notifications back to the operating system or host application. This includes the code which dictates how the control is drawn.

If you want to begin to understand how it's put together you could start here:
https://learn.microsoft.com/en-us/windo ... plications

But I can tell you it's not going to answer the question that you posed above because - it doesn't work like that! The SM_* constants are only values that are used as arguments to the GetSystemMetrics function. The values returned by that function aren't constants and will depend on the specific configuration of a specific target machine at a specific runtime.

What are you trying to achieve? If you tell us a bit more about the problem you are trying to solve or what you are trying to accomplish then we might be able to give you a more directly helpful answer.
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Window and gadgets building and SystemMetrics constants

Post by boddhi »

Thanks for your reply, Spikey :wink:
spikey wrote: In fact there's no distinction between a window and a gadget.
I know that :wink: Gadgets and windows are just controls... :mrgreen:

I've no specific need. But, by the past, I needed to design windows with gadgets and to know precisely (to the pixel) for example scrollbars widths and heights to correctly size listicons and others gadgets using them to fit perfectly in windows. But, as I've said, the retrieve values using GetSystemMetrics didn't correpond to what I had in screen (with a print screen analysis). So I therefore supposed that other graphic elements (single lines, double lines, 3D lines, etc???) might also have to be drawn.

That's why I wanted to know if there was a doc describing exactly how the controls were graphically drawn and what SM_ elements made them up.
I also know that it could be different depending on Windows version, each with its own style...

Thanks for the link. (My English skills will be severely tested :mrgreen: )
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Window and gadgets building and SystemMetrics constants

Post by boddhi »

BarryG wrote: Fri Jul 26, 2024 11:35 am Oh, I see. Sorry for misunderstanding. :(
Nobody is perfect! :lol: :wink:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
BarryG
Addict
Addict
Posts: 4168
Joined: Thu Apr 18, 2019 8:17 am

Re: Window and gadgets building and SystemMetrics constants

Post by BarryG »

boddhi wrote: Fri Jul 26, 2024 11:19 pm[need to] know precisely (to the pixel) for example scrollbars widths and heights to correctly size listicons and others gadgets using them to fit perfectly in windows
I do this by using GetSystemMetrics_() on my windows, and so my listicons are pixel-perfect for every window. Sometimes you might need to check if a border is present and so on, but it's not too hard. Got an example snippet that shows how you want to perfectly align everything?

BTW, I've been using these in the startup code of my apps without any issues since forever:

Code: Select all

; Border sizes (for ImageGadgets, etc).
Global borderx=GetSystemMetrics_(#SM_CXDLGFRAME)
Global bordery=GetSystemMetrics_(#SM_CYDLGFRAME)

; Scrollbar width and height of ListIconGadgets.
Global scrollwidth=GetSystemMetrics_(#SM_CXVSCROLL)+GetSystemMetrics_(#SM_CXDRAG)
Global scrollheight=GetSystemMetrics_(#SM_CXHSCROLL)+GetSystemMetrics_(#SM_CYDRAG)
boddhi
Enthusiast
Enthusiast
Posts: 524
Joined: Mon Nov 15, 2010 9:53 pm

Re: Window and gadgets building and SystemMetrics constants

Post by boddhi »

BarryG wrote: BTW, I've been using these in the startup code of my apps without any issues since forever:
Thanks for the tip :wink:
If my English syntax and lexicon are incorrect, please bear with Google translate and DeepL. They rarely agree with each other!
Except on this sentence...
Post Reply