>cards.cardsdll.drawcard(System.IntPtr, int, int, int, int, int)
>
>>public class DeckOfCards >{ > [DllImport("cards.dll")] > private static extern bool drawcard(ref IntPtr handle, ref int top, ref int left, > ref int width, ref int height, ref int card); > > public DeckOfCards() > { > } > > public bool DrawACard(IntPtr canvas, int top, int left, int width, int height, int card) > { > return drawcard(ref canvas, ref top, ref left, ref height, ref width, ref card); > } >} >>
>public partial class Form1 : Form >{ > public Form1() > { > InitializeComponent(); > > DrawCard(); > } > > private void DrawCard() > { > DeckOfCards Deck = new DeckOfCards(); > > IntPtr hdc = this.Handle; > > Deck.DrawACard(hdc, 10, 10, 100, 50, (int)Ranks.Five * 4 + (int)Suits.Clubs); > > } >} >>
public class DeckOfCards { [DllImport("cards.dll")] private static extern bool cdtInit(ref int width, ref int height); [DllImport("cards.dll")] private static extern bool cdtDraw(IntPtr hdc, int x, int y, int card, int mode, long color); public DeckOfCards() { int width = 150; int height = 150; if (!cdtInit(ref width, ref height)) throw new Exception("Could not initialize"); } public bool DrawACard(IntPtr canvas, int left, int top, int card, int mode, long color) { return cdtDraw(canvas, left, top,card, mode, color); } }Also I don't think you can draw it using the handle. Try from the forms OnPaint():
new DeckOfCards().DrawACard(e.Graphics.GetHdc(), 10, 10, 16 ,1,207);Of course in reality you wouldn't create an instance of DeckOfCards every time - just keep one hanging around somewhere.....