VARIANT Bitmap
-
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.
-
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.
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]
-
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]
-
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.
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]
-
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]
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)
RegardsThe Best Religion is Science. Once you understand it, you will know God.
-
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)
RegardsThe Best Religion is Science. Once you understand it, you will know God.
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]
-
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]
-
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.
Zainu wrote:
win32 api CreateFromHandle
Win32 API??? I didnt find it in MSDN. Can you tell me where it is declared?
nave [OpenedFileFinder]