Is there any way or API to detect the Screen Resolution in VB 6.
What do you exactly mean?
check out this sample program.
don't forget to give your geedback.
You dont need an API to know the Resolution.., Use Screen Object of VB:
msgbox "Width = " & Screen.Width/15 _ & vbcrlf _ & " Height = " & Screen.Height/15
Instead of using the constant 15 isn't it safer to use screen.twipsperPixelX and Screen.TwipsPerPixelY ?
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.
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.
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.
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_screen_resolutionAPI.htm
1. Download the API-GUIDE. Neat utility for all windows API and sample code. google it
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)
You will see that you can get the information you need.
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
We're both NEWBIES here and as far as VB6 and being a newbie are concerned, I suggest you better opt for simple coding and explanations. You see, advanced coding might give you migraines or ulcers...
Try the suggestions offered to you here (specifically on using the Screen.TwipsPerPixelX and Screen.TwipsPerPixelY techniques, which in my experience, are very simple to integrate and debug).
Now, if you want your program to detect changes in the screen resolution DURING RUN TIME, I suggest you do the coding WITHIN a timer subroutine. This means your program must stay memory-resident and check the screen resolution from time to time, say, every second. As your app checks the resolution, the values should be stored on two variables (say CurrentRes and NewRes, both being arrays to store the values of the screen resolution's height and width). Everytime CurrentRes and NewRes are detected as unequal, you can then trap the inequality and launch an appropriate routine to inform the user.
I can't give you here a thorough coding of this suggestion. Sorry, but you have to discover it by yourself through perseverance and diligence -- just the way I helped myself learn the simple nuances of VB6.
Good luck, Buddy...
What I am doing currently is designing two forms to open to the left of center under the assumption that user has high screen resolution, but putting a button on right-side form. If the resolution is low, user can't see left form. But, if user clicks button on right-form, both forms become centered. This works. I would, however, like to detect what the screen resolution is, so I will know to programatically to set forms in center when necessary.
If you read through all the other posts (FROM 2007!) you will see that there are multiple ways of getting the screen resolution.
Hey, so I wanna ask how I need to create a method who will remove word if in that word is 2 same chars. Example: "Potato" in this word there is a 2 "o" chars so this word will need to be removed. "Forum" in this word there is no ...
Hi I'm having a problem implementing a mini shopping cart drop down in the header to show the user all the products they have in their shopping cart. It seems the only solution for this is Ajax, and I've looked all over and can't find anything that I could possibly ...
Hi. Im using vb 2010. I want to dynamically add textboxes to my form by clicking on a button. I've google searched and so far this code worked:
Private Sub btn_addline_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_addline.Click Dim txtB1 As New TextBox Dim i For i = ...