GetScreenWidth and Height Thru Win32Api

In this category you can exchange your programming questions and solutions.
Post Reply
cvirus
Posts: 88
Joined: Tue Jan 12, 2010 8:33 pm

GetScreenWidth and Height Thru Win32Api

Post: # 1086Post cvirus
Thu Jun 27, 2013 1:34 pm

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]

Bob Hays
Posts: 26
Joined: Sun Oct 03, 2010 4:49 pm

GetScreenWidth and Height Thru Win32Api

Post: # 1087Post Bob Hays
Fri Jun 28, 2013 5:05 pm

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)?

cvirus
Posts: 88
Joined: Tue Jan 12, 2010 8:33 pm

GetScreenWidth and Height Thru Win32Api

Post: # 1088Post cvirus
Fri Jun 28, 2013 9:25 pm

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]

Post Reply