Help - Search - Members - Calendar
Full Version: VB Help - Card.dll Functions
CyberiaPC.com Community > Technical Zone > Programming (Java SE/EE, VB, C#)
Darkblade
Hi i was wondering if their was any way to get the cdtDraw function to draw a card in front of frames, labels, etc. sad.gif because i rather like the look of using frames for the different parts of my interface and i just can't seem to get the cards to showup in front of the frame??? some one plz help???
usr.c
Welcome to the board Darkblade.

I've never used the cards.dll API, but I compiled the following code for VB .NET, and found that it paints cards on top of all existing components:

CODE
Public Class Form1
   Inherits System.Windows.Forms.Form

   Private w As Integer = 0
   Private h As Integer = 0
   Dim FCardFace As Integer
   Friend WithEvents Label1 As System.Windows.Forms.Label
   Dim FSuit As Integer

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

       cdtInit(w, h)
       FCardFace = 0
       FSuit = 3

   End Sub

   Private Sub Form1_Paint(ByVal sender As Object, _
     ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint

       PaintGraphicFace(e.Graphics, 10, 10, 75, 100)

   End Sub

   Declare Function cdtInit Lib "cards.dll" (ByRef width As Integer, _
     ByRef height As Integer) As Boolean
   Declare Function cdtDrawExt Lib "cards.dll" (ByVal hdc As IntPtr, _
     ByVal x As Integer, ByVal y As Integer, ByVal dx As Integer, _
     ByVal dy As Integer, ByVal card As Integer, _
     ByVal suit As Integer, ByVal color As Long) As Boolean
   Declare Sub cdtTerm Lib "cards.dll" ()

   Public Sub PaintGraphicFace(ByVal g As Graphics, ByVal x As Integer, _
     ByVal y As Integer, ByVal dx As Integer, ByVal dy As Integer)

       Dim hdc As IntPtr = g.GetHdc()
       Try
           Dim Card As Integer = CType(Me.FCardFace, Integer) * 4 + FSuit
           cdtDrawExt(hdc, x, y, dx, dy, Card, 0, 0)
       Finally
           ' If Intellisense doesn't show this method
           ' unhide advanced members in Tools|Options
           g.ReleaseHdc(hdc)
       End Try
   End Sub

   Public Sub PaintGraphicBack(ByVal g As Graphics, ByVal x As Integer, _
     ByVal y As Integer, ByVal dx As Integer, ByVal dy As Integer)

       Dim hdc As IntPtr = g.GetHdc()
       Try
           ' TODO: Make card style (hardcoded 61) a configurable property
           cdtDrawExt(hdc, x, y, dx, dy, 61, 0, 0)
       Finally
           g.ReleaseHdc(hdc)
       End Try

   End Sub

   Private Sub Form1_Closing(ByVal sender As Object, _
     ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
       cdtTerm()
   End Sub
   Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox

   Private Sub InitializeComponent()
       Me.Label1 = New System.Windows.Forms.Label()
       Me.GroupBox1 = New System.Windows.Forms.GroupBox()
       Me.SuspendLayout()
       '
       'Label1
       '
       Me.Label1.Location = New System.Drawing.Point(24, 16)
       Me.Label1.Name = "Label1"
       Me.Label1.Size = New System.Drawing.Size(200, 128)
       Me.Label1.TabIndex = 0
       Me.Label1.Text = "swdsdsadsadsadasdasdsadsadsadasdasdsadsadsa"
       '
       'GroupBox1
       '
       Me.GroupBox1.Location = New System.Drawing.Point(40, 160)
       Me.GroupBox1.Name = "GroupBox1"
       Me.GroupBox1.Size = New System.Drawing.Size(144, 88)
       Me.GroupBox1.TabIndex = 1
       Me.GroupBox1.TabStop = False
       Me.GroupBox1.Text = "GroupBox1"
       '
       'Form1
       '
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.ClientSize = New System.Drawing.Size(292, 266)
       Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.GroupBox1, Me.Label1})
       Me.Name = "Form1"
       Me.ResumeLayout(False)

   End Sub
End Class

http://www.developer.com/net/vb/article.php/3303671


Attached is another example for VB6.

Hope that helps.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2012 Invision Power Services, Inc.