-
October 11th, 2009, 11:02 PM
#1
Change which monitor is primary
Is there some way I can change my secondary monitor to primary using VB code?
-
October 12th, 2009, 02:22 PM
#2
Re: Change which monitor is primary
-
October 13th, 2009, 12:02 AM
#3
Re: Change which monitor is primary
Hi,
Thanks for the link. I think that only shows me how to get the monitor information. I want to change which monitor is the primary one. Not sure if it would be possible using VB. I'll keep hunting.
-
October 13th, 2009, 06:25 AM
#4
Re: Change which monitor is primary
I don't think you could change which monitor is the Primary monitor - as that is a built in System constant, but you could indeed tell your porgram on which monitor to open.
Have a look at the following APIs :
Code:
Public Declare Function GetMonitorInfo Lib "user32.dll" Alias "GetMonitorInfoA" (ByVal hMonitor As Long, ByRef lpmi As MONITORINFO) As Long
Public Declare Function MonitorFromPoint Lib "user32.dll" (ByVal x As Long, ByVal y As Long, ByVal dwFlags As Long) As Long
Public Declare Function MonitorFromRect Lib "user32.dll" (ByRef lprc As RECT, ByVal dwFlags As Long) As Long
Public Declare Function MonitorFromWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal dwFlags As Long) As Long
Public Declare Function EnumDisplayMonitors Lib "user32.dll" (ByVal hdc As Long, ByRef lprcClip As Any, ByVal lpfnEnum As Long, ByVal dwData As Long) As Long
Public Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Then, these API Sturctures / Types :
Code:
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type MONITORINFO
cbSize As Long
rcMonitor As RECT
rcWork As RECT
dwFlags As Long
End Type
Then, these API constants :
Code:
Public Const MONITORINFOF_PRIMARY = &H1
Public Const MONITOR_DEFAULTTONEAREST = &H2
Public Const MONITOR_DEFAULTTONULL = &H0
Public Const MONITOR_DEFAULTTOPRIMARY = &H1
I hope my advice was helpful
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|