Home All Groups Group Topic Archive Search About

get users screen resolution

Author
21 Sep 2005 3:47 PM
Bruce L
I want to programatically get the user's screen resolution so that I can
bring up a different screen depending on whether they are set at 800x600 or
1024x768.
Thanks for any help.
--
Bruce L

Author
21 Sep 2005 3:54 PM
Jeff Johnson [MVP: VB]
"Bruce L" <Bru***@discussions.microsoft.com> wrote in message
news:4252117C-EB1E-413A-B110-5E7F07F4A44F@microsoft.com...

>I want to programatically get the user's screen resolution so that I can
> bring up a different screen depending on whether they are set at 800x600
> or
> 1024x768.

Screen.Width / Screen.TwipsPerPixelX

I leave it to you to figure out the height.
Author
21 Sep 2005 3:58 PM
Steve Barnett
MsgBox Screen.Width / Screen.TwipsPerPixelX & " - " & Screen.Height /
Screen.TwipsPerPixelY

Steve

Show quoteHide quote
"Bruce L" <Bru***@discussions.microsoft.com> wrote in message
news:4252117C-EB1E-413A-B110-5E7F07F4A44F@microsoft.com...
>I want to programatically get the user's screen resolution so that I can
> bring up a different screen depending on whether they are set at 800x600
> or
> 1024x768.
> Thanks for any help.
> --
> Bruce L
Author
22 Sep 2005 10:17 AM
Dave
"Steve Barnett" <non***@nodomain.com> wrote in message
news:%23AV8WVsvFHA.3080@tk2msftngp13.phx.gbl...
>
>   MsgBox Screen.Width / Screen.TwipsPerPixelX & " - " & Screen.Height /
> Screen.TwipsPerPixelY
>
What is that supposed to do?
Author
22 Sep 2005 10:24 AM
Nospam
"Dave" <Nob***@Nowhere.Com> wrote in message
news:ukRdL71vFHA.3588@tk2msftngp13.phx.gbl...
>
> "Steve Barnett" <non***@nodomain.com> wrote in message
> news:%23AV8WVsvFHA.3080@tk2msftngp13.phx.gbl...
> >
> >   MsgBox Screen.Width / Screen.TwipsPerPixelX & " - " & Screen.Height /
> > Screen.TwipsPerPixelY
> >
> What is that supposed to do?
>
>

What the original person asked for, return the screen resolution.!!
Author
22 Sep 2005 12:50 PM
Dave
Show quote Hide quote
"Nospam" <nospam@please.co.uk> wrote in message
news:up8GJ$1vFHA.1716@TK2MSFTNGP10.phx.gbl...
>
> "Dave" <Nob***@Nowhere.Com> wrote in message
> news:ukRdL71vFHA.3588@tk2msftngp13.phx.gbl...
>>
>> "Steve Barnett" <non***@nodomain.com> wrote in message
>> news:%23AV8WVsvFHA.3080@tk2msftngp13.phx.gbl...
>> >
>> >   MsgBox Screen.Width / Screen.TwipsPerPixelX & " - " & Screen.Height /
>> > Screen.TwipsPerPixelY
>> >
>> What is that supposed to do?
>>
>>
>
> What the original person asked for, return the screen resolution.!!
>

Well sort of, he wanted code not a message box and it has the cardinal sin
of mixing types, the numbers should really be enclosed with a CStr() or
Str() to explicitly convert them into strings. Sure it almost always works
like that but every now and then it will fail and will be tricky to track
down, far better to develop good habits now so if you learn another less
forgiving language you already have the discipline.



Regards

