How can I get the height of a statusbar?

Windows specific forum
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

How can I get the height of a statusbar?

Post by Trond »

How can I get the height of a statusbar? (I can't get my editorgadget to resize properly.)
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

I use this..

Code: Select all

    ;Statusbar
    hStatus = CreateStatusBar(#IdStatus, WindowID())
    If hStatus
      ;Get the statusbar height
      SendMessage_(hStatus, #SB_GETRECT, 0, @Value.RECT)
      SbHeight = Value\bottom - Value\top + 1
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

or

Code: Select all

GetWindowRect_(statusbar_h,@rect)
ProcedureReturn (rect\bottom-rect\top)
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

@blueznl, I'm not shure, but

Code: Select all

rect\bottom - rect\top
will be one pixel too small, or am I wrong ?
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

good one, could be :-)

i'm not on a machine where i can check it, unfortunately
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

Thanks, I've got it working. It does not seem like it returns one too little pixels.
User avatar
utopiomania
Addict
Addict
Posts: 1655
Joined: Tue May 10, 2005 10:00 pm
Location: Norway

Post by utopiomania »

Seems these two methods are not returning the same rectangle coordinates.

SB_GETRECT with SendMessage() retrieves the bounding rectangle of a part in a status window.

GetWindowRect_() retrieves the dimensions of the bounding rectangle of the specified window.

All according to Microsoft, but using GetRect_() and rect\bottom-rect\top returns one pixel
too many (23,20 pixels), contrary to what I expected.

Using SB_GETRECT and Value\bottom - Value\top + 1 returns the correct height (22,19) judged
from a few screendumps both with and without XP skins enabled.
Post Reply