How can I get a value from WinAPI

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kaba.

Hi!

To adjust the layout of my windows, I should know the size of the default system font, set by the user.

I found in the winapi the command GetTextMetrics() which allows me to read from the TEXTMETRIC Structure. There I'd like to read the value stored in tmHeight.

How does this work in PureBasic? What do I do wrong?
I've tried: fntheight.l = GetTextMetrics_(hwnd,tmheight.TEXTMETRIC)
but just got strange results, like "4218818"

Can anybody give me a hint? I'm using Win98SE

Thx

Kaba
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> To adjust the layout of my windows, I should know the size of the
> default system font, set by the user.

See here:

viewtopic.php?t=2021


PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.

You have to access the tmHeigt element within the structure TEXTMETRIC. So you do it like this:

Code: Select all

if GetTextMetrics_(UseWindow(yourwindownumber), @metrics.TEXTMETRIC)
  fontheight.l = metrics\tmHeight ; acces the element within structure
endif
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kaba.

GREAT!!!!! 8)

Thank you very much! You really help me a lot!! :)

Kaba
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Kaba.

@pupil: Thanks! I really understand this stuff now! :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fweil.

hello,

As GetTextMetrics_() requires a device context the working syntax should be :

GetTextMetrics_(GetWindowDC_(WindowID()), @metrics.TEXTMETRICS) ...

Not sure to be right but I think so.

Rgrds

Francois Weil
14, rue Douer
F64100 Bayonne
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Originally posted by fweil

hello,

As GetTextMetrics_() requires a device context the working syntax should be :

GetTextMetrics_(GetWindowDC_(WindowID()), @metrics.TEXTMETRICS) ...

Not sure to be right but I think so.
You're right, my bad, i missed that part when browsing the win api.
Post Reply