Herzlich Willkommen, lieber Gast!
  Sie befinden sich hier:

  Forum » C / C++ (WinAPI, Konsole) » Pokerspiel

Forum | Hilfe | Team | Links | Impressum | > Suche < | Mitglieder | Registrieren | Einloggen
  Quicklinks: MSDN-Online || STL || clib Reference Grundlagen || Literatur || E-Books || Zubehör || > F.A.Q. < || Downloads   

Autor Thread - Seiten: [ 1 ] > 2 < [ 3 ]
010
10.02.2006, 23:13 Uhr
xXx
Devil


hmm ok... ich hab ne kleine C++ Klasse geschrieben... eigentlich sollte es funzen... scheinbar stimmt aber etwas mit den Params die ich der Funktion aus der DLL übergeb... nuja.. vllt findet jemand meinen (dummen) Fehler... also hier mal der src:

Header-Datei

C++:
#pragma once

#include <windows.h>

#define CS_FACEUP            0    // Draw card face up
#define CS_FACEDOWN            1    // Draw card face down
#define CS_HILITE            2    // Same as FaceUp except drawn inverted
#define CS_GHOST            3    // Draw a ghost card -- for ace piles
#define CS_REMOVE            4    // draw background specified by color
#define CS_INVISIBLE_GHOST    5    // ?
#define CS_DECKX            6    // Draw X
#define CS_DECKO            7    // Draw O

enum eSUIT
{
    CLUBS   = 0,
    DIAMOND = 1,
    HEARTS  = 2,
    SPADES  = 3
};

enum eRANK // Ich weiß nicht ob ich die beiden enums brauche... eigentlich nicht ;) mal sehen...
{
    ACE   = 0,
    TWO   = 1,
    THREE = 2,
    FOUR  = 3,
    FIVE  = 4,
    SIX   = 5,
    SEVEN = 6,
    EIGHT = 7,
    NINE  = 8,
    TEN   = 9,
    JACK  = 10,
    QUEEN = 11,
    KING  = 12
};

typedef bool (__stdcall*cdtInit)(int iWidth, int iHeight);
typedef void (__stdcall*cdtTerm)();
typedef bool (__stdcall*cdtDraw)(HDC hdc, int x, int y, int iCard, int iMode, long lColor);
typedef bool (__stdcall*cdtDrawExt)(HDC hdc, int x, int y, int dx, int dy, int iCard, int iMode, long lColor);
typedef bool (__stdcall*cdtAnimate)(HDC hdc, int iCardBack, int x, int y, int iFrame);

class CCardsDLL
{
public:
    CCardsDLL(void);
    ~CCardsDLL(void);

public:
    HINSTANCE        m_hCardsDll;        // Handle (cards.dll)
    bool            m_bIsLoaded;

public:
    bool            Init(void);
    void            Destroy(void);
    bool            drawCard(HDC hdc, int x, int y, int iCard, int iMode, long lColor);
    bool            drawCardBack(HDC hdc, int x, int y, int iCard);
    bool            drawAnimatedBack(HDC hdc, int x, int y, int iCard, int iFrame);
    bool            drawInvertedCard(HDC hdc, int x, int y, int iCard);
    bool            drawEmptyCard(HDC hdc, int x, int y, long lColor);
    bool            drawExtrudedCard(HDC hdc, int x, int y, int dx, int dy, int iCard, int iMode, long lColor);

    static eSUIT    getSuit(int iCard); // Weiß noch nicht ob ich die brauch.... ist erstmal nur übernommen...
    static eRANK    getRank(int iCard); // " "
};



Sourcefile

C++:
#include ".\cardsdll.h"

cdtInit        myCdtInit        = NULL;
cdtDraw        myCdtDraw        = NULL;
cdtDrawExt    myCdtDrawExt    = NULL;
cdtTerm        myCdtTerm        = NULL;
cdtAnimate    myCdtAnimate    = NULL;