Dave O.
Author
22 Sep 2005 1:03 PM
Nospam
Show quote Hide quote
"Dave" <Nob***@Nowhere.Com> wrote in message
news:egYU0Q3vFHA.916@TK2MSFTNGP10.phx.gbl...
>
> "Nospam" <nospam@please.co.uk> wrote in message
> news:up8GJ$1vFHA.1716@TK2MSFTNGP10.phx.gbl...
> >
> > "Dave" <Nob***@Nowhere.Com> wrote in message
> > news:ukRdL71vFHA.3588@tk2msftngp13.phx.gbl...
> >>
> >> "Steve Barnett" <non***@nodomain.com> wrote in message
> >> news:%23AV8WVsvFHA.3080@tk2msftngp13.phx.gbl...
> >> >
> >> >   MsgBox Screen.Width / Screen.TwipsPerPixelX & " - " & Screen.Height
/
> >> > Screen.TwipsPerPixelY
> >> >
> >> What is that supposed to do?
> >>
> >>
> >
> > What the original person asked for, return the screen resolution.!!
> >
>
> Well sort of, he wanted code not a message box and it has the cardinal sin
> of mixing types, the numbers should really be enclosed with a CStr() or
> Str() to explicitly convert them into strings. Sure it almost always works
> like that but every now and then it will fail and will be tricky to track
> down, far better to develop good habits now so if you learn another less
> forgiving language you already have the discipline.
>
>
>
> Regards
>
> Dave O.
>

You asked "What is that supposed to do?" and I answered.
You did not say that there were bad practices in the example. I agree that
the example was poor (it was not provided by me!), but it give the required
info in an easy to test (and read) form. It would be up to the person using
the example to convert the code into a form suitable for his application.

John..
Author
22 Sep 2005 2:02 PM
Steve Barnett
It shows the poster the resolution of the monitor. Had the poster asked for
a complete application, I probably would not have bothered to post. What I
did do, however, was offer enough information to be able to solve the
posters problem, without coding all of the work for them.

I guess you have nothing better to do with your time. I do.

Steve

Show quoteHide quote
"Dave" <Nob***@Nowhere.Com> wrote in message
news:ukRdL71vFHA.3588@tk2msftngp13.phx.gbl...
>
> "Steve Barnett" <non***@nodomain.com> wrote in message
> news:%23AV8WVsvFHA.3080@tk2msftngp13.phx.gbl...
>>
>>   MsgBox Screen.Width / Screen.TwipsPerPixelX & " - " & Screen.Height /
>> Screen.TwipsPerPixelY
>>
> What is that supposed to do?
>
Author
22 Sep 2005 5:58 PM
Mike Williams
"Steve Barnett" <non***@nodomain.com> wrote in message
news:OKMy643vFHA.460@TK2MSFTNGP15.phx.gbl...

> It shows the poster the resolution of the monitor. Had the poster
> asked for a complete application, I probably would not have
> bothered to post.

Hey Steve, take no notice of Dave. He probably just got out of the wrong
side of the bed this morning! I'm sure that the OP appreciated your
response, and was very thankful that you took the time out to answer him.

Mike
Author
23 Sep 2005 7:48 AM
Steve Barnett
My fault - I shouldn't rise to the bait.

Caught me at a bad time - I'd just got back from a meeting with a client -
four and a half hour round trip in the car for a 20 minute meeting where I
was asked (by a man who hadn't read any of the documentation I sent him)
whether there would be any problems installing a new version of our
software. This was not helped by the torn ligament in my shoulder - just
what you want with four and a half hours behind the wheel.

Steve


Show quoteHide quote
"Mike Williams" <M***@WhiskyAndCoke.com> wrote in message
news:dgurmv$re5$1@news8.svr.pol.co.uk...
> "Steve Barnett" <non***@nodomain.com> wrote in message
> news:OKMy643vFHA.460@TK2MSFTNGP15.phx.gbl...
>
>> It shows the poster the resolution of the monitor. Had the poster
>> asked for a complete application, I probably would not have
>> bothered to post.
>
> Hey Steve, take no notice of Dave. He probably just got out of the wrong
> side of the bed this morning! I'm sure that the OP appreciated your
> response, and was very thankful that you took the time out to answer him.
>
> Mike
>
>
>
>
>
Author
21 Sep 2005 4:17 PM
Mike D Sutton
> I want to programatically get the user's screen resolution so that I can
> bring up a different screen depending on whether they are set at 800x600 or
> 1024x768.

Multiple monitors are becoming more popular these days, so what happens if the user has one 1024*768 and one 800*600 display
attached to their machine?  The VB Screen object returns information on the primary monitor but not necessarily the largest, if you
need to know that then grab the multi-monitor library off my page which will expose all this additional information for you (and
also works on single-monitor setups.)
Hope this helps,

    Mike


- Microsoft Visual Basic MVP -
E-Mail: ED***@mvps.org
WWW: Http://EDais.mvps.org/