Page 1 of 1

GetScreenWidth and Height Thru Win32Api

Posted: Thu Jun 27, 2013 1:34 pm
by cvirus
Enjoy :)

[code]
Declare SystemScreen as "GetSystemMetrics" of "user32"
? ? nIndex As Long
? ? result As Long
end declare

object myform as form
? ? BorderIcons=BiSystemmenu
? ? width=200
? ? height=150
? ? caption="Screen Resolution"
Object lbl as Label
? ?caption="X:"
? ? left=15
? ? top=12
end object
Object lbl1 as Label
? ? caption="Y:"
? ? left=15
? ? top=52
end object
Object txt1 as edit
? ? left=30
? ? top=50
end object
Object txt2 as edit
? ? left=30
? ? top=10
end object
Object btn as Button
? ? width=100
? ? caption="Get Resolution"
? ? top=80
? ? left=35
? ? onclick=GetScreenHeight
end object

end object

Const SM_CXSCREEN = 0 `X Size of screen
Const SM_CYSCREEN = 1 `Y Size of Screen

dim xscreen as integer
dim yscreen as integer

myform.showmodal

sub GetScreenWidth()
SystemScreen.nIndex=SM_CXSCREEN
SystemScreen.execute
xscreen=SystemScreen.result
txt2.text= str$(xscreen)
GetScreenHeight()
end sub

sub GetScreenHeight()
SystemScreen.nIndex=sm_cyscreen
SystemScreen.execute
yscreen=SystemScreen.result
txt1.text=str$(yscreen)
end sub
[/code]

GetScreenWidth and Height Thru Win32Api

Posted: Fri Jun 28, 2013 5:05 pm
by Bob Hays
Your program would work better of you were to call GetScreenWidth with the button.
You have the button calling the GetScreenHeight which doesn`t call GetScreenWidth.  ;)

What inputs would you need to get screen resolutions for multiple screens (monitors)?

GetScreenWidth and Height Thru Win32Api

Posted: Fri Jun 28, 2013 9:25 pm
by cvirus
Done :), typo sorry for that. Will look at that.


[quote author=7C69766D6A6C1F0 link=1372340062/0#0 date=1372340062]

[code]
Declare SystemScreen as "GetSystemMetrics" of "user32"
? ? nIndex As Long
? ? result As Long
end declare

object myform as form
? ? BorderIcons=BiSystemmenu
? ? width=200
? ? height=150
? ? caption="Screen Resolution"
Object lbl as Label
? ?caption="X:"
? ? left=15
? ? top=12
end object
Object lbl1 as Label
? ? caption="Y:"
? ? left=15
? ? top=52
end object
Object txt1 as edit
? ? left=30
? ? top=50
end object
Object txt2 as edit
? ? left=30
? ? top=10
end object
Object btn as Button
? ? width=100
? ? caption="Get Resolution"
? ? top=80
? ? left=35
? ? onclick=GetScreenWidth
end object

end object

Const SM_CXSCREEN = 0 `X Size of screen
Const SM_CYSCREEN = 1 `Y Size of Screen

dim xscreen as integer
dim yscreen as integer

myform.showmodal

sub GetScreenWidth()
SystemScreen.nIndex=SM_CXSCREEN
SystemScreen.execute
xscreen=SystemScreen.result
txt2.text= str$(xscreen)
GetScreenHeight()
end sub

sub GetScreenHeight()
SystemScreen.nIndex=sm_cyscreen
SystemScreen.execute
yscreen=SystemScreen.result
txt1.text=str$(yscreen)
end sub
[/code][/quote]