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. C#
  4. Drawing on second monitor using Graphics

Drawing on second monitor using Graphics

Scheduled Pinned Locked Moved C#
graphicscsharphelpquestion
3 Posts 2 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.
  • J Offline
    J Offline
    jjansen
    wrote on last edited by
    #1

    Using the Screen class I can retrieve the DeviceName of my second monitor, which I can feed into CreateDC to get a device context (DC) of that particular monitor. With it I am able to use all kinds of GDI drawing functions, which do show on my second monitor. Although that works, I would rather draw with a C# Graphics object. The problem is that when I make a Graphics object (with Graphics.FromHdc), I get one with the property VisibleClipBounds set to the bounds of the PRIMARY monitor, and this property is read-only! Does anyone know how I could get the VisibleClipBounds to correspond to the bounds of the right monitor (or all monitors)? Thanks.

    C 1 Reply Last reply
    0
    • J jjansen

      Using the Screen class I can retrieve the DeviceName of my second monitor, which I can feed into CreateDC to get a device context (DC) of that particular monitor. With it I am able to use all kinds of GDI drawing functions, which do show on my second monitor. Although that works, I would rather draw with a C# Graphics object. The problem is that when I make a Graphics object (with Graphics.FromHdc), I get one with the property VisibleClipBounds set to the bounds of the PRIMARY monitor, and this property is read-only! Does anyone know how I could get the VisibleClipBounds to correspond to the bounds of the right monitor (or all monitors)? Thanks.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      The Screen class allows you to get the dimensions of the second monitor. You can then create a screen and put it onto the second monitor by giving it those bounds. I'm not sure how you'd go about getting the DC to draw directing to the desktop, however, am I right in thinking that's what you want ?

      Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      J 1 Reply Last reply
      0
      • C Christian Graus

        The Screen class allows you to get the dimensions of the second monitor. You can then create a screen and put it onto the second monitor by giving it those bounds. I'm not sure how you'd go about getting the DC to draw directing to the desktop, however, am I right in thinking that's what you want ?

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        J Offline
        J Offline
        jjansen
        wrote on last edited by
        #3

        Christian Graus wrote:

        I'm not sure how you'd go about getting the DC to draw directing to the desktop, however, am I right in thinking that's what you want ?

        Actually, I don't want to draw on the desktop but on top of my own application across several separate controls, basically to display a box around an area to draw attention to it. I tried walking through the nested controls on my form, but you can only draw in their client areas, which in some cases doe not cover the entire control (e.g. Edit boxes and list boxes with borderstyle "Fixed3D"). Hence I felt forced to revert to old GDI.

        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