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. VARIANT Bitmap

VARIANT Bitmap

Scheduled Pinned Locked Moved C / C++ / MFC
comgraphicstutoriallearning
8 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
    shiraztk
    wrote on last edited by
    #1

    Hi all Let me explain my requirement. I want to create a Activex control which has two methods SetPicture() and GetPicture(). SetPicture(VARIANT data) should copy the contents of the data to the clipboard and VARIANT GetPicture should return the contents of the clipboard. I know how to manage clipboard. But I dont know how to manage the VARIANT to hold the bitmap. Could anyone point me to a good resource or spare time to tell me how to accomplish this. Regards

    The Best Religion is Science. Once you understand it, you will know God.

    N 1 Reply Last reply
    0
    • S shiraztk

      Hi all Let me explain my requirement. I want to create a Activex control which has two methods SetPicture() and GetPicture(). SetPicture(VARIANT data) should copy the contents of the data to the clipboard and VARIANT GetPicture should return the contents of the clipboard. I know how to manage clipboard. But I dont know how to manage the VARIANT to hold the bitmap. Could anyone point me to a good resource or spare time to tell me how to accomplish this. Regards

      The Best Religion is Science. Once you understand it, you will know God.

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      Zainu wrote:

      SetPicture(VARIANT data) should copy the contents of the data to the clipboard and VARIANT GetPicture should return the contents of the clipboard

      Since you need to pass the bitmap between the same process, it better to pass the handle of the bitmap to and from the active-x. Other option is to pass the bitmap's pixel data. i.e retrive the pixel data. set the pointer of the bits array to the VARIANT object then pass it. The activex should again covert this pixel data to bitmap. I think the first one is simple.

      nave [OpenedFileFinder]

      S 1 Reply Last reply
      0
      • N Naveen

        Zainu wrote:

        SetPicture(VARIANT data) should copy the contents of the data to the clipboard and VARIANT GetPicture should return the contents of the clipboard

        Since you need to pass the bitmap between the same process, it better to pass the handle of the bitmap to and from the active-x. Other option is to pass the bitmap's pixel data. i.e retrive the pixel data. set the pointer of the bits array to the VARIANT object then pass it. The activex should again covert this pixel data to bitmap. I think the first one is simple.

        nave [OpenedFileFinder]

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

        Thankyou If I want to pass the handle of the bitmap what should be the type of the VARIANT? Regards

        The Best Religion is Science. Once you understand it, you will know God.

        N 1 Reply Last reply
        0
        • S shiraztk

          Thankyou If I want to pass the handle of the bitmap what should be the type of the VARIANT? Regards

          The Best Religion is Science. Once you understand it, you will know God.

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          Zainu wrote:

          what should be the type of the VARIANT?

          VT_I4 cast the handle to a long value and set it to the lVal of the VARIANT.

          nave [OpenedFileFinder]

          S 1 Reply Last reply
          0
          • N Naveen

            Zainu wrote:

            what should be the type of the VARIANT?

            VT_I4 cast the handle to a long value and set it to the lVal of the VARIANT.

            nave [OpenedFileFinder]

            S Offline
            S Offline
            shiraztk
            wrote on last edited by
            #5

            Hi Thats fine. Thankyou. Now to test my activex i am using vb. There I created a picturebox and am trying to set the picture property of picturebox using MyControl.GetBitmap (After copying a bitmap to the clipboard) Should this work or is there anything else am to do. (Anyway this is not working as expected am getting an Object required error. This is the VB code. Sorry for posting VB code in this forum, just for clarity Dim bit As Variant bit = AaClipboard1.GetBitmap Picture1.Picture = bit // am getting error here. End Sub) Regards

            The Best Religion is Science. Once you understand it, you will know God.

            N 1 Reply Last reply
            0
            • S shiraztk

              Hi Thats fine. Thankyou. Now to test my activex i am using vb. There I created a picturebox and am trying to set the picture property of picturebox using MyControl.GetBitmap (After copying a bitmap to the clipboard) Should this work or is there anything else am to do. (Anyway this is not working as expected am getting an Object required error. This is the VB code. Sorry for posting VB code in this forum, just for clarity Dim bit As Variant bit = AaClipboard1.GetBitmap Picture1.Picture = bit // am getting error here. End Sub) Regards

              The Best Religion is Science. Once you understand it, you will know God.

              N Offline
              N Offline
              Naveen
              wrote on last edited by
              #6

              hmm my VB is weak. How ever the Picture1.Picture is a IPictureDisp object. Please search whether there is any method to create IPictureDisp from HBITMAP. like Dim pic As IPictureDisp pic == somefunction( var ) Picture1.Picture = pic

              nave [OpenedFileFinder]

              S 1 Reply Last reply
              0
              • N Naveen

                hmm my VB is weak. How ever the Picture1.Picture is a IPictureDisp object. Please search whether there is any method to create IPictureDisp from HBITMAP. like Dim pic As IPictureDisp pic == somefunction( var ) Picture1.Picture = pic

                nave [OpenedFileFinder]

                S Offline
                S Offline
                shiraztk
                wrote on last edited by
                #7

                Hi thankyou, i got it working. I made it VARIANT long. In vb I used a win32 api CreateFromHandle and passed the variant type. Regards

                The Best Religion is Science. Once you understand it, you will know God.

                N 1 Reply Last reply
                0
                • S shiraztk

                  Hi thankyou, i got it working. I made it VARIANT long. In vb I used a win32 api CreateFromHandle and passed the variant type. Regards

                  The Best Religion is Science. Once you understand it, you will know God.

                  N Offline
                  N Offline
                  Naveen
                  wrote on last edited by
                  #8

                  Zainu wrote:

                  win32 api CreateFromHandle

                  Win32 API??? I didnt find it in MSDN. Can you tell me where it is declared?

                  nave [OpenedFileFinder]

                  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