Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Window Location, Multiple Monitor: Sorry for crosspost

Window Location, Multiple Monitor: Sorry for crosspost

Scheduled Pinned Locked Moved Visual Basic
workspacecsharpgraphicshelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Matt Philmon
    wrote on last edited by
    #1

    Sorry for the cross post. I posted it the first time to the wrong forum. I'm writing a plug-in in VB.NET to a an application called DesktopSidebar for Windows. Right clicking my plug-in's "panel" shows among other things a Properties Dialog. All I need to do is pop up the dialog in the proper place and on the same monitor in a multiple monitor environment. My plug-in doesn't appear at this point to have the Window handle of the calling application. After quite a bit of trial and error I came up with this: Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Int32, ByRef lpRect As RECT) As Int32 Public Structure RECT Dim Left As Int32 Dim Top As Int32 Dim Right As Int32 Dim Bottom As Int32 End Structure Dim colProcess() As System.Diagnostics.Process Dim oProcess As Diagnostics.Process colProcess = Diagnostics.Process.GetProcessesByName("sidebar") If colProcess.Length > 0 Then oProcess = colProcess(0) Dim handle As System.IntPtr = oProcess.MainWindowHandle Dim loc As RECT If GetWindowRect(handle.ToInt32, loc) > 0 Then 'Where are we docked? If loc.Left = 0 Then Me.Location = New Drawing.Point(loc.Right,(loc.Bottom - loc.Top)/2) Else Me.Location = New Drawing.Point(loc.Left - Me.Width, (loc.Bottom - loc.Top)/2) End If End If End If This works great as long as you have a single monitor, whether DesktopSideBar is docked to the Left or the Right. However, I run in a multi-monitor environment. In my particular setup my primary display is my laptop and my secondary display actually hovers ABOVE my primary display (it's a 19 inch monitor) and I have my desktop extended onto it. The code above, only targets the primary display, even though I dock DesktopSideBar on my secondary monitor. My screen coordinates are still good... just not on the right monitor. Could anyone offer up some suggestions on how to not only determine the monitor my panel is on, but also how to set the location of my dialog to a specific place on the proper monitor?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups