473,624 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

External Window Location - Multi Monitor

I'm writing a plug-in in VB.NET to a an application called
DesktopSidebar for Windows. Right clicking my plug-in's "panel" gives
shows among other things a Properties Dialog. All I need to do is pop
up the dialog in the proper place. 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.Diagnost ics.Process
Dim oProcess As Diagnostics.Pro cess
colProcess = Diagnostics.Pro cess.GetProcess esByName("sideb ar")
If colProcess.Leng th > 0 Then
oProcess = colProcess(0)
Dim handle As System.IntPtr = oProcess.MainWi ndowHandle
Dim loc As RECT
If GetWindowRect(h andle.ToInt32, loc) > 0 Then
'Where are we docked?
If loc.Left = 0 Then
Me.Location = New Drawing.Point(l oc.Right,(loc.B ottom -
loc.Top)/2)
Else
Me.Location = New Drawing.Point(l oc.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. So, essentially I can move my mouse straight UP to the other
monitor. Quite handy as a developer stuck on a laptop. 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 deal with this in
VB.NET?
Nov 20 '05 #1
1 6316
You might want to look at a mangaged class of

system.windows. forms.screen
"Matt" <mp******@yahoo .com> wrote in message
news:66******** *************** ***@posting.goo gle.com...
I'm writing a plug-in in VB.NET to a an application called
DesktopSidebar for Windows. Right clicking my plug-in's "panel" gives
shows among other things a Properties Dialog. All I need to do is pop
up the dialog in the proper place. 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.Diagnost ics.Process
Dim oProcess As Diagnostics.Pro cess
colProcess = Diagnostics.Pro cess.GetProcess esByName("sideb ar")
If colProcess.Leng th > 0 Then
oProcess = colProcess(0)
Dim handle As System.IntPtr = oProcess.MainWi ndowHandle
Dim loc As RECT
If GetWindowRect(h andle.ToInt32, loc) > 0 Then
'Where are we docked?
If loc.Left = 0 Then
Me.Location = New Drawing.Point(l oc.Right,(loc.B ottom -
loc.Top)/2)
Else
Me.Location = New Drawing.Point(l oc.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. So, essentially I can move my mouse straight UP to the other
monitor. Quite handy as a developer stuck on a laptop. 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 deal with this in
VB.NET?

Nov 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2284
by: Bilal | last post by:
Hi, I have a web application that operates on several windows. Each window is named win_1, win_2, win_3,... . When I quit a session, I usually loop through all the windows and close one by one. So far so good until my client wants to surf on 1 particular window and doesn't want that window to close when a I quit a session. I had something in mind: find the window url through "window.location.host" or something (I'd save it as a global...
5
9704
by: Carol Lyn | last post by:
Could use your assistance with this. I have a window that opens via onclick and it is a small window with info about a site. If the user is interested in visiting that site, there is a link to click that opens the site in a new and larger window via onclick. My question is, can I have the smaller window automatically close when the user clicks the link to visit the site? I also have a link that merely closes the smaller info window if...
8
15818
by: Els | last post by:
Hi, i have the following script in the head of my document: <script language="Javascript"> <!-- // *********************************************** // AUTHOR: WWW.CGISCRIPT.NET, LLC // URL: http://www.cgiscript.net // Use the script, just leave this message intact. // Download your FREE CGI/Perl Scripts today! // ( http://www.cgiscript.net/scripts.htm )
2
5356
by: Randell D. | last post by:
HELP! Its taken me ages - I'm a newbie and I've compiled bits of code that I've read in this newsgroup over time to create one of my most intricate functions to date... Basically, the script gets called with a single arguement (full path to an image). The image is supposed to be downloaded to the cache, and when complete, a new window opened that is slightly larger insize then the images dimensions... The new window will contain the...
1
2909
by: sonic_soul | last post by:
Hi, Is there a way to monitor a newly opepend child window with opener, even when the page keeps reloading ? Say window A opens window B and gives it a name/handle "myWindow". At this point anywhere in window A, we could say myWindow.location.href to find out where the child is. But what if someone was to take window A to another site, and than return using history button, OR reload it completely.
3
5626
by: anonieko | last post by:
You can try this code: > > > > > <!--- filename: mypage.html ----> <html> ....blah blah blah <script language=JavaScript src=/Javascript/center.js></script>
10
11595
by: santiago538 | last post by:
Hi, Is there any way to specify which monitor a Window.open() will launch a new browser window in on systems with more than one display. It would only need to work with Mozilla browsers, and not IE. Thanks!
7
4513
by: Bill Nguyen | last post by:
This has been posted before but received no response: I need to arrange window screens on the total area of a mulitple-mopnitor desktop. As an example, below is the bound info for my 2-monitor PC: Device Name: \\.\DISPLAY1 Bounds: {X=1152,Y=0,Width=1152,Height=864} Primary Screen: False
5
3685
by: althafexcel | last post by:
hi everyone Im trying to include an external js in my aspx page under the head tag, it doesn't load or it displays an object expected error whenver the function from the .js is called. Actually for repeated html im using the external js, i mean the TOP, BOTTOM they are repeated in every page, so i include them as functions in the external js and call them. Why it doesn't work?
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8348
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2613
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.