CCardsDLL::CCardsDLL(void)
{
    m_hCardsDll = ::LoadLibrary("cards.dll");

    if(m_hCardsDll == NULL)
    {
        ::MessageBox(NULL, "Unable to load library.", "Error", MB_OK | MB_ICONERROR);
    }
    else
    {
        myCdtInit        = reinterpret_cast<cdtInit>(::GetProcAddress(m_hCardsDll, "cdtInit"));
        myCdtDraw        = reinterpret_cast<cdtDraw>(::GetProcAddress(m_hCardsDll, "cdtDraw"));
        myCdtDrawExt    = reinterpret_cast<cdtDrawExt>(::GetProcAddress(m_hCardsDll, "cdtDrawExt"));
        myCdtTerm        = reinterpret_cast<cdtTerm>(::GetProcAddress(m_hCardsDll, "cdtTerm"));
        myCdtAnimate    = reinterpret_cast<cdtAnimate>(::GetProcAddress(m_hCardsDll, "cdtAnimate"));

        if(myCdtInit == NULL || myCdtDraw == NULL || myCdtDrawExt == NULL || myCdtTerm == NULL || myCdtAnimate == NULL)
        {
            m_bIsLoaded = false;
            ::MessageBox(NULL, "There is an error!", "Error", MB_OK | MB_ICONERROR);
            ::FreeLibrary(m_hCardsDll);
        }
        else
        {
            m_bIsLoaded = true;
        }
    }
}

bool CCardsDLL::Init(void)
{
    if(m_bIsLoaded)
    {
        if(!::myCdtInit(71, 95))
        {
            ::MessageBox(NULL, "Fehler beim Initialisieren der Spielkarten!", "Fehler", MB_OK | MB_ICONERROR);
            return false;
        }
    }
    else
    {
        return m_bIsLoaded;
    }
}

CCardsDLL::~CCardsDLL(void)
{
    Destroy();
}


void CCardsDLL::Destroy(void)
{
    ::myCdtTerm();
    ::FreeLibrary(m_hCardsDll);
}

bool CCardsDLL::drawCard(HDC hdc, int x, int y, int iCard, int iMode, long lColor)
{
    return ::myCdtDraw(hdc, x, y, iCard, iMode, lColor);                
}

bool CCardsDLL::drawCardBack(HDC hdc, int x, int y, int iCard)
{
    return ::myCdtDraw(hdc, x, y, iCard, CS_FACEDOWN, 0);                
}

bool CCardsDLL::drawAnimatedBack(HDC hdc, int x, int y, int iCard, int iFrame)
{
    return ::myCdtAnimate(hdc, iCard, x, y, iFrame );
}

bool CCardsDLL::drawInvertedCard(HDC hdc, int x, int y, int iCard)
{
    return ::myCdtDraw(hdc, x, y, iCard, CS_HILITE, 0 );                
}

bool CCardsDLL::drawEmptyCard(HDC hdc, int x, int y, long lColor)
{
    return ::myCdtDraw(hdc, x, y, 1, CS_GHOST, lColor);            
}

bool CCardsDLL::drawExtrudedCard(HDC hdc, int x, int y, int dx, int dy, int iCard, int iMode, long lColor)
{
    return ::myCdtDrawExt(hdc, x, y, dx, dy, iCard, iMode, lColor);
}

eSUIT CCardsDLL::getSuit(int iCard)
{
    int iSuit = iCard % 4;
    
    return (eSUIT)iSuit;
}

eRANK CCardsDLL::getRank(int iCard)
{
    int iRank = iCard / 4;
    
    return (eRANK)iRank;
}



So... das ganze ist noch nicht fertig... aber vllt findet jemand von euch ja auch direkt den Fehler... ich find ihn imo net und hab Kopfschmerzen und keinen Bock mehr Mach morgen odg. weiter...

Mit freundlichen Grüßen
Deviloper
Devil Entertainment
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
011
10.02.2006, 23:41 Uhr
xXx
Devil


Uff.. vllt findet ja jemand den Fehler... Dependency Walker meint, das die Entry Points der Funktionen in der DLL wie folgt lauten:

WEP 0x000013E0
cdtAnimate 0x0000118A
cdtDraw 0x00001813
cdtDrawExt 0x000014F3
cdtInit 0x000013E6
cdtTerm 0x0000138B

... jemand ne Idee was ich noch flasch hab?
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
012
10.02.2006, 23:48 Uhr
xXx
Devil


arg.. jetzt hab ich mist erzählt... das war weil ich nur die dll untersucht hab.. dann listet der die funktionen falsch... also, die Einstiegspunkte sind mit dem wert den bsw. myCdtInit hat identisch... muss was an den Params net stimmen doer so... ach ich weiß es net FLOSOFT!!
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
013
11.02.2006, 01:03 Uhr
Adil



also, das ist jetz der code für das austeilen der karten??

