读书人

请问PlayEnhMetaFile不能正常显示图

发布时间: 2012-06-01 16:46:36 作者: rapoo

请教,PlayEnhMetaFile不能正常显示图形
emf文件可以正常生成,可是Picture控件中不显示



[size=11px]

VB code
Private Sub Form_load()    Dim picdc As Long, wmm As Long, hmm As Long, wp As Long, hp As Long, emfdc As Long, hemf As Long    Dim emfrect As RECT    Dim strpath As String        '定义三个点并赋值    Dim points(2) As POINTAPI    points(0).x = 50    points(0).y = 50    points(1).x = 150    points(1).y = 80    points(2).x = 230    points(2).y = 30        '获得Picture1控件的设备场景    picdc = GetDC(Picture1.hwnd)        '给emfrect赋值,并将单位转换为0.01mm    Call GetClientRect(Picture1.hwnd, emfrect)    wmm = GetDeviceCaps(picdc, HORZSIZE)    hmm = GetDeviceCaps(picdc, VERTSIZE)    wp = GetDeviceCaps(picdc, HORZRES)    hp = GetDeviceCaps(picdc, VERTRES)    With emfrect        .Top = (emfrect.Top * hmm * 100) / hp        .Bottom = (emfrect.Bottom * hmm * 100) / hp        .Left = (emfrect.Left * wmm * 100) / wp        .Right = (emfrect.Right * wmm * 100) / wp    End With        '生成emf文件,并在picture1控件中显示    strpath = "c:\emf\temp.emf"    emfdc = CreateEnhMetaFile(picdc, strpath, emfrect, "Test EMF")    Polyline emfdc, points(0), 3    hemf = CloseEnhMetaFile(emfdc)    If PlayEnhMetaFile(picdc, hemf, emfrect) = 0 Then MsgBox "PlayEnhMetaFile执行失败"    DeleteEnhMetaFile (hemf)End Sub
[/size]

[解决办法]
picturebox 肯定不支持emf的,必须你自己转换成bitmap.

读书人网 >VB

热点推荐