944,156 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Nov 7th, 2007
0

How to detect Screen Resolution in VB6 ?

Expand Post »
Is there any way or API to detect the Screen Resolution in VB 6.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dilip_singh3 is offline Offline
24 posts
since Oct 2007
Nov 7th, 2007
0

Re: How to detect Screen Resolution in VB6 ?

What do you exactly mean?
Reputation Points: 28
Solved Threads: 71
Posting Pro
ryan_vietnow is offline Offline
578 posts
since Aug 2007
Nov 7th, 2007
0

Re: How to detect Screen Resolution in VB6 ?

check out this sample program.
don't forget to give your geedback.
Attached Files
File Type: zip Res.zip (3.0 KB, 1732 views)
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007
Nov 7th, 2007
0

Re: How to detect Screen Resolution in VB6 ?

Hi,

You dont need an API to know the Resolution.., Use Screen Object of VB:

vb Syntax (Toggle Plain Text)
  1. msgbox "Width = " & Screen.Width/15 _
  2. & vbcrlf _
  3. & " Height = " & Screen.Height/15

Regards
Veena
Last edited by QVeen72; Nov 7th, 2007 at 5:55 am.
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Nov 29th, 2007
0

Re: How to detect Screen Resolution in VB6 ?

Instead of using the constant 15 isn't it safer to use screen.twipsperPixelX and Screen.TwipsPerPixelY ?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
BC_Programming is offline Offline
8 posts
since Nov 2007
Dec 1st, 2007
0

Re: How to detect Screen Resolution in VB6 ?

Yes, use twipsperpixel... I recently found this changed on wide-screen flat panels, and if you don't adjust for it, some elements on your forms will look crappy.
Reputation Points: 40
Solved Threads: 24
Junior Poster
SCBWV is offline Offline
125 posts
since Apr 2007
Feb 4th, 2008
0

Re: How to detect Screen Resolution in VB6 ?

I have the same issue. What I want to detect is the actual operating system under the control panel and detect that windows settings so that I can tell the user change the resolution. The screen method does not seem to work well. i have tested my code where I changed the resolution to a lower resolution, and someone made the comment the program looks crappy!

I agree. There's got to be a way to detect under start->Control Panel->Display->Settings-> screen Resolution Slide bar.

The specific question is how to fetch that resolution and evaluate it in your code? The dumb way would be to have a dialog box and tell the user to change it, but more elegant would be a way to detect it.

Does anyone know how to do this? There's got to be an API to acces that in the OS.

Regards,
Rj
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rjrodrig is offline Offline
3 posts
since Feb 2008
Feb 4th, 2008
0

Re: How to detect Screen Resolution in VB6 ?

Yes, the SysInfo control has an event called DisplayChanged which fires when the screen resolution has been changed. It has many others, including one for SysColorsChanged, several for battery status, power changes and device arrival/removal.
Reputation Points: 40
Solved Threads: 24
Junior Poster
SCBWV is offline Offline
125 posts
since Apr 2007
Feb 4th, 2008
1

Re: How to detect Screen Resolution in VB6 ?

The answer to everyone's request is here. I knew there was an API out there to do so. this website has it http://cuinl.tripod.com/Tips/get_scr...olutionAPI.htm


1. Download the API-GUIDE. Neat utility for all windows API and sample code. google it
http://www.devhood.com/Tools/tool_de...px?tool_id=563


Make a module and dump this code

Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1

Make a form and dump it on the Form_Load() procedure.

Private Sub Form_Load()
Dim Tmp As String
Tmp = GetSystemMetrics(SM_CXSCREEN) & _
"x" & GetSystemMetrics(SM_CYSCREEN)
MsgBox (Tmp)
End Sub

You will see that you can get the information you need.

RJ
Last edited by rjrodrig; Feb 4th, 2008 at 11:11 pm. Reason: quoting web
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rjrodrig is offline Offline
3 posts
since Feb 2008
May 7th, 2009
-1

Re: How to detect Screen Resolution in VB6 ?

yes I believe i ve tried using the code already ====
====
all you really need is to discover controls in Visual Basic..

heres the code ive used:
i used it in the module so that i could easily call it:

Public Function ScreenResolution(f As Form) As String

Dim iWidth As Integer, iHeight As Integer

iWidth = Screen.Width \ Screen.TwipsPerPixelX
iHeight = Screen.Height \ Screen.TwipsPerPixelY
ScreenRes = iWidth & " X " & iHeight

End Function


gr3en39@gmail.com
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gr3en39 is offline Offline
2 posts
since May 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Simple Calculation with data in datagridview
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Creating ICON in vb6





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC