| View previous topic :: View next topic |
| Have you tried the code. |
| Yes i have. |
|
0% |
[ 0 ] |
| No i haven't. |
|
100% |
[ 2 ] |
|
| Total Votes : 2 |
|
| Author |
Message |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Wed Jan 23, 2008 1:31 pm Post subject: detecting screen resolution in vb 6 |
|
|
This will detect your current screen resolution and might come handy if you for instance wanna be able to size any of ur controls.
Here is how to save it onto variables.
| Code: | dim intWidth as integer
dim intHeight as integer
intWidth = Screen.Width / 15
intHeight = Screen.Height / 15 |
Here is how show the resolution on a textbox named text1
| Code: | | text1 = "Screen resolution : " & Screen.Width / 15 & "*" & Screen.Height / 15 |
Last edited by NINTENDO on Thu Jan 24, 2008 9:29 am; edited 1 time in total |
|
| Back to top |
|
 |
Trow Grandmaster Cheater
Reputation: 2
Joined: 17 Aug 2006 Posts: 957
|
Posted: Thu Jan 24, 2008 8:54 am Post subject: |
|
|
failed to detect my resolution (2048*768)
_________________
Get kidnapped often. |
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Thu Jan 24, 2008 8:58 am Post subject: |
|
|
| blland wrote: | | failed to detect my resolution (2048*768) |
Well i tested in with that resolution and gues what? It worked fine.
So just try it again
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Jan 24, 2008 9:18 am Post subject: |
|
|
I bet screen width / 15 is the correct width...
Its like saying aHundred = 100 / 15.
|
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Thu Jan 24, 2008 9:21 am Post subject: |
|
|
| Symbol wrote: | I bet screen width / 15 is the correct width...
Its like saying aHundred = 100 / 15. |
/15 is correct. Did u even try the code before posting?
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
Trow Grandmaster Cheater
Reputation: 2
Joined: 17 Aug 2006 Posts: 957
|
Posted: Thu Jan 24, 2008 9:59 am Post subject: |
|
|
i mean i have two screens. "screen" only detects the first one, which is 1024*768.
_________________
Get kidnapped often. |
|
| Back to top |
|
 |
AtheistCrusader Grandmaster Cheater
Reputation: 6
Joined: 23 Sep 2006 Posts: 681
|
Posted: Thu Jan 24, 2008 10:03 am Post subject: |
|
|
| It does work.
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Thu Jan 24, 2008 10:03 am Post subject: |
|
|
No thanks, I used my brain.
If it is correct then vb is so lame, its getting the screen width * 15?
|
|
| Back to top |
|
 |
Trow Grandmaster Cheater
Reputation: 2
Joined: 17 Aug 2006 Posts: 957
|
Posted: Thu Jan 24, 2008 10:06 am Post subject: |
|
|
vb default unit is "twips" (pixels / twipsperpixel) and default "twipsperpixel" is 15 so yeah
that shit's gone now in .net
_________________
Get kidnapped often. |
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
Posted: Thu Jan 24, 2008 10:30 am Post subject: |
|
|
| blland wrote: | | that shit's gone now in .net |
WTF...
Then this was sooo waste of time.
FUCK YOU MICROSOFT!!
_________________
Intel over amd yes. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Thu Jan 24, 2008 7:35 pm Post subject: |
|
|
| Code: | Dim dwWinWidth As Long
Dim dwWinHeight As Long
dwWinWidth = (Screen.Width / Screen.TwipsPerPixelX)
dwWinHeight = (Screen.Height / Screen.TwipsPerPixelY) |
In VB6 coords (x,y) are stored and such in Twips where as in .NET versions of VB, they are stored in pixels. But, the TwipsPerPixelX/Y functions are still in .NET for conversion functions that anyone might need to use.
They can be located in the Support namespace.
Support.TwipsPerPixelX()
Support.TwipsPerPixelY()
They are Single returns (floats) in .NET though unlike VB6 they were Longs.
You can also look at the Microsoft.VisualBasic.Compatibility.VB6 namespace for more VB6 to .NET conversions and such.
More info here:
http://msdn2.microsoft.com/en-us/library/microsoft.visualbasic.compatibility.vb6.support.twipsperpixelx.aspx
_________________
- Retired. |
|
| Back to top |
|
 |
NINTENDO Grandmaster Cheater Supreme
Reputation: 0
Joined: 02 Nov 2007 Posts: 1371
|
|
| Back to top |
|
 |
|