What is Display Resolution?
The number of Pixels displayed in your Monitor is called Screen Resolution.
It is represented as how many Pixels displayed in Screen height x Screen width. To get the screen height and width use these codes as per your programming language. The computer or mobile devices do not have standard screen resolutions.
It varies with every manufacturer and every computer model. So, the developers have to design their application to be compatible with the user’s device resolution limits.
Be it an application developer or a Web developer, everyone have to use any of these codes at some point of time.
Also Read: WhatsApp Dual Login - 2 WhatsApp on 1 Phone
1. What is my Screen Resolution? – VBA using Windows API
The VBA code below retrieves screen resolution parameters using 2 different methods, both using the Win api functions.
VBA to find Screen Resolution of ComputerVisual Basic123456789101112131415161718192021222324252627282930313233Option Explicit'For Method 1Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As LongPrivate Declare Function GetDesktopWindow Lib "user32" () As LongPrivate Type RECTLeft As LongTop As LongRight As LongBottom As LongEnd Type'For Method 2Private Declare Function GetSystemMetrics Lib "user32.dll" (ByVal nIndex As Long) As LongConst SM_CXSCREEN = 0Const SM_CYSCREEN = 1Private Sub VBA_Screen_Resolution()'Method 1Dim rScreen As RECTGetClientRect CLng(GetDesktopWindow()), rScreenThisWorkbook.Sheets(1).Cells(1, 1) = "Left"ThisWorkbook.Sheets(1).Cells(2, 1) = "Right"ThisWorkbook.Sheets(1).Cells(3, 1) = "Top"ThisWorkbook.Sheets(1).Cells(4, 1) = "Bottom"ThisWorkbook.Sheets(1).Cells(1, 2) = rScreen.LeftThisWorkbook.Sheets(1).Cells(2, 2) = rScreen.RightThisWorkbook.Sheets(1).Cells(3, 2) = rScreen.TopThisWorkbook.Sheets(1).Cells(4, 2) = rScreen.Bottom'Method 2MsgBox "Screen Resolution - " & GetSystemMetrics(SM_CXSCREEN) & " x " & GetSystemMetrics(SM_CYSCREEN)End Sub
Note: Function used in method 2 in above example can be used in C Programming to get screen width & height. Include Windows.h and then use the function with same parameters in your C program.
The above can be tested right from your internet browser Firefox, Chrome or IE. To test it in Firefox, press Ctrl + Shift + q, then choose ‘Console’. Type this command ‘console.log (wscr);’ and press enter.
Firefox console will display the screen width.
3. Find Windows Screen Height & Width from Command Prompt
Open command prompt and type this command. Just so simplest of all.Command Prompt to Find Screen ResolutionShell123wmic desktopmonitor get screenheight, screenwidth'Or this command to open the windows screen resolution display settings.rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,3
By now you would be able to answer ‘What is Display resolution’ of your computer using the above free codes. If you require the coding in any specific programming language, please leave us a comment.