Accueil > > > CLASSE POUR UTILISER CARDS.DLL FACILEMENT
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);
}
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
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
|
Derniers Blogs
[WF4] POURQUOI UTILISER LE CONTENTPRESENTER DANS L'ACTIVITYDESIGNER?[WF4] POURQUOI UTILISER LE CONTENTPRESENTER DANS L'ACTIVITYDESIGNER? par JeremyJeanson
Vous avez peut être remarqué dans les samples WF4 ou dans mon dernier post qu'afin d'appliquer des Template sur un ActivityDesigner on utilise un ContentPresenter . Mais les plus observateurs auront aussi remarqué que l'ActivityDesigner à des propriétés T...
Cliquez pour lire la suite de l'article par JeremyJeanson [MIX 2010] - TELECHARGEZ INTERNET EXPLORER 9 EN PREVIEW ![MIX 2010] - TELECHARGEZ INTERNET EXPLORER 9 EN PREVIEW ! par redo
La Preview de Windows Explorer 9 est maintenant disponible à l'adresse suivante : http://ie.microsoft.com/testdrive/ Cette version ne nécessite pas un redémarrage de votre machine pour être exploitée . Cette version est fonctionnelle mais reste cependant ...
Cliquez pour lire la suite de l'article par redo [MIX 2010] - KEYNOTE DAY 2 ONLINE : WINDOWS INTERNET EXPLORER 9, JQUERY, ODATA ET DALLAS CTP2 ![MIX 2010] - KEYNOTE DAY 2 ONLINE : WINDOWS INTERNET EXPLORER 9, JQUERY, ODATA ET DALLAS CTP2 ! par redo
Dans la lignée du premier keynote, retrouvez la vidéo du second keynote en ligne : Visionnez la vidéo à l'url suivante : http://www.microsoft.com/presspass/events/mix/VideoGallery.aspx Vous y retrouverez ainsi les speakers Scott Guthrie, Dean Hachamovitch...
Cliquez pour lire la suite de l'article par redo [MIX 2010] - RETOUR D'EXPéRIENCE DéVELOPPEMENT SEESMIC SUR WINDOWS PHONE 7[MIX 2010] - RETOUR D'EXPéRIENCE DéVELOPPEMENT SEESMIC SUR WINDOWS PHONE 7 par redo
En avant première, Loic le retour d'expérience de Loïc Le Meur du portage de l'application http://seesmic.com/ sur plateforme Windows Phone 7 . c'était d'ailleurs une des rares opportunités de tester, voir toucher le nouveau device . voyez par vous-même :...
Cliquez pour lire la suite de l'article par redo [MIX 2010] - LE KEYNOTE DAY 1 DISPONIBLE ONLINE ![MIX 2010] - LE KEYNOTE DAY 1 DISPONIBLE ONLINE ! par redo
Si tout comme moi, vous avez manqué de peu le premier keynote du Microsoft Mix 2010, je vous invite à prendre deux heure et le consulter ci-dessous . Visionnez le Keynote à l'url suivante : http://www.microsoft.com/Presspass/events/mix/videoGallery.aspx?c...
Cliquez pour lire la suite de l'article par redo
Logiciels
Xilisoft Convertisseur Vidéo Ultimate (5.1.39.0305)XILISOFT CONVERTISSEUR VIDéO ULTIMATE (5.1.39.0305)Xilisoft Convertisseur Vidéo Ultimate est un outil puissant de conversion vidéo, facile à utilise... Cliquez pour télécharger Xilisoft Convertisseur Vidéo Ultimate Xilisoft DVD Ripper Ultimate (5.0.64.0304)XILISOFT DVD RIPPER ULTIMATE (5.0.64.0304)Xilisoft DVD Ripper Ultimate est un logiciel excellent pour copier et convertir DVD vers presque ... Cliquez pour télécharger Xilisoft DVD Ripper Ultimate Rigs of Rods (63.3)RIGS OF RODS (63.3)c'est un jeu de multi-simulation camions,autobus voitures, avions, bateaux, hélicoptère avec défo... Cliquez pour télécharger Rigs of Rods Konvertor (4.00)KONVERTOR (4.00)Le logiciel est un gestionnaire multimedia affichant, jouant et convertissant plus de 2000 format... Cliquez pour télécharger Konvertor
|