I want to take into account the size of the caption of a Form when calculating the best size of a Form dynamically.
Ideally I would use the GetTextSize function but naturally that won't work. I don't want to use a .NET call, and I don't want to make just assumptions of what the font used by Windows might actually be.
Any ideas?
Size of text in a Form caption
Re: Size of text in a Form caption
Hi Kai
The Windows API function GetSystemMetrics will give you a lot of information that you might find useful.
In this old function (pre 2000) I used it to find the size of the scroll bars but GetSystemMetrics contains a lot more useful stuff.
Hope this might help, or give you ideas.
Ray
The Windows API function GetSystemMetrics will give you a lot of information that you might find useful.
In this old function (pre 2000) I used it to find the size of the scroll bars but GetSystemMetrics contains a lot more useful stuff.
SetPW;old;wid;sw;GET;sb;pw;fn16;cursz;dll;⎕IO;⎕ML
⍝ ---Set ⎕PW according to APL font size and Screen dimensions
⎕IO←1 ⋄ ⎕ML←0 ⍝
old←'⎕se'⎕WG'coord' ⍝ Save current coord system
'⎕se'⎕WS'coord' 'pixel' ⍝ Set Coord system to PIXEL
wid←2⊃'⎕se'⎕WG⊂'Textsize' '⎕' ⍝ Get size of an APL character
cursz←2⊃'⎕se'⎕WG'Size'
'⎕se'⎕WS'coord'old
dll←'user32|GetSystemMetrics'
'fn16'⎕NA'I ',dll,' I'
sw←cursz-fn16 2 ⍝ Screen width, reduce by scroll bar width
pw←30⌈⌊sw÷wid ⍝ calculate width in APL char units
⎕PW←pw ⍝ Set Page Width
Hope this might help, or give you ideas.
Ray
Ray Cannon
Please excuse any smelling pisstakes.
Please excuse any smelling pisstakes.
Re: Size of text in a Form caption
Ray, thanks for that.
I am fully aware of GetSystemMetrics. I can find out everything except ... <drumroll> ... the size of the caption and the font used by the operating system!
I am fully aware of GetSystemMetrics. I can find out everything except ... <drumroll> ... the size of the caption and the font used by the operating system!
Re: Size of text in a Form caption
Hello Kai, are looking at finding the size and name of the font used for example in the 'Active Title Bar' as show below ?:
Re: Size of text in a Form caption
Kai, I don't know if there's an elegant way, but have you tried the registry?
See the entries under:
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
See the entries under:
HKEY_CURRENT_USER\Control Panel\Desktop\WindowMetrics
-
- Posts: 94
- Joined: Sat Nov 28, 2009 3:12 pm
Re: Size of text in a Form caption
Hi,
perhaps I'm on the wrong track, but if you are just looking for the Caption size, the Metrics helps a bit:
(4 represents here SM_CYCAPTION, the height of a caption area, in pixels)
-Veli-Matti
perhaps I'm on the wrong track, but if you are just looking for the Caption size, the Metrics helps a bit:
{∆m←+⋄(⎕EX'∆m')⊢∆m ⍵⊣'∆m'⎕NA'I4 User32|GetSystemMetrics I4'}4
22
(4 represents here SM_CYCAPTION, the height of a caption area, in pixels)
-Veli-Matti
Re: Size of text in a Form caption
Hello Kai, I know you said no .Net but I could not resist:
⎕using←'System.Windows,WPF/PresentationFramework.dll'
SystemFonts.CaptionFontSize
12
SystemFonts.CaptionFontFamily
Segoe UI