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 / C++ / MFC
  4. activex - save graphics to file

activex - save graphics to file

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsc++winformscomquestion
4 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.
  • S Offline
    S Offline
    sstoyan
    wrote on last edited by
    #1

    hi - i have an mfc activex control and want to save its visuals to a file. how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC? thanx so far i have this: CDC* pdc = GetDC(); RECT rect; GetClientRect(&rect); Graphics graphics(pdc->GetSafeHdc()); Bitmap bitmap(rect.right - rect.left, rect.bottom - rect.top, &graphics); CLSID pngClsid; GetEncoderClsid(L"image/jpeg", &pngClsid); bitmap.Save(fineName, &pngClsid, NULL); but it just outputs a black screen, which is understandable

    R S 2 Replies Last reply
    0
    • S sstoyan

      hi - i have an mfc activex control and want to save its visuals to a file. how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC? thanx so far i have this: CDC* pdc = GetDC(); RECT rect; GetClientRect(&rect); Graphics graphics(pdc->GetSafeHdc()); Bitmap bitmap(rect.right - rect.left, rect.bottom - rect.top, &graphics); CLSID pngClsid; GetEncoderClsid(L"image/jpeg", &pngClsid); bitmap.Save(fineName, &pngClsid, NULL); but it just outputs a black screen, which is understandable

      R Offline
      R Offline
      Roger Allen
      wrote on last edited by
      #2

      You should be able to use the WM_PRINT message to render the control into a DC of your own choice. With a bitmap of your own sleected into it of the correct size, you could then save the output to a file. If you vote me down, my score will only get lower

      S 1 Reply Last reply
      0
      • S sstoyan

        hi - i have an mfc activex control and want to save its visuals to a file. how should i do this? the graphics on the control are created through GDI+, so should i go through Graphics contents to an Image, or may be through CDC? thanx so far i have this: CDC* pdc = GetDC(); RECT rect; GetClientRect(&rect); Graphics graphics(pdc->GetSafeHdc()); Bitmap bitmap(rect.right - rect.left, rect.bottom - rect.top, &graphics); CLSID pngClsid; GetEncoderClsid(L"image/jpeg", &pngClsid); bitmap.Save(fineName, &pngClsid, NULL); but it just outputs a black screen, which is understandable

        S Offline
        S Offline
        sstoyan
        wrote on last edited by
        #3

        my search led me to GdipCreateBitmapFromGraphics method and this post: http://www.pscode.com/vb/scripts/ShowCode.asp?txtCodeId=37541&lngWId=1 where this guy - "Avery" - gives a great hint

        1 Reply Last reply
        0
        • R Roger Allen

          You should be able to use the WM_PRINT message to render the control into a DC of your own choice. With a bitmap of your own sleected into it of the correct size, you could then save the output to a file. If you vote me down, my score will only get lower

          S Offline
          S Offline
          sstoyan
          wrote on last edited by
          #4

          thanx, Roger, i didn't notice anybody replied to the post. i found a solution, check my previous post. i guess your idea is close to what i finally implemented - thanx !

          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