Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ExtractIcon or ExtractAssociatedIcon...
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00653833
Message ID:
00660304
Views:
67
>SavePicture() requires an object reference in VFP. I've tried with value returned by OleCreatePictureIndirect() but that's simply a pointer to the object. That doesn't work. In order to use SavePicture(), I'd have to use SYS(2600) to copy the object. Unfortunately, I have no idea as to what to specify for the size. Or am I misunderstanding something here?

May be you overlooked what for VFP7 IPic parameter in OleCreatePictureIndirect() is declared as Object. SavePicture() works for me. You can try this code for saving clipboard content in BMP file:
#define PICTYPE_BITMAP 1
#define CF_BITMAP 2
#define IID_IDispatch Chr(0x00)+Chr(0x04)+Chr(0x02)+Chr(0x00)+ ;
		Replicate(Chr(0x00), 4)+Chr(0xC0)+Replicate(Chr(0x00), 6)+Chr(0x46)

Declare Long OpenClipboard In user32 Long hWnd
Declare Long CloseClipboard In user32
Declare Long GetClipboardData In user32 Long uFormat
Declare Long OleCreatePictureIndirect In oleaut32 ;
	String @ PicDesc, String @ RefIID, Long fPictureOwnsHandle, Object @ IPic

If OpenClipboard(0) != 0
	lhBmp = GetClipboardData(CF_BITMAP)
	If lhBmp = 0
		MessageBox("No bitmap data in clipboard")
	Else
		* Create Picture object according to PICTDESC structure
		PictDesc = DWord(16) ;				&& Size of PICTDESC structure
				 + DWord(PICTYPE_BITMAP) ;	&& Type of picture
				 + DWord(lhBmp) ;			&& HBITMAP
				 + DWord(0)					&& HPALETTE
		IPic = 0
		iid = IID_IDispatch
		OleCreatePictureIndirect(@PictDesc, @iid, 0, @IPic)
		SavePicture(IPic, "clipbrd.bmp")
	EndIf

	CloseClipboard()
EndIf
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform