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. .NET (Core and Framework)
  4. Drawing to the screen DC with GDI+

Drawing to the screen DC with GDI+

Scheduled Pinned Locked Moved .NET (Core and Framework)
csharpgraphicshelpc++winforms
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
    Jon Rista
    wrote on last edited by
    #1

    I'm working on writing a custom menubar/toolbar set of classes, to replace the standard windows menu bar in my applications. I would like to have a fully custom-drawn, pure C#/.NET coded paint method to draw the popup menus for the menubar. I've run into the little problem of needing the screen DC to be able to properly draw the popup menu outside the bounds of the menubar control, though. Is there any way to get the screen DC using GDI+, so I could draw to it as if it were a standard windows control? I remember being able to do this long ago before the days of MFC, but I havn't tried since. I havn't had much luck finding any documentation on how in the MSDN help, nor by browsing around the articles here on CP. Any help is greatly appreciated...

    S 1 Reply Last reply
    0
    • J Jon Rista

      I'm working on writing a custom menubar/toolbar set of classes, to replace the standard windows menu bar in my applications. I would like to have a fully custom-drawn, pure C#/.NET coded paint method to draw the popup menus for the menubar. I've run into the little problem of needing the screen DC to be able to properly draw the popup menu outside the bounds of the menubar control, though. Is there any way to get the screen DC using GDI+, so I could draw to it as if it were a standard windows control? I remember being able to do this long ago before the days of MFC, but I havn't tried since. I havn't had much luck finding any documentation on how in the MSDN help, nor by browsing around the articles here on CP. Any help is greatly appreciated...

      S Offline
      S Offline
      Shafqat Ahmed Shiplu
      wrote on last edited by
      #2

      Try calling GetDC using WIN32 interop. Like this: Step 1. int hdc = GetDC (0) // Gets the screen DC Step 2. Get a graphics object from the DC and draw Step 3. Dispose the graphics object and call releaseDC like this ReleaseDC (hdc, 0) Thanks Shafqat Ahmed admin@shiplu.com

      J 1 Reply Last reply
      0
      • S Shafqat Ahmed Shiplu

        Try calling GetDC using WIN32 interop. Like this: Step 1. int hdc = GetDC (0) // Gets the screen DC Step 2. Get a graphics object from the DC and draw Step 3. Dispose the graphics object and call releaseDC like this ReleaseDC (hdc, 0) Thanks Shafqat Ahmed admin@shiplu.com

        J Offline
        J Offline
        Jon Rista
        wrote on last edited by
        #3

        Thanks for the reply. I assume the GetDC() function is in gdi32.dll? I use C#, not C++, so I have to DllImport it to use it.

        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