Adil
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
014
11.02.2006, 01:17 Uhr
Spacelord
Hoffnungsloser Fall



Zitat von Adil:
also, das ist jetz der code für das austeilen der karten??

Adil


Ohne Worte....
--
.....Ich mach jetzt nämlich mein Jodeldiplom.Dann hab ich endlich was Eigenes.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
015
11.02.2006, 01:48 Uhr
Adil



ich bin doch erst anfänger man
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
016
11.02.2006, 14:14 Uhr
xXx
Devil


das ist der Code zum Laden der cards.dll in einen Handle m_hCardsDLL usw.

Guck dir doch einfach mal an, wie die FUnktionen heißen... dann fällt dir auf, das deine Frage ziemlich daneben war
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
017
11.02.2006, 14:22 Uhr
xXx
Devil


So... da waren nur kleine Fehler drinne... bis auf das da jetzt noch nicht alles sauber am ende gelöscht wird funzt es


C++:
#pragma once

#include <windows.h>

#define CS_FACEUP            0    // Draw card face up
#define CS_FACEDOWN            1    // Draw card face down
#define CS_HILITE            2    // Same as FaceUp except drawn inverted
#define CS_GHOST            3    // Draw a ghost card -- for ace piles
#define CS_REMOVE            4    // draw background specified by color
#define CS_INVISIBLE_GHOST    5    // ?
#define CS_DECKX            6    // Draw X
#define CS_DECKO            7    // Draw O

enum eSUIT
{
    CLUBS   = 0,
    DIAMOND = 1,
    HEARTS  = 2,
    SPADES  = 3
};

enum eRANK
{
    ACE   = 0,
    TWO   = 1,
    THREE = 2,
    FOUR  = 3,
    FIVE  = 4,
    SIX   = 5,
    SEVEN = 6,
    EIGHT = 7,
    NINE  = 8,
    TEN   = 9,
    JACK  = 10,
    QUEEN = 11,
    KING  = 12
};

typedef bool (__stdcall*cdtInit)(int *, int *);
typedef void (__stdcall*cdtTerm)(void);
typedef bool (__stdcall*cdtDraw)(HDC, int x, int y, int iCard, int iMode, DWORD dwColor);
typedef bool (__stdcall*cdtDrawExt)(HDC, int x, int y, int dx, int dy, int iCard, int iMode, DWORD dwColor);
typedef bool (__stdcall*cdtAnimate)(HDC hdc, int iCardBack, int x, int y, int iFrame);

class CCardsDLL
{
public:
    CCardsDLL(void);
    ~CCardsDLL(void);

public:
    HWND            m_hWnd;                // Main - HWND
    ::HINSTANCE__*    m_hCardsDll;        // Handle (cards.dll)
    bool            m_bIsLoaded;

public:
    bool            Init(void);
    void            Destroy(void);
    bool            drawCard(HDC hdc, int x, int y, int iCard, int iMode, DWORD dwColor);
    bool            drawCardBack(HDC hdc, int x, int y, int iCard);
    bool            drawAnimatedBack(HDC hdc, int x, int y, int iCard, int iFrame);
    bool            drawInvertedCard(HDC hdc, int x, int y, int iCard);
    bool            drawEmptyCard(HDC hdc, int x, int y, DWORD dwColor);
    bool            drawExtrudedCard(HDC hdc, int x, int y, int dx, int dy, int iCard, int iMode, DWORD dwColor);

    static eSUIT    getSuit(int iCard);
    static eRANK    getRank(int iCard);
};





C++:
#include ".\cardsdll.h"

cdtInit        myCdtInit        = NULL;
cdtDraw        myCdtDraw        = NULL;
cdtDrawExt    myCdtDrawExt    = NULL;
cdtTerm        myCdtTerm        = NULL;
cdtAnimate    myCdtAnimate    = NULL;


