Size Of Control?

Windows specific questions.
Post Reply
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Size Of Control?

Post by albert »

How do you get the size of a control?? Window or Static?

I need width and height of control...
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Size Of Control?

Post by jj2007 »

Under Windows, it's either GetWindowRect or GetClientRect, depending on your needs.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: Size Of Control?

Post by dodicat »

Using the rectangle

Code: Select all



#include "windows.bi"

dim as msg message
var main= CreateWindowEx( 0, "#32770", "stretch me", WS_OVERLAPPEDWINDOW Or WS_VISIBLE , 100, 0, 800, 600, 0, 0, 0, 0 )
var box=CreateWindowEx( 0, "static", "" , WS_Border or WS_VISIBLE Or WS_CHILD , 10 , 10 , 100 , 100 , main, 0, 0, 0 )

While GetMessage( @message, null, 0, 0 )
   
    TranslateMessage( @message )
    DispatchMessage( @message )
    
    Select Case message.hwnd
    Case main
            Select Case message.message
            Case 273 : end
        case else
                Dim As rect r
                getwindowrect(Main,@r)
                var wide=r.right-r.left
                var high=r.bottom-r.top
                var s="Main size ="+chr(13,10)+ str(wide)+" by "+str(high)+chr(13,10,13,10,13,10)
                'do the label
                getwindowrect(box,@r)
                wide=r.right-r.left
                high=r.bottom-r.top
                s+="box size ="+chr(13,10)+ str(wide)+" by "+str(high)+chr(13,10)
                setwindowtext(box,s)
            End Select
    End Select
Wend  
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Size Of Control?

Post by albert »

@Dodicat

Thanks for the code and info....
jj2007
Posts: 2326
Joined: Oct 23, 2016 15:28
Location: Roma, Italia
Contact:

Re: Size Of Control?

Post by jj2007 »

You are welcome, Albert.
albert
Posts: 6000
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Size Of Control?

Post by albert »

Thanks jj2007!
Post Reply