2007-04-22, 19:38
  #1
Medlem
ni-ar-fjortisars avatar
hej! Jag hade tänkt att utveckla ett kortspel, men jag har fastnat! Jag kan inte rita ut korten! Jag får fram detta: http://ww2.beffo.se/upload/pic~/1RSJQyOwOwTG.JPG

Jag förstår inte vad som händer, jag försöker rita up två kort, ena på (10,10) och andra (10,15)!

Här är min kod:

Kod:
        void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics x = e.Graphics;
            hdc = x.GetHdc();
            x.ReleaseHdc(hdc);
            Draw();
            
        }

        void Draw()
        {
            this.Text = cardsdll.drawCard(hdc, 10, 10, 10, 0, 0).ToString();
            this.Text = cardsdll.drawCard(hdc, 10, 15, 10, 0, 0).ToString();
        }

(this.Text blir True btw)
Funktionen drawCard använder sig av denna funktion:
Kod:
        [DllImport("cards.dll", SetLastError = true)]
        private static extern bool cdtDraw(IntPtr hdc, int x, int y, int card, int mode, int color);

Skulle uppskatta lite hjälp här!
Citera
2007-04-22, 19:43
  #2
Medlem
http://www.codeproject.com/csharp/drawcardscp1.asp

där har du en grundlig guid till hur du ska göra
Citera
2007-04-22, 19:44
  #3
Medlem
och du måste väl ange MODE

alternativ

int mode - mode
.
mdFaceUp - draw face up card
mdFaceDown - draw face down card
mdHilite - draw face up card inverted
mdGhost - draw a ghost card, the card parameter is ignored
mdRemove - draw rectangle of background color at x, y
mdDeckX - draw an X
mdDeckO - draw an O
Citera
2007-04-22, 19:55
  #4
Medlem
ni-ar-fjortisars avatar
Citat:
Ursprungligen postat av K85
och du måste väl ange MODE

alternativ

int mode - mode
.
mdFaceUp - draw face up card
mdFaceDown - draw face down card
mdHilite - draw face up card inverted
mdGhost - draw a ghost card, the card parameter is ignored
mdRemove - draw rectangle of background color at x, y
mdDeckX - draw an X
mdDeckO - draw an O

Det var den jag gick efter.

Jao, mdFaceUp = 0

Ska kolla lite mer på codeprojectsidan
Citera
2007-04-22, 20:01
  #5
Medlem
du har inte missat >

[DllImport("cards.dll")]
private static extern bool cdtInit( ref int width, ref int height );

cdtInit initializes the cards.dll library. As you can see the method takes two arguments which are stored as the width and height of the card in pixels. The return value is either TRUE for when the cards.dll has been initialized, or FALSE if an error has occurred. The constructor for the cardsdll class will throw an exception if there is an error. This is shown in the snippet below.
Citera
2007-04-22, 20:16
  #6
Medlem
ni-ar-fjortisars avatar
Citat:
Ursprungligen postat av K85
du har inte missat >

[DllImport("cards.dll")]
private static extern bool cdtInit( ref int width, ref int height );

cdtInit initializes the cards.dll library. As you can see the method takes two arguments which are stored as the width and height of the card in pixels. The return value is either TRUE for when the cards.dll has been initialized, or FALSE if an error has occurred. The constructor for the cardsdll class will throw an exception if there is an error. This is shown in the snippet below.

Tack så mycket!

Hade funktionen som skulle initialisera den, men jag körde den aldrig! Tack!
Citera
2007-04-22, 20:37
  #7
Medlem
Citat:
Ursprungligen postat av ni-ar-fjortisar
Tack så mycket!

Hade funktionen som skulle initialisera den, men jag körde den aldrig! Tack!

Tack för att jag fick hjälpa
Citera

Skapa ett konto eller logga in för att kommentera

Du måste vara medlem för att kunna kommentera

Skapa ett konto

Det är enkelt att registrera ett nytt konto

Bli medlem

Logga in

Har du redan ett konto? Logga in här

Logga in