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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Screen Capture

Screen Capture

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
9 Posts 3 Posters 1 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.
  • U Offline
    U Offline
    User 6831394
    wrote on last edited by
    #1

    Hi Members How i get Screen capture?I am using dialog based application i want to get Screen capture and save into .dat format. Please help me

    R D 2 Replies Last reply
    0
    • U User 6831394

      Hi Members How i get Screen capture?I am using dialog based application i want to get Screen capture and save into .dat format. Please help me

      R Offline
      R Offline
      Rajesh R Subramanian
      wrote on last edited by
      #2

      See Barry's Screen Capture[^] I used the CodeProject "search" feature to arrive on that result.

      “Follow your bliss.” – Joseph Campbell

      1 Reply Last reply
      0
      • U User 6831394

        Hi Members How i get Screen capture?I am using dialog based application i want to get Screen capture and save into .dat format. Please help me

        D Offline
        D Offline
        David Crow
        wrote on last edited by
        #3

        Member 6864839 wrote:

        How i get Screen capture?

        See here for an idea.

        "One man's wage rise is another man's price increase." - Harold Wilson

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        "Man who follows car will be exhausted." - Confucius

        U 1 Reply Last reply
        0
        • D David Crow

          Member 6864839 wrote:

          How i get Screen capture?

          See here for an idea.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Man who follows car will be exhausted." - Confucius

          U Offline
          U Offline
          User 6831394
          wrote on last edited by
          #4

          thanks both of you for reply.I use this code

          HDC m_hdcMem,hdc;
          HBITMAP m_Bitmap,m_OldBitmap,hMainBmp ;
          //one intersting for you if you want to use of other resulition
          int x=800;
          int y=600;

          //use of GetDC()->m_hDC and see result.
          //hdc=GetDC()->m_hDC;
          hdc=GetDesktopWindow()->GetDC()->m_hDC;

          m_hdcMem= CreateCompatibleDC(hdc);

          //one interesting for you if you want to use of other
          m_Bitmap = CreateCompatibleBitmap(hdc,x,y);
          m_OldBitmap=(HBITMAP) SelectObject(m_hdcMem, m_Bitmap);

          BitBlt(m_hdcMem, 0,0,x,y, hdc,0,0,SRCCOPY);
          hMainBmp =(HBITMAP) SelectObject(m_hdcMem, m_OldBitmap);
          ///////////Now you have a hbitmap of screen hMainBmp/////

          CImage m_Image;
          m_Image.Attach(hMainBmp);
          m_Image.Save("C:\\image.bmp");//use of jpg instead bmp but if you can zip your file its good.
          m_Image.Detach();
          DeleteDC(m_hdcMem);
          DeleteObject(hMainBmp );
          DeleteObject(m_OldBitmap);

          It's working for me. Now i want to save file in format of .DAT. Please help me

          R 1 Reply Last reply
          0
          • U User 6831394

            thanks both of you for reply.I use this code

            HDC m_hdcMem,hdc;
            HBITMAP m_Bitmap,m_OldBitmap,hMainBmp ;
            //one intersting for you if you want to use of other resulition
            int x=800;
            int y=600;

            //use of GetDC()->m_hDC and see result.
            //hdc=GetDC()->m_hDC;
            hdc=GetDesktopWindow()->GetDC()->m_hDC;

            m_hdcMem= CreateCompatibleDC(hdc);

            //one interesting for you if you want to use of other
            m_Bitmap = CreateCompatibleBitmap(hdc,x,y);
            m_OldBitmap=(HBITMAP) SelectObject(m_hdcMem, m_Bitmap);

            BitBlt(m_hdcMem, 0,0,x,y, hdc,0,0,SRCCOPY);
            hMainBmp =(HBITMAP) SelectObject(m_hdcMem, m_OldBitmap);
            ///////////Now you have a hbitmap of screen hMainBmp/////

            CImage m_Image;
            m_Image.Attach(hMainBmp);
            m_Image.Save("C:\\image.bmp");//use of jpg instead bmp but if you can zip your file its good.
            m_Image.Detach();
            DeleteDC(m_hdcMem);
            DeleteObject(hMainBmp );
            DeleteObject(m_OldBitmap);

            It's working for me. Now i want to save file in format of .DAT. Please help me

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            Member 6864839 wrote:

            Now i want to save file in format of .DAT.

            There's no such .DAT file. What you've got by capturing the screen is a bitmap, and you just save it to the disk by providing any extension you want to the filename. Or if by .DAT you want to have a file format that your app can only handle, encrypt (search the site) the bitmap and save it to ".DAT format".

            “Follow your bliss.” – Joseph Campbell

            U 1 Reply Last reply
            0
            • R Rajesh R Subramanian

              Member 6864839 wrote:

              Now i want to save file in format of .DAT.

              There's no such .DAT file. What you've got by capturing the screen is a bitmap, and you just save it to the disk by providing any extension you want to the filename. Or if by .DAT you want to have a file format that your app can only handle, encrypt (search the site) the bitmap and save it to ".DAT format".

              “Follow your bliss.” – Joseph Campbell

              U Offline
              U Offline
              User 6831394
              wrote on last edited by
              #6

              ok i use this code but file not save in my disk.

              m_Image.Save("C:\\image.dat");

              R 1 Reply Last reply
              0
              • U User 6831394

                ok i use this code but file not save in my disk.

                m_Image.Save("C:\\image.dat");

                R Offline
                R Offline
                Rajesh R Subramanian
                wrote on last edited by
                #7

                Take a look at the example at the end of the documentation for CImage::Save()[^]. Because you said "image.dat", the call didn't know the format. You will need to explicitly specify it as bitmap format by doing it this way:

                m_Image.Save("c:\\image.dat",ImageFormatBMP);

                “Follow your bliss.” – Joseph Campbell

                U 1 Reply Last reply
                0
                • R Rajesh R Subramanian

                  Take a look at the example at the end of the documentation for CImage::Save()[^]. Because you said "image.dat", the call didn't know the format. You will need to explicitly specify it as bitmap format by doing it this way:

                  m_Image.Save("c:\\image.dat",ImageFormatBMP);

                  “Follow your bliss.” – Joseph Campbell

                  U Offline
                  U Offline
                  User 6831394
                  wrote on last edited by
                  #8

                  Thanks it's working. Thanks once again...........

                  R 1 Reply Last reply
                  0
                  • U User 6831394

                    Thanks it's working. Thanks once again...........

                    R Offline
                    R Offline
                    Rajesh R Subramanian
                    wrote on last edited by
                    #9

                    I'm glad I could help. Shameless plug: May I please ask you to mark the helpful replies as "Good Answer" by clicking on the appropriate posts? :)

                    “Follow your bliss.” – Joseph Campbell

                    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