DECLARE INTEGER OpenClipboard IN User32 INTEGER
DECLARE INTEGER CloseClipboard IN User32
DECLARE LONG IsClipboardFormatAvailable IN user32 LONG
DECLARE INTEGER EmptyClipboard IN User32
DECLARE INTEGER SetClipboardData IN User32 INTEGER,INTEGER
DECLARE INTEGER LoadImage IN WIN32API INTEGER,String,INTEGER,INTEGER,INTEGER,INTEGER
DECLARE INTEGER GetClipboardData IN User32 INTEGER
DECLARE INTEGER GdipCreateBitmapFromHBITMAP IN GdiPlus.dll INTEGER, INTEGER, INTEGER @
DECLARE INTEGER GdipSaveImageToFile IN GdiPlus.dll INTEGER,String,String @,String @
DECLARE Long GdipCreateHBITMAPFromBitmap IN GDIPLUS.DLL Long nativeImage, Long @, Long
DECLARE Long GdipCreateBitmapFromFile IN GDIPLUS.DLL String FileName, Long @nBitmap
DECLARE Long CopyImage IN WIN32API Long hImage, Long, Long, Long , Long
#Define CF_BITMAP 2
#Define CF_DIB 8
#Define IMAGE_BITMAP 0
#Define LR_LOADFROMFILE 16
IF IsClipboardFormatAvailable(2)=0
MESSAGEBOX("剪贴板中没有图像",64,"提示")
else
IF OpenClipboard(0)=0
MESSAGEBOX("剪贴板打开失败",64,"提示")
else
OpenClipboard(0)
hBitmap = GetClipboardData(CF_BITMAP)
hDib = GetClipboardData(CF_DIB)
CloseClipboard()
uBitmap=0
GdipCreateBitmapFromHBITMAP(hBitmap,2,@uBitmap)
lcOutputFile=STRCONV('C:\Temp1.jpg'+CHR(0),5)
lqEncoderClsID_JPG=0h01F47C55041AD3119A730000F81EF32E &&运行时此处提示语法错误!!! (JPG格式)
GdipSaveImageToFile(uBitmap,lcOutputFile,lqEncoderClsID_JPG,NULL)
ENDIF
ENDIF
版主,你好! 上面这段代码也可以在VFP9下正常把截图生成JPG文件,但在VFP6下运行时在倒数第4行提示语法错误。
根据您上面的提示,我把这条语句由:lqEncoderClsID_JPG=0h01F47C55041AD3119A730000F81EF32E 改为:
lqEncoderClsID_JPG=CHR(0x01)+CHR(0xF4)+CHR(0x7C)+CHR(0x55)+CHR(0x04)+CHR(0x1A)+CHR(0xD3)+CHR(0x11)+CHR(0x9A)+CHR(0x73)+CHR(0x00)+CHR(0x00)+CHR(0xF8)+CHR(0x1E)+CHR(0xF3)+CHR(0x2E)
虽然运行不出现错误提示,但没有生成截图JPG格式的文件,不知道哪个地方不对,请指教,谢谢。