How to detect Screen Resolution in VB6 ?

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2007
Posts: 24
Reputation: dilip_singh3 is an unknown quantity at this point 
Solved Threads: 0
dilip_singh3 dilip_singh3 is offline Offline
Newbie Poster

How to detect Screen Resolution in VB6 ?

 
0
  #1
Nov 7th, 2007
Is there any way or API to detect the Screen Resolution in VB 6.
Reply With Quote Quick reply to this message  
Join Date: Aug 2007
Posts: 570
Reputation: ryan_vietnow is an unknown quantity at this point 
Solved Threads: 71
ryan_vietnow's Avatar
ryan_vietnow ryan_vietnow is offline Offline
Posting Pro

Re: How to detect Screen Resolution in VB6 ?

 
0
  #2
Nov 7th, 2007
What do you exactly mean?
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 538
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: How to detect Screen Resolution in VB6 ?

 
0
  #3
Nov 7th, 2007
check out this sample program.
don't forget to give your geedback.
Attached Files
File Type: zip Res.zip (3.0 KB, 102 views)
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: How to detect Screen Resolution in VB6 ?

 
0
  #4
Nov 7th, 2007
Hi,

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

  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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 8
Reputation: BC_Programming is an unknown quantity at this point 
Solved Threads: 0
BC_Programming BC_Programming is offline Offline
Newbie Poster

Re: How to detect Screen Resolution in VB6 ?

 
0
  #5
Nov 29th, 2007
Instead of using the constant 15 isn't it safer to use screen.twipsperPixelX and Screen.TwipsPerPixelY ?
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 106
Reputation: SCBWV is an unknown quantity at this point 
Solved Threads: 16
SCBWV SCBWV is offline Offline
Junior Poster

Re: How to detect Screen Resolution in VB6 ?

 
0
  #6
Dec 1st, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 3
Reputation: rjrodrig is an unknown quantity at this point 
Solved Threads: 0
rjrodrig rjrodrig is offline Offline
Newbie Poster

Re: How to detect Screen Resolution in VB6 ?

 
0
  #7
Feb 4th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 106
Reputation: SCBWV is an unknown quantity at this point 
Solved Threads: 16
SCBWV SCBWV is offline Offline
Junior Poster

Re: How to detect Screen Resolution in VB6 ?

 
0
  #8
Feb 4th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 3
Reputation: rjrodrig is an unknown quantity at this point 
Solved Threads: 0
rjrodrig rjrodrig is offline Offline
Newbie Poster

Re: How to detect Screen Resolution in VB6 ?

 
0
  #9
Feb 4th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 2
Reputation: gr3en39 is an unknown quantity at this point 
Solved Threads: 0
gr3en39 gr3en39 is offline Offline
Newbie Poster

Re: How to detect Screen Resolution in VB6 ?

 
0
  #10
May 7th, 2009
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 7302 | Replies: 10
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC