Trouver une ressource (Nouvelle version du moteur, plus rapide & pertinent, essayez le !)
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 de la même categorie
Commentaires
Discussions en rapport avec ce code source
|
CalendriCode
| | | L | M | M | J | V | S | D |
| | 1 | 2 | 3 | 4 | 5 | 6 |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | | | |
|
Téléchargements
Logiciels à télécharger sur le même thème :
|