CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Change which monitor is primary

  1. #1
    Join Date
    Aug 2004
    Posts
    132

    Change which monitor is primary

    Is there some way I can change my secondary monitor to primary using VB code?

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Change which monitor is primary


  3. #3
    Join Date
    Aug 2004
    Posts
    132

    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.

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,268

    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
    [SIGPIC][/SIGPIC]
    All my Articles
    Hannes

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)