Click here to Skip to main content
15,889,595 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralPrinting Please Help Pin
Pugman81222-Feb-04 16:51
Pugman81222-Feb-04 16:51 
GeneralSet Selected Item Pin
mosquitooth22-Feb-04 8:05
mosquitooth22-Feb-04 8:05 
GeneralRe: Set Selected Item Pin
Nadroj22-Feb-04 10:15
Nadroj22-Feb-04 10:15 
GeneralRe: Set Selected Item Pin
Dave Kreskowiak22-Feb-04 16:13
mveDave Kreskowiak22-Feb-04 16:13 
GeneralTime of Day Launched Project Pin
tjmule2221-Feb-04 15:47
tjmule2221-Feb-04 15:47 
GeneralRe: Time of Day Launched Project Pin
Charlie Williams21-Feb-04 16:40
Charlie Williams21-Feb-04 16:40 
GeneralRe: Time of Day Launched Project Pin
John Kuhn21-Feb-04 17:33
John Kuhn21-Feb-04 17:33 
GeneralWindow Location, Multiple Monitor: Sorry for crosspost Pin
Matt Philmon20-Feb-04 19:48
Matt Philmon20-Feb-04 19:48 
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?
GeneralListbox and XML Pin
Novaoblivion20-Feb-04 14:25
Novaoblivion20-Feb-04 14:25 
Generalrich text output to postscript or... Pin
jjpaquin20-Feb-04 7:52
jjpaquin20-Feb-04 7:52 
GeneralJanus GridEx & Rows Pin
RichardGrimmer20-Feb-04 4:26
RichardGrimmer20-Feb-04 4:26 
GeneralRe: Janus GridEx & Rows Pin
jimpar20-Feb-04 9:12
jimpar20-Feb-04 9:12 
GeneralRe: Janus GridEx & Rows Pin
RichardGrimmer20-Feb-04 12:20
RichardGrimmer20-Feb-04 12:20 
Generalcrystal report Pin
joypreeti20-Feb-04 1:33
joypreeti20-Feb-04 1:33 
Generaloutpur in Excel using vb6 Pin
Anonymous20-Feb-04 0:52
Anonymous20-Feb-04 0:52 
GeneralRe: outpur in Excel using vb6 Pin
John Kuhn20-Feb-04 12:55
John Kuhn20-Feb-04 12:55 
General.NET and Binary compatibility Pin
cnurse19-Feb-04 22:33
cnurse19-Feb-04 22:33 
GeneralFree UML tools Pin
cnurse19-Feb-04 22:26
cnurse19-Feb-04 22:26 
GeneralRe: Free UML tools Pin
Corinna John22-Feb-04 22:13
Corinna John22-Feb-04 22:13 
GeneralRe: Free UML tools Pin
cnurse22-Feb-04 22:26
cnurse22-Feb-04 22:26 
GeneralRe: Free UML tools Pin
Corinna J.23-Feb-04 6:01
sussCorinna J.23-Feb-04 6:01 
GeneralRe: Free UML tools Pin
LuckyNB12-Sep-09 21:48
professionalLuckyNB12-Sep-09 21:48 
QuestionRuntime Error 430?? Pin
erikkloeze19-Feb-04 21:49
erikkloeze19-Feb-04 21:49 
AnswerRe: Runtime Error 430?? Pin
Nadroj20-Feb-04 1:57
Nadroj20-Feb-04 1:57 
GeneralRe: Runtime Error 430?? Pin
erikkloeze20-Feb-04 3:40
erikkloeze20-Feb-04 3:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.