惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
G
Google Developers Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
A
About on SuperTechFans
Vercel News
Vercel News
B
Blog
Martin Fowler
Martin Fowler
MyScale Blog
MyScale Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
腾讯CDC
D
Docker
V
Visual Studio Blog
博客园 - 叶小钗
The Cloudflare Blog
Jina AI
Jina AI
B
Blog RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏

博客园 - 岳洋

网上较好的提取链接的正则表达式 下载网页源代码的程序 一个读取网页源代码的小程序 file manager 0.1 circleliner阅读笔记 panel的使用 用于学习鼠标作图的网页。 写文件时换行的问题[转载] by 東風耐候 - 岳洋 用旧方法文件读写 - 岳洋 - 博客园 Birthday Reminder Framework 1.1版本 Birthday Reminder (R Edition) ver1.0 build 050813正式发布! 050627ReciteDemo0.2 050626诗歌背诵程序demo 050615 B-A-M v1.0源代码 050615 Bact.-Anti-Med.ver1.0正式发布! 新建一个按钮至少需要做的事情…… 我决定不再和窗体设计器争生意了! 050614Bact.-Anti-Med.v0.3最新更新 按钮的突然消失!(小记一次编程失误)
关键词:vb.net 扑克 cards.dll
岳洋 · 2006-02-09 · via 博客园 - 岳洋

Posted on 2006-02-09 16:56  岳洋  阅读(585)  评论()    收藏  举报

网上的确有,不过不知道为什么我那里运行不了。这里提供的代码是paint在panel上的。.net真好啊,不用设备上下文,gethdc默认还是隐藏的……我找来找去都找不到这个方法……
几点注意:
1.记得要把dll初始化,function cdtInit。两个参数,在网上找吧。
2.要redraw panel,用:Panel1.Invalidate()。

Public Class Form1
    
Inherits System.Windows.Forms.Form
    
Dim pcards(3As card
    
Dim p As card
    
Dim i As Integer
    
Declare Function cdtInit Lib "cards.dll" (ByRef width As Integer, _
    
ByRef height As IntegerAs Boolean
    
Declare Function cdtDrawExt Lib "cards.dll" (ByVal hdc As IntPtr, _
      
ByVal x As IntegerByVal y As IntegerByVal dx As Integer, _
      
ByVal dy As IntegerByVal card As Integer, _
      
ByVal suit As IntegerByVal color As LongAs Boolean
    
Declare Sub cdtTerm Lib "cards.dll" ()

    
Public Structure card
        
Public face As Integer
        
Public suit As Integer
        
Public count As Integer
        
Public faceup As Boolean
    
End Structure



Windows 窗体设计器生成的代码


    
Private Sub Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Panel1.Paint
        
Dim ct As Int16 = 0
        
For ct = 1 To 3
            drawcard(pcards(ct), e.Graphics, 
10 + ct * 203075100)
        
Next
        
'For Each p In pcards
        'drawcard(p, e.Graphics, 10 + ct * 10, 30, 75, 100)
        'ct += 1
        'Next

    
End Sub

    
Private Sub drawcard(ByVal t As card, ByVal g As Graphics, ByVal x As Integer, _
     
ByVal y As IntegerByVal dx As IntegerByVal dy As Integer)
        
Dim hdc As IntPtr = g.GetHdc()
        
Try
            
Dim Card As Integer = t.suit * 4 + t.count
            cdtDrawExt(hdc, x, y, dx, dy, Card, 
00)
        
Finally
            
' If Intellisense doesn't show this method 
            ' unhide advanced members in Tools|Options
            g.ReleaseHdc(hdc)
        
End Try
    
End Sub


    
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cdtInit(
75100)

        
For i = 1 To 3
            pcards(i) 
= New card()
            
With pcards(i)
                .suit 
= i
                .count 
= i + 1
            
End With
        
Next
        Panel1.Invalidate()
    
End Sub

End Class