如何制作VFP桌面歌词效果,API和GDI高手请进
恳请各位大侠给于指点
参考VB代码
http://tieba.baidu.com/f?kz=702349514
下载地址:
http://www.quwen168.com/lrcshow.rar
现已实现在表单上画出,本来想画到图片中再通过透明窗口来实现,试了一下字体边缘很难看....
主要是这两个API不知道怎么实现
CreateDIBSection
UpdateLayeredWindow
网上找到的CreateDIBSection定义但BHDR_STRUCT_SIZE参数的值不知道是什么
nBitmapWidth=500
nBitmapHeight=300
nBitsPerPixel=24
ppvBits=0
cBITMAPINFOHEADER=num2dword(BHDR_STRUCT_SIZE) +;
num2dword(nBitmapWidth) + num2dword(nBitmapHeight) +;
num2word(1) + num2word(nBitsPerPixel) +;
num2dword(BI_RGB)
cBITMAPINFOHEADER=PADR(cBITMAPINFOHEADER,;
BHDR_STRUCT_SIZE, CHR(20))
hBitmap=CreateDIBSection(hDC, @cBITMAPINFOHEADER,;
DIB_RGB_COLORS, @ppvBits, 0, 0)
以下代码放在一个命令按键里就可看出绘制效果,注意表单的ShowWindow=0
DECLARE INTEGER GdipCreateStringFormat IN GdiPlus.dll ;
INTEGER formatAttributes, INTEGER language, INTEGER @nFormat
DECLARE INTEGER GdipDeleteBrush IN GdiPlus.dll ;
INTEGER brush
DECLARE INTEGER GdipCreateFont IN GdiPlus.dll;
INTEGER fontFamily, SINGLE emSize,;
INTEGER fntstyle, INTEGER unit, INTEGER @fnt
DECLARE INTEGER GdipDeleteFont IN GdiPlus.dll ;
INTEGER fnt
DECLARE INTEGER GdipCreateFontFamilyFromName IN GdiPlus.dll;
STRING familyname, INTEGER FontCollection, INTEGER @FontFamily
DECLARE INTEGER GdipDeleteFontFamily IN GdiPlus.dll ;
INTEGER FontFamily
DECLARE INTEGER GdipCreateFromHWND IN gdiplus.dll ;
INTEGER hWind, INTEGER @graphics
DECLARE INTEGER GdipDeleteGraphics IN GdiPlus.dll ;
INTEGER graphics
DECLARE INTEGER GdipSetSmoothingMode IN "gdiplus" INTEGER ,INTEGER
DECLARE INTEGER GdipCreateFontFamilyFromName IN gdiplus STRING familyname, INTEGER fontCollection, INTEGER @FontFamily
DECLARE INTEGER GdipCreateStringFormat IN gdiplus INTEGER formatAttributes, INTEGER language, INTEGER @fmt
DECLARE integer GdipCreateLineBrushFromRect IN gdiplus.dll string,integer,integer,integer, integer, integer @
DECLARE LONG GdipCreatePath IN GDIPLUS LONG brushmode, LONG @path
DECLARE LONG GdipAddPathStringI IN GDIPLUS LONG path, STRING str, LONG length, LONG family, LONG style, SINGLE emSize, STRING @layoutRect, LONG StringFormat
DECLARE LONG GdipFillPath IN GDIPLUS LONG graphics, LONG brush, LONG path
DECLARE LONG GdipDrawPath IN GDIPLUS LONG graphics, LONG pen, LONG path
DECLARE INTEGER GdipCreatePen1 IN gdiplus INTEGER color,SINGLE penwidth,INTEGER unit,INTEGER @ gdipen
graphics=0
GdipCreateFromHWND(thisform.hwnd,@graphics)
GdipSetSmoothingMode(graphics,2)&&SmoothingModeHighQuality
lcFontName='黑体'&&字体名称,必须是已注册的字体
lcFontName=STRCONV(lcFontName+CHR(0),5)
lnFontFamily=0
GdipCreateFontFamilyFromName(lcFontName,0,@lnFontFamily)
strFormat = 0
GdipCreateStringFormat(0,0,@strFormat)
*DECLARE LONG GdipSetStringFormatAlign IN GDIPLUS LONG @StringFormat, LONG
*GdipSetStringFormatAlign(@strFormat,1)
x=0&&绘制文字的左上角坐标
y=0
w=72
h=72
lcRectangleF=BINTOC(x,'F')+BINTOC(y,'F')+BINTOC(W,'F')+BINTOC(H,'F')
Brush = 0
GdipCreateLineBrushFromRect(lcRectangleF, 0x90000000, 0x90000000, 1, 2, @Brush)
x=1&&绘制文字的左上角坐标
y=1
rclayout=BINTOC(x,'4rs')+BINTOC(y,'4rs')
strPath = 0
GdipCreatePath(0,@strPath)
GdipAddPathStringI(strPath, STRCONV('QQ音乐,我最流行!'+CHR(0),5), -1, lnFontFamily, 1, 72, rclayout, strFormat)&&strFormat
GdipFillPath(graphics, Brush, strPath)
GdipDrawPath(graphics, 0, strPath)
*RETURN
*---
Brush = 0
GdipCreateLineBrushFromRect(lcRectangleF, 0x30000000, 0x30000000, 1, 3, @Brush)
x=1.5&&绘制文字的左上角坐标
y=1.5
rclayout=BINTOC(x,'4rs')+BINTOC(y,'4rs')
GdipCreatePath(0,@strPath)
GdipAddPathStringI(strPath, STRCONV('QQ音乐,我最流行!'+CHR(0),5), -1, lnFontFamily, 1, 72, rclayout, strFormat)
GdipFillPath(graphics, Brush, strPath)
GdipDrawPath(graphics, 0, strPath)
*---
Brush = 0
GdipCreateLineBrushFromRect(lcRectangleF, 0x20000000, 0x20000000, 1, 3, @Brush)
x=2&&绘制文字的左上角坐标
y=2
rclayout=BINTOC(x,'4rs')+BINTOC(y,'4rs')
GdipCreatePath(0,@strPath)
GdipAddPathStringI(strPath, STRCONV('QQ音乐,我最流行!'+CHR(0),5), -1, lnFontFamily, 1, 72, rclayout, strFormat)
GdipFillPath(graphics, Brush, strPath)
GdipDrawPath(graphics, 0, strPath)
*---
Brush = 0
GdipCreateLineBrushFromRect(lcRectangleF, 0x10000000, 0x10000000, 1, 3, @Brush)
x=2.2&&绘制文字的左上角坐标
y=2.2
rclayout=BINTOC(x,'4rs')+BINTOC(y,'4rs')
GdipCreatePath(0,@strPath)
GdipAddPathStringI(strPath, STRCONV('QQ音乐,我最流行!'+CHR(0),5), -1, lnFontFamily, 1, 72, rclayout, strFormat)
GdipFillPath(graphics, Brush, strPath)
GdipDrawPath(graphics, 0, strPath)
*---
Brush = 0
GdipCreateLineBrushFromRect(lcRectangleF, 0x40000000, 0x40000000, 1, 3, @Brush)
x=-1&&绘制文字的左上角坐标
y=-1
rclayout=BINTOC(x,'4rs')+BINTOC(y,'4rs')
GdipCreatePath(0,@strPath)
GdipAddPathStringI(strPath, STRCONV('QQ音乐,我最流行!'+CHR(0),5), -1, lnFontFamily, 1, 72, rclayout, strFormat)
GdipFillPath(graphics, Brush, strPath)
GdipDrawPath(graphics, 0, strPath)
*---
Brush = 0
GdipCreateLineBrushFromRect(lcRectangleF, 0x30000000, 0x30000000, 1, 3, @Brush)
x=-1.5&&绘制文字的左上角坐标
y=-1.5
rclayout=BINTOC(x,'4rs')+BINTOC(y,'4rs')
*
GdipCreatePath(0,@strPath)
GdipAddPathStringI(strPath, STRCONV('QQ音乐,我最流行!'+CHR(0),5), -1, lnFontFamily, 1, 72, rclayout, strFormat)
GdipFillPath(graphics, Brush, strPath)
GdipDrawPath(graphics, 0, strPath)
*---
Brush = 0
GdipCreateLineBrushFromRect(lcRectangleF,0xFF013C8F,0xFF0198D4, 1, 3, @Brush)
x=0&&绘制文字的左上角坐标
y=0
rclayout=BINTOC(x,'4rs')+BINTOC(y,'4rs')
pen =0
GdipCreatePen1(0x90000000, 1, 5, @pen)
GdipCreatePath(0,@strPath)
GdipAddPathStringI(strPath, STRCONV('QQ音乐,我最流行!'+CHR(0),5), -1, lnFontFamily, 1, 72, rclayout, strFormat)
GdipFillPath(graphics, Brush, strPath)
GdipDrawPath(graphics, pen, strPath)