|
Trouver une ressource
Vous ne trouvez pas de réponse à votre problème ? Alors posez la question dans le forum. Souvenez-vous qu'il n'y a jamais de question bête, mais rester dans l'ignorance parce que l'on n'ose pas poser une question, ça c'est une erreur !
CLASSE POUR UTILISER CARDS.DLL FACILEMENT
Information sur la source
Description
Il s'agit d'une classe très simple qui permet une utilisation simplifiée et facile de la librairie Cards.dll.
Source
- // MyCards.h
-
- /*****************************************
-
- MyCards : Classe permettant d'utiliser facilement la librairie Cards.dll
-
- Guillaume Bourgeois ( 14/06/06 )
-
- *****************************************/
-
- #include "windows.h"
-
- #define CLUBS 0
- #define DIAMONDS 1
- #define HEARTS 2
- #define SPADES 3
-
- #define ACE 0
- #define TWO 1
- #define THREE 2
- #define FOUR 3
- #define FIVE 4
- #define SIX 5
- #define SEVEN 6
- #define EIGHT 7
- #define NINE 8
- #define TEN 9
- #define JACK 10
- #define QUEEN 11
- #define KING 12
-
- #define CS_CROSSHATCH 53
- #define CS_WEAVE1 54
- #define CS_WEAVE2 55
- #define CS_ROBOT 56
- #define CS_FLOWERS 57
- #define CS_VINE1 58
- #define CS_VINE2 59
- #define CS_FISH1 60
- #define CS_FISH2 61
- #define CS_SHELLS 62
- #define CS_CASTLE 63
- #define CS_ISLAND 64
- #define CS_CARDHAND 65
- #define CS_UNUSED 66
- #define CS_THE_X 67
- #define CS_THE_O 68
-
- #define MAKE_CARD_VALUE(Face, Suit) (Face * 4 + Suit)
- // Faces : 0 = Ace, 1 = Two , ... 10 = Jack, 11 = Queen, 12 = King.
- // Suit : 0 = Clubs, 1 = Diamond, 2 = Heart, 3 = Spades
-
- typedef BOOL (WINAPI *pfcdtInit)(int *, int *);
- typedef BOOL (WINAPI *pfcdtDraw)(HDC, int x, int y, int card, int type, DWORD color);
- typedef BOOL (WINAPI *pfcdtDrawEx)(HDC, int x, int y, int dx, int dy, int card, int type, DWORD color);
- typedef BOOL (WINAPI *pfcdtAnimate)(HDC hdc, int cardback, int x, int y, int state);
- typedef void (WINAPI *pfcdtTerm) (void);
-
- class MyCards
- {
- public:
- MyCards(); //Constructeur
- ~MyCards(); //Destructeur
-
- private:
-
- bool InitCardsDll(void);
-
- HMODULE hCardDll;
-
- pfcdtInit cdtInit;
- pfcdtDraw cdtDraw;
- pfcdtDrawEx cdtDrawEx;
- pfcdtAnimate cdtAnimate;
- pfcdtTerm cdtTerm;
-
- public:
- bool SetDefaultCardSize(int Height, int Width);
-
- bool DrawCard(HDC hDC, int x, int y, int CardValue, int Type, DWORD Color=0x00FFFFFF);
- bool DrawCard(HDC hDC, POINT Position, int CardValue, int Type, DWORD Color=0x00FFFFFF);
- bool DrawCard(HDC hDC, int x, int y, int Height, int Width, int CardValue, int Type, DWORD Color=0x00FFFFFF);
- bool DrawCard(HDC hDC, POINT Position, int Height, int Width, int CardValue, int Type, DWORD Color=0x00FFFFFF);
- bool DrawCard(HDC hDC, RECT Position, int CardValue, int Type, DWORD Color=0x00FFFFFF);
- // To make a card value use MAKE_CARD_VALUE(Face,Suit)
- // Type = 0 -> Front Face
- // Type = 1 -> Back face
- // Type = 3 -> Front Face ( Inverted colors )
-
- };
-
-
- /*************************************************************
- **************************************************************
- **************************************************************
- **************************************************************
- **************************************************************/
-
- #include "MyCards.h"
-
- MyCards::MyCards()
- {
- if ( !InitCardsDll() )
- ::MessageBox(0,"Unable to load Cards.dll","Error",MB_ICONERROR);
- SetDefaultCardSize(30,20);
- }
- MyCards::~MyCards()
- {
- cdtTerm();
- ::FreeLibrary(hCardDll);
- }
- bool MyCards::InitCardsDll(void)
- {
- hCardDll = ::LoadLibrary("cards.dll");
-
- if(hCardDll == 0)
- return 0;
-
- cdtInit = (pfcdtInit) GetProcAddress(hCardDll, "cdtInit");
- cdtDraw = (pfcdtDraw) GetProcAddress(hCardDll, "cdtDraw");
- cdtDrawEx = (pfcdtDrawEx) GetProcAddress(hCardDll, "cdtDrawExt");
- cdtAnimate = (pfcdtAnimate) GetProcAddress(hCardDll, "cdtAnimate");
- cdtTerm = (pfcdtTerm) GetProcAddress(hCardDll, "cdtTerm");
-
- return 1;
- }
- bool MyCards::SetDefaultCardSize(int Height, int Width)
- {
- return cdtInit(&Height,&Width);
- }
- bool MyCards::DrawCard(HDC hDC, int x, int y, int CardValue, int Type, DWORD Color)
- {
- return cdtDraw(hDC,x,y,CardValue,Type,Color);
- }
- bool MyCards::DrawCard(HDC hDC, POINT Position, int CardValue, int Type, DWORD Color)
- {
- return cdtDraw(hDC,Position.x,Position.y,CardValue,Type,Color);
- }
- bool MyCards::DrawCard(HDC hDC, int x, int y, int Height, int Width, int CardValue, int Type, DWORD Color)
- {
- return cdtDrawEx(hDC,x,y,Height,Width,CardValue,Type,Color);
- }
- bool MyCards::DrawCard(HDC hDC, POINT Position, int Height, int Width, int CardValue, int Type, DWORD Color)
- {
- return cdtDrawEx(hDC,Position.x,Position.y,Height,Width,CardValue,Type,Color);
- }
- bool MyCards::DrawCard(HDC hDC, RECT Position, int CardValue, int Type, DWORD Color)
- {
- return cdtDrawEx(hDC,Position.left,Position.top,
- (Position.right-Position.left),(Position.bottom-Position.top),CardValue,Type,Color);
- }
// MyCards.h
/*****************************************
MyCards : Classe permettant d'utiliser facilement la librairie Cards.dll
Guillaume Bourgeois ( 14/06/06 )
*****************************************/
#include "windows.h"
#define CLUBS 0
#define DIAMONDS 1
#define HEARTS 2
#define SPADES 3
#define ACE 0
#define TWO 1
#define THREE 2
#define FOUR 3
#define FIVE 4
#define SIX 5
#define SEVEN 6
#define EIGHT 7
#define NINE 8
#define TEN 9
#define JACK 10
#define QUEEN 11
#define KING 12
#define CS_CROSSHATCH 53
#define CS_WEAVE1 54
#define CS_WEAVE2 55
#define CS_ROBOT 56
#define CS_FLOWERS 57
#define CS_VINE1 58
#define CS_VINE2 59
#define CS_FISH1 60
#define CS_FISH2 61
#define CS_SHELLS 62
#define CS_CASTLE 63
#define CS_ISLAND 64
#define CS_CARDHAND 65
#define CS_UNUSED 66
#define CS_THE_X 67
#define CS_THE_O 68
#define MAKE_CARD_VALUE(Face, Suit) (Face * 4 + Suit)
// Faces : 0 = Ace, 1 = Two , ... 10 = Jack, 11 = Queen, 12 = King.
// Suit : 0 = Clubs, 1 = Diamond, 2 = Heart, 3 = Spades
typedef BOOL (WINAPI *pfcdtInit)(int *, int *);
typedef BOOL (WINAPI *pfcdtDraw)(HDC, int x, int y, int card, int type, DWORD color);
typedef BOOL (WINAPI *pfcdtDrawEx)(HDC, int x, int y, int dx, int dy, int card, int type, DWORD color);
typedef BOOL (WINAPI *pfcdtAnimate)(HDC hdc, int cardback, int x, int y, int state);
typedef void (WINAPI *pfcdtTerm) (void);
class MyCards
{
public:
MyCards(); //Constructeur
~MyCards(); //Destructeur
private:
bool InitCardsDll(void);
HMODULE hCardDll;
pfcdtInit cdtInit;
pfcdtDraw cdtDraw;
pfcdtDrawEx cdtDrawEx;
pfcdtAnimate cdtAnimate;
pfcdtTerm cdtTerm;
public:
bool SetDefaultCardSize(int Height, int Width);
bool DrawCard(HDC hDC, int x, int y, int CardValue, int Type, DWORD Color=0x00FFFFFF);
bool DrawCard(HDC hDC, POINT Position, int CardValue, int Type, DWORD Color=0x00FFFFFF);
bool DrawCard(HDC hDC, int x, int y, int Height, int Width, int CardValue, int Type, DWORD Color=0x00FFFFFF);
bool DrawCard(HDC hDC, POINT Position, int Height, int Width, int CardValue, int Type, DWORD Color=0x00FFFFFF);
bool DrawCard(HDC hDC, RECT Position, int CardValue, int Type, DWORD Color=0x00FFFFFF);
// To make a card value use MAKE_CARD_VALUE(Face,Suit)
// Type = 0 -> Front Face
// Type = 1 -> Back face
// Type = 3 -> Front Face ( Inverted colors )
};
/*************************************************************
**************************************************************
**************************************************************
**************************************************************
**************************************************************/
#include "MyCards.h"
MyCards::MyCards()
{
if ( !InitCardsDll() )
::MessageBox(0,"Unable to load Cards.dll","Error",MB_ICONERROR);
SetDefaultCardSize(30,20);
}
MyCards::~MyCards()
{
cdtTerm();
::FreeLibrary(hCardDll);
}
bool MyCards::InitCardsDll(void)
{
hCardDll = ::LoadLibrary("cards.dll");
if(hCardDll == 0)
return 0;
cdtInit = (pfcdtInit) GetProcAddress(hCardDll, "cdtInit");
cdtDraw = (pfcdtDraw) GetProcAddress(hCardDll, "cdtDraw");
cdtDrawEx = (pfcdtDrawEx) GetProcAddress(hCardDll, "cdtDrawExt");
cdtAnimate = (pfcdtAnimate) GetProcAddress(hCardDll, "cdtAnimate");
cdtTerm = (pfcdtTerm) GetProcAddress(hCardDll, "cdtTerm");
return 1;
}
bool MyCards::SetDefaultCardSize(int Height, int Width)
{
return cdtInit(&Height,&Width);
}
bool MyCards::DrawCard(HDC hDC, int x, int y, int CardValue, int Type, DWORD Color)
{
return cdtDraw(hDC,x,y,CardValue,Type,Color);
}
bool MyCards::DrawCard(HDC hDC, POINT Position, int CardValue, int Type, DWORD Color)
{
return cdtDraw(hDC,Position.x,Position.y,CardValue,Type,Color);
}
bool MyCards::DrawCard(HDC hDC, int x, int y, int Height, int Width, int CardValue, int Type, DWORD Color)
{
return cdtDrawEx(hDC,x,y,Height,Width,CardValue,Type,Color);
}
bool MyCards::DrawCard(HDC hDC, POINT Position, int Height, int Width, int CardValue, int Type, DWORD Color)
{
return cdtDrawEx(hDC,Position.x,Position.y,Height,Width,CardValue,Type,Color);
}
bool MyCards::DrawCard(HDC hDC, RECT Position, int CardValue, int Type, DWORD Color)
{
return cdtDrawEx(hDC,Position.left,Position.top,
(Position.right-Position.left),(Position.bottom-Position.top),CardValue,Type,Color);
}
Fichier Zip
Pour les "Membres Club", vous pouvez télécharger directement un fichier contenu dans le zip sans télécharger le zip en entier !
Télécharger le zip
Historique
- 16 juin 2006 16:43:42 :
- - Ajouté le HDC en argument aux fonctions.
- Enlevé un pointeur inutile :P
- 16 juin 2006 21:58:29 :
- Enlevé la fonction GetDC() qui n'était même plus définie :P, puis ajouter une surcharge a DrawCard().
Sources du même auteur
Sources de la même categorie
Sources en rapport avec celle ci
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
lecteur de carte [ par cyril ]
Avec un lecteur de carte typeCKL2000 modèle ECR8 peux-on changer le programme pour lire des cartes bancaire ou des cartes de code.Merci pour une répon
Cartes à jouer [ par oxy ]
Est-ce que qqun connaît une librairie premettant d'utiliser des cartes à jouer?Merci d'avance pour vos réponses!
Récupérer une adresse IP. ( à partir de 2 cartes réseaux. ) [ par pcayrol ]
Ma config : un PC avec deux cartes réseaux. Chaque carte a son adresse IP.Avec la fonction gethostbyname je recupere un pointeur HOSTENT qui pointe su
Appler une structure dans une fonction ... [ par eldered ]
Salut !!Alors mon pb est le suivant :J'ai cré une fonction qui me permet un certain nombre de chose en autre trouver si un element appartient a un tab
Probleme de probalitié de pioche [ par Kirbyboss ]
Bonjour a tous.J'aimerais faire un programme permettant de connaitre le nombre de chance de piocher un certain nombre de carte precise dans un paquet
Jeu de Mémoire [ par lacousine ]
Bonjour,je suis sur la conception d'un jeu de mémoire, qui consiste à trouver 2 cartes pareilles. Mon programme affiche 16 cartes, dont 8 trouvées au
Affichage, graphisme fenetre en C/C++ [ par sdrthomas ]
Bonjour bonjour,Voilà je suis en école d'ingé et ai reçu des cours de C++ puis C. Le problème c'est que tout ça est resté très terre à terre. Je pense
creation d'un uno en C/C++....grand besoin d'aide...merci d'avance [ par celine11 ]
Au secours!!!Je souhaite créer un uno en langage C mais à chaque creation de nouvelles fonctions, rien ne marche, je commence à saturer. Voici la desc
programme de classification avec les cartes de Kohonen (SOM) en C++ [ par malikach ]
Salut,je cherche le code du programme de classification avec les cartes de Kohonen en C++, est ce que vous pouvez m'aider?merci infiniment
Faire des cartes pour jeu [ par gimli123 ]
Salut tout le monde BONNE ANNEE !!!!Bon alors heu voila ma question ^_^Par quel procédé on fait pour faire des petites cartes pour des niveaux dans un
|
Téléchargements
Logiciels à télécharger sur le même thème :
Comparez les prix Nouvelle version
|