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
[WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning
|