Size Of Control?

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

Size Of Control?

Postby albert » Feb 12, 2019 17:54

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

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

Re: Size Of Control?

Postby jj2007 » Feb 12, 2019 18:30

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

Re: Size Of Control?

Postby dodicat » Feb 12, 2019 19:36

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: 4469
Joined: Sep 28, 2006 2:41
Location: California, USA

Re: Size Of Control?

Postby albert » Feb 12, 2019 21:48

@Dodicat

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

Re: Size Of Control?

Postby jj2007 » Feb 12, 2019 22:01

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

Re: Size Of Control?

Postby albert » Feb 12, 2019 23:08

Thanks jj2007!

Return to “Windows”

Who is online

Users browsing this forum: No registered users and 1 guest