CCardsDLL::CCardsDLL(void)
{
    m_hCardsDll = ::LoadLibrary("cards.dll");

    if(m_hCardsDll == NULL)
    {
        ::MessageBox(NULL, "Unable to load library.", "Error", MB_OK | MB_ICONERROR);
    }
    else
    {
        myCdtInit        = reinterpret_cast<cdtInit>(::GetProcAddress(m_hCardsDll, "cdtInit"));
        myCdtDraw        = reinterpret_cast<cdtDraw>(::GetProcAddress(m_hCardsDll, "cdtDraw"));
        myCdtDrawExt    = reinterpret_cast<cdtDrawExt>(::GetProcAddress(m_hCardsDll, "cdtDrawExt"));
        myCdtTerm        = reinterpret_cast<cdtTerm>(::GetProcAddress(m_hCardsDll, "cdtTerm"));
        myCdtAnimate    = reinterpret_cast<cdtAnimate>(::GetProcAddress(m_hCardsDll, "cdtAnimate"));

        if(myCdtInit == NULL || myCdtDraw == NULL || myCdtDrawExt == NULL || myCdtTerm == NULL /*|| myCdtAnimate == NULL*/)
        {
            m_bIsLoaded = false;
            ::MessageBox(NULL, "There is an error!", "Error", MB_OK | MB_ICONERROR);
            ::FreeLibrary(m_hCardsDll);
        }
        else
        {
            m_bIsLoaded = true;
        }
    }
}

bool CCardsDLL::Init(void)
{
    if(m_bIsLoaded)
    {
        int iWidth    = 71;
        int iHeight    = 95;
        if(!::myCdtInit(&iWidth, &iHeight))
        {
            ::MessageBox(NULL, "Fehler beim Initialisieren der Spielkarten!", "Fehler", MB_OK | MB_ICONERROR);
            return false;
        }
    }
    else
    {
        return m_bIsLoaded;
    }
}

CCardsDLL::~CCardsDLL(void)
{
    Destroy();
}


void CCardsDLL::Destroy(void)
{
    ::myCdtTerm();
    ::FreeLibrary(m_hCardsDll);
}

bool CCardsDLL::drawCard(HDC hdc, int x, int y, int iCard, int iMode, DWORD dwColor)
{
    return ::myCdtDraw(hdc, x, y, iCard, iMode, dwColor);                
}

bool CCardsDLL::drawCardBack(HDC hdc, int x, int y, int iCard)
{
    return ::myCdtDraw(hdc, x, y, iCard, CS_FACEDOWN, 0);                
}

bool CCardsDLL::drawAnimatedBack(HDC hdc, int x, int y, int iCard, int iFrame)
{
    return ::myCdtAnimate(hdc, iCard, x, y, iFrame );
}

bool CCardsDLL::drawInvertedCard(HDC hdc, int x, int y, int iCard)
{
    return ::myCdtDraw(hdc, x, y, iCard, CS_HILITE, 0 );                
}

bool CCardsDLL::drawEmptyCard(HDC hdc, int x, int y, DWORD dwColor)
{
    return ::myCdtDraw(hdc, x, y, 1, CS_GHOST, dwColor);            
}

bool CCardsDLL::drawExtrudedCard(HDC hdc, int x, int y, int dx, int dy, int iCard, int iMode, DWORD dwColor)
{
    return ::myCdtDrawExt(hdc, x, y, dx, dy, iCard, iMode, dwColor);
}

eSUIT CCardsDLL::getSuit(int iCard)
{
    int iSuit = iCard % 4;
    
    return (eSUIT)iSuit;
}

eRANK CCardsDLL::getRank(int iCard)
{
    int iRank = iCard / 4;
    
    return (eRANK)iRank;
}

 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
018
11.02.2006, 17:43 Uhr
Adil



cool vielen Dank,..ich werde mich jetzt richtig damit auseunandersetzen und hoffen dass keine dummen fragen merh folgen

Adil
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
019
11.02.2006, 19:05 Uhr
xXx
Devil


Achja... man sollte void Destroy(void); besser protected machen... da es schon von dem Destruktor automatisch aufgerufen wird und man sonnst in versuchung kommt die Funktion von außen aufzurufen...


Ups, noch was vergessen wenn man aus den enums einfach defines macht, kann man auch die benutzen und muss nicht deren Wert den funktionen übergeben...

Dieser Post wurde am 11.02.2006 um 19:07 Uhr von xXx editiert.
 
Profil || Private Message || Suche Download || Zitatantwort || Editieren || Löschen || IP
Seiten: [ 1 ] > 2 < [ 3 ]     [ C / C++ (WinAPI, Konsole) ]  


ThWBoard 2.73 FloSoft-Edition
© by Paul Baecher & Felix Gonschorek (www.thwboard.de)

Anpassungen des Forums
© by Flo-Soft (www.flo-soft.de)

Sie sind Besucher: