| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 868 人关注过本帖
标题:再问gdi+的问题
只看楼主 加入收藏
ylof1986
Rank: 2
等 级:论坛游民
帖 子:241
专家分:61
注 册:2008-1-6
结帖率:93.94%
收藏
已结贴  问题点数:20 回复次数:3 
再问gdi+的问题
为什么背景是不是透明的啊,我的用户控件背景设为透明的了,可是在窗口中加载控件后还是会出现灰色背景啊,这个我有其他控件在时是这个样子,然后使用下面代码时就会啥也不显示
程序代码:
Option Explicit
Private Type GdiplusStartupInput
    GdiplusVersion As Long ' Must be 1 for GDI+ v1.0, the current version as of this writing.
    DebugEventCallback As Long ' Ignored on free builds
    SuppressBackgroundThread As Long ' FALSE unless you're prepared to call
    ' the hook/unhook functions properly
    SuppressExternalCodecs As Long ' FALSE unless you want GDI+ only to use
    ' its internal image codecs.
End Type
Private Enum GpStatus ' aka Status
    Ok = 0
    GenericError = 1
    InvalidParameter = 2
    OutOfMemory = 3
    ObjectBusy = 4
    InsufficientBuffer = 5
    NotImplemented = 6
    Win32Error = 7
    WrongState = 8
    Aborted = 9
    FileNotFound = 10
    ValueOverflow = 11
    AccessDenied = 12
    UnknownImageFormat = 13
    FontFamilyNotFound = 14
    FontStyleNotFound = 15
    NotTrueTypeFont = 16
    UnsupportedGdiplusVersion = 17
    GdiplusNotInitialized = 18
    PropertyNotFound = 19
    PropertyNotSupported = 20
End Enum
Private Declare Function GdiplusStartup Lib "gdiplus" (token As Long, inputbuf As GdiplusStartupInput, Optional ByVal outputbuf As Long = 0) As GpStatus
Private Declare Function GdiplusShutdown Lib "gdiplus" (ByVal token As Long) As GpStatus
Private Declare Function GdipDrawImage Lib "gdiplus" (ByVal graphics As Long, ByVal Image As Long, ByVal x As Single, ByVal y As Single) As GpStatus
Private Declare Function GdipCreateFromHDC Lib "gdiplus" (ByVal hDC As Long, graphics As Long) As GpStatus
Private Declare Function GdipDeleteGraphics Lib "gdiplus" (ByVal graphics As Long) As GpStatus
Private Declare Function GdipLoadImageFromFile Lib "gdiplus" (ByVal filename As Any, Image As Long) As GpStatus
Private Declare Function GdipDisposeImage Lib "gdiplus" (ByVal Image As Long) As GpStatus
Dim gdip_Token As Long
Dim gdip_pngImage As Long
Dim gdip_Graphics As Long

Private Sub UserControl_Initialize()
Dim GpInput As GdiplusStartupInput
GpInput.GdiplusVersion = 1
If GdiplusStartup(gdip_Token, GpInput) <> Ok Then
    MsgBox "加载GDI+失败!", vbCritical, "加载错误"
    End
End If
If GdipCreateFromHDC(UserControl.hDC, gdip_Graphics) <> Ok Then
    MsgBox "出现错误!", vbCritical, "错误"
    GdiplusShutdown gdip_Token
    End
Else
Debug.Print UserControl.hDC
End If
Dim gs As GpStatus, sTmp$
sTmp$ = App.Path & "\Show.png"
gs = GdipLoadImageFromFile(StrPtr(sTmp$), gdip_pngImage)   '加载文件
Debug.Print gs = GpStatus.Ok, gs
End Sub

Private Sub UserControl_Paint()
If GdipDrawImage(gdip_Graphics, gdip_pngImage, 0, 0) <> Ok Then Debug.Print "显示失败。。。"  '就是这步会失败
End Sub

Private Sub UserControl_Terminate()
GdipDisposeImage gdip_pngImage
GdipDeleteGraphics gdip_Graphics
GdiplusShutdown gdip_Token
End Sub

 

[ 本帖最后由 ylof1986 于 2010-3-26 10:45 编辑 ]
搜索更多相关主题的帖子: gdi 
2010-03-26 10:42
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:20 
回复 楼主 ylof1986
http://www.
哎!~

看看吧!~
2010-03-26 14:01
ylof1986
Rank: 2
等 级:论坛游民
帖 子:241
专家分:61
注 册:2008-1-6
收藏
得分:0 
回复 2楼 bczgvip
看了下,看不懂,难道对于高手这部分代码不简单吗,简单的话就告诉我吧
2010-03-27 20:16
bczgvip
Rank: 14Rank: 14Rank: 14Rank: 14
等 级:贵宾
威 望:66
帖 子:1310
专家分:5312
注 册:2009-2-26
收藏
得分:0 
那是简单例子,各种图形图像的实现。
还有个类型库。
引用-浏览-  xxx.tlb
慢慢搞吧!
2010-03-28 06:34
快速回复:再问gdi+的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048298 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved