Jump to content
  • Advertisement
Sign in to follow this  
Tape_Worm

[C#] GDI+, Drawing on the desktop and Multiple Monitors.

This topic is 4860 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I have an app that I'm designing here. Basically one of its features is that it can snap the window to the corners of each monitor. To supplement this feature, the application draws nice translucent blue rectangles in each corner of the monitor to show the snap guides. This works great for my single monitor system, however when it runs on a multiple monitor system the snapping works just fine, however the blue rectangles do not appear. I'm using GDI+ (no, I have no option to use DX or OpenGL) to draw these images to the desktop via DrawImage and creating the graphics interface objects via the device contexts to the desktops for each monitor. That is,
desktopHDC[monitor] = CreateDC(IntPtr.Zero, Screen.AllScreens[monitor].DeviceName, IntPtr.Zero, IntPtr.Zero);

Graphics graphicsObject[monitor] = Graphics.FromHDC(desktopHDC[monitor]);


This approach works fine when I read the original desktop corner images for the monitors (so that I can restore the images later) and I have confirmed this by blitting those images to my primary monitor. However, when it comes to drawing the overlay image to the secondary monitor corners nothing appears. I've also confirmed that it is not the result of being outside of the bounds of the secondary monitor. When I blit the image(s) to the monitors I use the DrawImage function:
graphicsObject[monitor].DrawImage(overlay[monitor],MonitorLeft,MonitorTop);


I even went so far as to create the overlay bitmaps using the graphicsObject that is related to the indiviual monitor. So if anyone can help or tell me what I could possibly be doing wrong, I'd appreciate it.

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!