cards.dll apprendre à utiliser un dll
-
- Messages : 1
- Inscription : ven. 26/juil./2019 12:16
cards.dll apprendre à utiliser un dll
Est-ce que quelqu'un serait assez gentil pour nous montrer comment utiliser cards.dll et faire apparaitre des cartes à l'écran....Je veux juste m'amuser et apprendre....ou sont les ressources sur les dll, comment programmer des jeux, etc.
Yves
Yves
Re: cards.dll apprendre à utiliser un dll
Au cas ou, bonjour.
- Il y a un YvesRossignol sur le forum et là apparaît un YvesRossignol1 ? => Explain ?
- Ensuite c'est qui "nous" ?
- Ensuite ce message va dans la section débutant.. Je le déplace
- Enfin, cards.dll d'ou ?
Bref.. Bot ou pas bot ?
- Il y a un YvesRossignol sur le forum et là apparaît un YvesRossignol1 ? => Explain ?
- Ensuite c'est qui "nous" ?
- Ensuite ce message va dans la section débutant.. Je le déplace
- Enfin, cards.dll d'ou ?
Bref.. Bot ou pas bot ?
~~~~Règles du forum ~~~~
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
⋅.˳˳.⋅ॱ˙˙ॱ⋅.˳Ar-S ˳.⋅ॱ˙˙ॱ⋅.˳˳.⋅
W11x64 PB 6.x
Section HORS SUJET : ICI
LDV MULTIMEDIA : Dépannage informatique & mes Logiciels PB
UPLOAD D'IMAGES : Uploader des images de vos logiciels
- microdevweb
- Messages : 1800
- Inscription : mer. 29/juin/2011 14:11
- Localisation : Belgique
Re: cards.dll apprendre à utiliser un dll
Bonjour,
d'abord trouver une dll qui fonctionne
http://www.dlldownloader.com/cards-dll/ ... 98aa709d4/
voici une code pour lister les fonctions de la dll
Voici le résulta
ensuite utilise Resultat = CallFunction(#Bibliotheque, NomFonction$ [,Parametre1 [, Parametre2...]])
lien vers l'utilisation des fonctions (que je connais pas perso)
http://www.catch22.net/tuts/win32/using-cards-dll-api#
d'abord trouver une dll qui fonctionne
http://www.dlldownloader.com/cards-dll/ ... 98aa709d4/
voici une code pour lister les fonctions de la dll
Code : Tout sélectionner
#LIBRARY = 0
path.s = GetCurrentDirectory()+"cards.dll"
OpenLibrary(#LIBRARY,path)
If ExamineLibraryFunctions(#LIBRARY)
While NextLibraryFunction()
Debug LibraryFunctionName()
Wend
EndIf
Code : Tout sélectionner
WEP
cdtAnimate
cdtDraw
cdtDrawExt
cdtInit
cdtTerm
lien vers l'utilisation des fonctions (que je connais pas perso)
http://www.catch22.net/tuts/win32/using-cards-dll-api#
Windows 10 64 bits PB: 5.70 ; 5.72 LST
Work at Centre Spatial de Liège
Work at Centre Spatial de Liège
Re: cards.dll apprendre à utiliser un dll
il y a un vieux post dans annonces qui parle de ça.
https://www.purebasic.fr/french/viewtop ... =cards.dll
https://www.purebasic.fr/french/viewtop ... =cards.dll
Re: cards.dll apprendre à utiliser un dll
Bonjour,
Bon bot ou pas bot, je me suis pencher sur le sujet. Mon but étant de pouvoir afficher simplement les cartes une par une.
Voici le résultat en code :
Ps: Je sais que l'on peut optimisé pour la recherche des cartes, mais j'ai voulu faire très basic
Je suis d’ailleurs tomber sur un bon site en français qui explique bien toutes les démarches. Voici le lien au cas ou
La Dll est d'ailleurs disponible sur son site ou sur internet et même dans votre Windows dans le system32. Pensez a modifier le chemin de la Dll dans le code Ligne 43
Voili voilou.
@++
Bon bot ou pas bot, je me suis pencher sur le sujet. Mon but étant de pouvoir afficher simplement les cartes une par une.
Voici le résultat en code :
Code : Tout sélectionner
; /////////////////////////////////////////////////////
; // Autor : Venom //
; // Project name : Afficher carte (cards.dll) //
; // Version : V 1.0 //
; // Compilator : PureBasic V5.71 //
; // Date : 27/02/2020 //
; // OS : Windows 10 //
; /////////////////////////////////////////////////////
; La DLL "cards.dll" utilise cinq fonctions:
; Fonction Description
; -------- ------------
; cdtAnimate Anime le dos des cartes. Elle fonctionne uniquement avec des cartes de taille normal dessinés avec la fonction "cdtDraw".
; cdtDraw Dessine une carte à jouer de taille standard (x = 71 y = 96).
; cdtDrawExt Identique à la fonction "cdtDraw". La seule différence est que cette fonction possède deux paramètres suplémentaires qui vous permetteront d'indiquer la taille (largeur et hauteur) des cartes.
; cdtInit Initialise la DLL. Les deux paramètres permettent de récupèrer la largeur et la hauteur des cartes à jouer.
; cdtTerm Libère les ressources allouées.
;- Window Constants
Enumeration
#Window_0
EndEnumeration
;- Gadgets Constants
Enumeration
#Frame_0
#Combo
#Frame_Rendu
#Image_Rendu
#Card
EndEnumeration
; Chemin vers la Dll
Global CheminDll$ = "cards.dll"
; Variables
Global Dll_ID, HDC, TailleX, TailleY, Card
; Declaration des procedures
Declare CreationGadgets()
Declare RemplissageDesCombos()
Declare InitialisationDeLaDll()
Declare AffichageDeLaCarte()
; ///////////////////////////////////////////////
; /////////// Ouverture de la fenetre ///////////
; ///////////////////////////////////////////////
InitialisationDeLaDll()
If OpenWindow(#Window_0, 0, 0, 220, 200, "Afficher carte (cards.dll)", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
CreationGadgets()
RemplissageDesCombos()
AffichageDeLaCarte()
EndIf
; ///////////////////////////////////////////////
; /////////////////// Boucle ////////////////////
; ///////////////////////////////////////////////
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
Select EventGadget()
Case #Combo
AffichageDeLaCarte()
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
CloseLibrary(Dll_ID) ; Ferme la Dll et libère la mémoire associée
; ///////////////////////////////////////////////
; ///////////////// Procedures //////////////////
; ///////////////////////////////////////////////
Procedure CreationGadgets()
; Gadgets Frame + Combo
FrameGadget(#Frame_0, 10, 10, 200, 50, "Choix de la carte")
ComboBoxGadget(#Combo, 20, 27, 180, 20)
; Gadgets Image
FrameGadget(#Frame_Rendu, 65, 70, 91, 123, "Rendu")
EndProcedure
Procedure RemplissageDesCombos()
AddGadgetItem(#Combo, 0, "As de trèfle")
AddGadgetItem(#Combo, 1, "As de carreau")
AddGadgetItem(#Combo, 2, "As de coeur")
AddGadgetItem(#Combo, 3, "As de pique")
AddGadgetItem(#Combo, 4, "2 de trèfle")
AddGadgetItem(#Combo, 5, "2 de carreau")
AddGadgetItem(#Combo, 6, "2 de coeur")
AddGadgetItem(#Combo, 7, "2 de pique")
AddGadgetItem(#Combo, 8, "3 de trèfle")
AddGadgetItem(#Combo, 9, "3 de carreau")
AddGadgetItem(#Combo, 10, "3 de coeur")
AddGadgetItem(#Combo, 11, "3 de pique")
AddGadgetItem(#Combo, 12, "4 de trèfle")
AddGadgetItem(#Combo, 13, "4 de carreau")
AddGadgetItem(#Combo, 14, "4 de coeur")
AddGadgetItem(#Combo, 15, "4 de pique")
AddGadgetItem(#Combo, 16, "5 de trèfle")
AddGadgetItem(#Combo, 17, "5 de carreau")
AddGadgetItem(#Combo, 18, "5 de coeur")
AddGadgetItem(#Combo, 19, "5 de pique")
AddGadgetItem(#Combo, 20, "6 de trèfle")
AddGadgetItem(#Combo, 21, "6 de carreau")
AddGadgetItem(#Combo, 22, "6 de coeur")
AddGadgetItem(#Combo, 23, "6 de pique")
AddGadgetItem(#Combo, 24, "7 de trèfle")
AddGadgetItem(#Combo, 25, "7 de carreau")
AddGadgetItem(#Combo, 26, "7 de coeur")
AddGadgetItem(#Combo, 27, "7 de pique")
AddGadgetItem(#Combo, 28, "8 de trèfle")
AddGadgetItem(#Combo, 29, "8 de carreau")
AddGadgetItem(#Combo, 30, "8 de coeur")
AddGadgetItem(#Combo, 31, "8 de pique")
AddGadgetItem(#Combo, 32, "9 de trèfle")
AddGadgetItem(#Combo, 33, "9 de carreau")
AddGadgetItem(#Combo, 34, "9 de coeur")
AddGadgetItem(#Combo, 35, "9 de pique")
AddGadgetItem(#Combo, 36, "10 de trèfle")
AddGadgetItem(#Combo, 37, "10 de carreau")
AddGadgetItem(#Combo, 38, "10 de coeur")
AddGadgetItem(#Combo, 39, "10 de pique")
AddGadgetItem(#Combo, 40, "Valet (J) de trèfle")
AddGadgetItem(#Combo, 41, "Valet (J) de carreau")
AddGadgetItem(#Combo, 42, "Valet (J) de coeur")
AddGadgetItem(#Combo, 43, "Valet (J) de pique")
AddGadgetItem(#Combo, 44, "Dame (Q) de trèfle")
AddGadgetItem(#Combo, 45, "Dame (Q) de carreau")
AddGadgetItem(#Combo, 46, "Dame (Q) de coeur")
AddGadgetItem(#Combo, 47, "Dame (Q) de pique")
AddGadgetItem(#Combo, 48, "Roi (K) de trèfle")
AddGadgetItem(#Combo, 49, "Roi (K) de carreau")
AddGadgetItem(#Combo, 50, "Roi (K) de coeur")
AddGadgetItem(#Combo, 51, "Roi (K) de pique")
SetGadgetState(#Combo, 0) ; Selectionne le premier element de la ComboBox. (As de trèfle)
EndProcedure
Procedure InitialisationDeLaDll()
Dll_ID = OpenLibrary(#PB_Any, CheminDll$) ; Ouverture de la Dll
If Dll_ID > 0 ; On verifie bien que la Dll ce charge
CallFunction(Dll_ID, "cdtInit", @TailleX, @TailleY) ; cdtInit voir ligne 21. @TailleX, @TailleY est la taille de base des cartes
Else ; Sinon on affiche un message d'erreur
MessageRequester("Information", "Erreur. Cards.dll est introuvable." +#CRLF$+"Verifiez le chemin du fichier.", #PB_MessageRequester_Error)
End ; Et on quitte
EndIf
EndProcedure
Procedure AffichageDeLaCarte()
; HDC : ID dans lequel la carte sera dessiner.
; X,Y : Position de la carte à jouer en pixel. (0 x 0)
; Card : Numéro (appelé égalemnt ID) de la carte à jouer.
Card = GetGadgetState(#Combo) ; récupere l'ID séléctionner dans le ComboBox
If CreateImage(#Card, TailleX, TailleY)
HDC = StartDrawing(ImageOutput(#Card))
CallFunction(Dll_ID, "cdtDraw", HDC, 0, 0, Card) ; cdtDraw voir ligne 19.
StopDrawing()
EndIf
ImageGadget(#Image_Rendu, 75, 87, TailleX, TailleY, ImageID(#Card), 0) ; Affiche la carte
EndProcedure
Je suis d’ailleurs tomber sur un bon site en français qui explique bien toutes les démarches. Voici le lien au cas ou
La Dll est d'ailleurs disponible sur son site ou sur internet et même dans votre Windows dans le system32. Pensez a modifier le chemin de la Dll dans le code Ligne 43
Voili voilou.
@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
Re: cards.dll apprendre à utiliser un dll
Un tableau de toutes les cartes même le dos des cartes.
Attention au chemin de cards.dll
Mesa.
Attention au chemin de cards.dll
Code : Tout sélectionner
;
; This code is automatically generated by the FormDesigner.
; Manual modification is possible to adjust existing commands, but anything else will be dropped when the code is compiled.
; Event procedures needs to be put in another source file.
;
; EnableExplicit
Global Window_0
Global ScrollArea_0
Structure File
x.i
y.i
ImageID.i
ContainerID.i
ImageGadgetID.i
Text$
EndStructure
Global NewList File.File()
Declare ResizeGadgetsWindow_0()
Declare Affiche_cartes(type, debut, fin, x, y)
Procedure OpenWindow_0(x = 0, y = 0, width = 620, height = 400)
Window_0 = OpenWindow(#PB_Any, x, y, width, height, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_SizeGadget)
ScrollArea_0 = ScrollAreaGadget(#PB_Any, 10, 10, 600, 380, 780, 570, 1)
CloseGadgetList()
EndProcedure
Procedure ResizeGadgetsWindow_0()
Protected FormWindowWidth, FormWindowHeight
FormWindowWidth = WindowWidth(Window_0)
FormWindowHeight = WindowHeight(Window_0)
ResizeGadget(ScrollArea_0, 10, 10, FormWindowWidth - 20, FormWindowHeight - 20)
EndProcedure
Procedure Window_0_Events(event)
Select event
Case #PB_Event_SizeWindow
ResizeGadgetsWindow_0()
Case #PB_Event_CloseWindow
ProcedureReturn #False
Case #PB_Event_Menu
Select EventMenu()
EndSelect
Case #PB_Event_Gadget
Select EventGadget()
EndSelect
EndSelect
ProcedureReturn #True
EndProcedure
OpenWindow_0()
#card_dll=0
Define path.s = "cards.dll" ;GetCurrentDirectory()+
OpenLibrary(#card_dll,path)
;{ Liste les fonctions de la dll
; If ExamineLibraryFunctions(#card_dll)
; Debug CountLibraryFunctions(#card_dll)
;
; While NextLibraryFunction()
; Debug LibraryFunctionName()
; Debug LibraryFunctionAddress()
;
; Wend
; EndIf
;}
Prototype.i Proto_cdtAnimate(DC,Card,X,Y,Etat)
Prototype.i Proto_cdtDraw(DC, X,Y,Card,Typ, Color);:TColor
Prototype.i Proto_cdtDrawExt(DC, X,Y,CardWidth,CardHeight,Card,Typ,Color);:TColor
Prototype.i Proto_dtInit(Width,Height)
Prototype.i Proto_dtTerm()
;Prototype.i Proto_WEP(); si dll en 16 bits
Global cdtAnimate.Proto_cdtAnimate = GetFunction(#card_dll, "cdtAnimate")
Global cdtDraw.Proto_cdtDraw = GetFunction(#card_dll, "cdtDraw")
Global cdtDrawExt.Proto_cdtDrawExt = GetFunction(#card_dll, "cdtDrawExt")
Global cdtInit.Proto_dtInit = GetFunction(#card_dll, "cdtInit")
Global cdtTerm.Proto_dtTerm = GetFunction(#card_dll, "cdtTerm")
;{
; function cdtAnimate(DC:HDC;Card,X,Y,Etat:Integer):Integer; StdCall; external 'CARDS.DLL';
; function cdtDraw(DC:HDC; X,Y,Card,Typ:Integer; Color:TColor):Integer; StdCall; external 'CARDS.DLL';
; function cdtDrawExt(DC:HDC; X,Y,CardWidth,CardHeight,Card,Typ:Integer; Color:TColor):integer; StdCall; external 'CARDS.DLL';
; function cdtInit(var Width,Height:Integer):Integer; StdCall; external 'CARDS.DLL';
; function cdtTerm:Integer; StdCall; external 'CARDS.DLL';
; function cdtDraw(DC:HDC; X,Y,Card,Typ:Integer; Color:TColor):Integer;
;
; Paramètre
;
; Description
; DC
; Handle du contexte de périphérique dans lequel le tracé de la carte à jouer sera effectuée.
; X,Y
; Position de la carte à jouer en pixel.
; Card
; Numéro (appelé égalemnt ID) de la carte à jouer.
; Typ
; Type de la carte. LES valeurs possibles sont "0", "1" et "2" (permet d'inverser les couleurs).
; Si le paramètre "Typ" vaut "1", le paramètre "Card" de la fonction "cdtDraw" possèdent également quinze autres valeures qui sont : "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63", "64", "65", "67" et "68".
; On peut remarquer que la valeur "66" n'existe pas.
; Color
; Couleur de fond de la carte. Par défaut, cette couleur est blanche.
;
; Ce tableau récapitule LES valeurs possibles du paramètre "Card" de la fonction "cdtDraw".
; trefle carreau coeur pique
;
; As 0 1 2 3
;
;
; Roi 48 49 50 51
;
;
; LES images qui sont affichées au dos de la carte à jouer peuvent être différentes en fonction
;des versions de Windows et donc de la DLL.
;
; Astuce : Lorsque le paramètre "Typ" de la fonction "cdtDraw" vaut "1", vous pouvez alors changer
;la couleur de fond des 52 cartes à jouer (ainsi que pour le dos de la carte "53") grâce au
;paramètre"Color".
;}
; //Initialise la DLL
Global TailleCarteW,TailleCarteH
; CallFunction(Dll_ID, "cdtInit", @TailleCarteW, @TailleCarteH)
cdtInit(@TailleCarteW, @TailleCarteH)
; Debug TailleCarteW
; Debug TailleCarteH
; Afficher cartes
OpenGadgetList(ScrollArea_0)
Global n=GadgetWidth(ScrollArea_0)/(TailleCarteW)
Define x=0
Define y=0
Define c=0
; mode 0 is "draw face card"
; For modes 0 And 2, the resource ID uses this formula
; resource id equals ((((card number SHL 2) mod 0dh) plus ((card number And
; 3) times 0dh)) plus 1)
;{ type 0 et 2
; Dim tab(255)
; For i=0 To 255
; ; ((((card number SHL 2) mod 0dh) plus ((card number And 3) times 0dh)) plus 1)
; ; a=((((Mod(i << 2)), 13) + ((i & 3) * 13)) + 1)
; a=i << 2
; b=Mod(a,13)
; c=i & 3
; c=c*13
; d=b+c+1
; tab(i)=d
; Debug d
; Next i
; SortArray(tab(),#PB_Sort_Ascending )
; Debug "================================="
; For i=0 To 255
; Debug tab(i) ; tab rempli de 1 à 52
; Next i
;}
Define Card_Type=0
y=Affiche_cartes(Card_Type, 0, 61, x, y); au dessus de 61 ça bug
; mode 1 is "draw back"
Card_Type=1
x=0
y=y+TailleCarteH+20
y=Affiche_cartes(Card_Type, 0, 255, x, y)
; mode 2 is "draw highlighted face card"
Card_Type=2
x=0
y=y+TailleCarteH+20
y=Affiche_cartes(Card_Type, 0, 51, x, y)
; mode 3 is "draw empty card spot"
Card_Type=3
x=0
y=y+TailleCarteH+20
y=Affiche_cartes(Card_Type, 0, 53, x, y)
; mode 4 is "erase card"
Card_Type=4
x=0
y=y+TailleCarteH+20
y=Affiche_cartes(Card_Type, 0, 255, x, y)
; mode 5 is "draw empty card spot but doesnt paint background"
Card_Type=5
x=0
y=y+TailleCarteH+20
y=Affiche_cartes(Card_Type, 0, 53, x, y)
; mode 6 is "draw red X card"
Card_Type=6
x=0
y=y+TailleCarteH+20
y=Affiche_cartes(Card_Type, 0, 67, x, y)
; mode 7 is "draw green O card"
Card_Type=7
x=0
y=y+TailleCarteH+20
y=Affiche_cartes(Card_Type, 0, 68, x, y)
; ; mode 8 et + ? à essayer sur les dll plus récentes
; Card_Type=8
; x=0
; y=y+TailleCarteH+20
; y=Affiche_cartes(Card_Type, 0, 255, x, y)
;Fermeture de la dll
cdtTerm()
Define event
Repeat
event=WaitWindowEvent()
Select event
Case #PB_Event_SizeWindow
ResizeGadgetsWindow_0()
EndSelect
Until event=#PB_Event_CloseWindow
Procedure Affiche_cartes(type, debut, fin, x, y)
Protected HDC, hdcc, ok, marge, z, marge_legende,c, index
For z=debut To fin
HDC = CreateImage(#PB_Any, TailleCarteW, TailleCarteH);,32,#PB_Image_Transparent )
If HDC
AddElement(File())
File()\ImageID = HDC
; Debug hdc
hdcc=StartDrawing(ImageOutput(HDC))
ok=cdtDraw(hdcc,0,0,z,Type,#White)
; Debug ok
StopDrawing()
EndIf
marge =0
marge_legende=30
If ok
File()\x=x
File()\y=y
x=x+TailleCarteW+marge
c=c+1
If c>n-1
c=0
x=0
y=y+TailleCarteH+marge+marge_legende
EndIf
File()\ContainerID = ContainerGadget(#PB_Any, File()\x, File()\y, TailleCarteW, TailleCarteH+marge_legende, #PB_Container_Flat)
File()\ImageGadgetID=ImageGadget(#PB_Any, 0, 0, TailleCarteW, TailleCarteH, ImageID(File()\ImageID))
TextGadget(#PB_Any, 0, TailleCarteH, TailleCarteW,marge_legende, "Type: "+Str(type)+" n°"+Str(z),#PB_Text_Center)
CloseGadgetList()
; Update the Gadget states and refresh the display
;
index = ListIndex(File())
SetGadgetAttribute(ScrollArea_0, #PB_ScrollArea_InnerHeight, (index+1)*TailleCarteH + 10)
While WindowEvent(): Wend
EndIf
Next z
ProcedureReturn y
EndProcedure
;{Explication
; After finding OUT that certain things I did when coding cards.dll (such As
; studying the complete code IN a disassembler) mean that any code I write
; For it a potential "derivitave work", I have come up With a descrition that
; is (hopefully) detailed enough To enable someone Else With windows GDI
; programming experience To write cards.dll For wine but (hopefully) Not
; detailed enough To be considered a "derivitive work"
;
; The folowing files can be made available To whoever ends up working on
; cards.dll:
; 1.cards.spec, a ready made spec file For the dll
; 2.cards.rc, a RC file containing the card bitmaps (which are licenced under
; a licence that gave permission To use them) And also the card back bitmaps
; that were sent To me before (To whoever ends up working on this, feel free
; To modify the images If you dont like them :)
; 3.makefile.IN ready made For the dll
; AND 4.cards.h which contains the publicly documented Interface To cards.dll
; (which I pulled from various info documents found on the net)
; IANAL but I dont think that any of these could be claimed To be covered by
; that "derivitave work" thing, If they are, please do tell me.
;
; This document explains the workings of cards.dll (version 5.00.2134.1 from
; windows XP SP1)
;
; Cards.dll exports 7 different functions.
; These are:
; cdtInit
; cdtTerm
; cdtAnimate
; cdtDraw
; cdtDrawExt
; DllMain
; AND WEP
;
; cdtInit takes 2 INT * variables. It should Return TRUE If the initalization
; was sucessfull And FALSE If it was Not.
; It is a place To do any initalization you require (depending on For example
; If you want To preload the resource bitmaps Or whatever).
; It should Return the x And y size of the card bitmaps IN the 2 variables.
; For the cards I am using, the x size is 71 And the y size is 96 (which just
; happened To match up With the size of microsofts cards which is good)
;
; the main purpose of DllMain is To store the HINSTANCE of the cards.dll To
; use later when the bitmaps are loaded
;
; WEP is a holdover from when cards.dll was a 16 bit dll And doesnt actually
; need To be implemented (since its never called by 32 bit windows)
;
; cdtTerm is where you undo anything you did IN cdtInit (such As unloading
; any preloaded resources)
; It takes no parameters And returns nothing.
;
; cdtAnimate is supposed To handle animations For the card backs but since
; the backs we are using dont animate, it can just Return TRUE
; (hence why the resource file I wrote returns the windows XP version number
; since XP doesnt have animated backs either)
; As For parameters, it takes a HDC, an x And y position And a frame number
; (each individual microsoft back has a specific number of frames And
; applictions tend To hard-code these values)
;
; cdtDraw basicly calls cdtDrawExt passing the Default size of the card
; bitmaps As the x And y size parameters
;
; The real work is done IN cdtDrawExt
; This function takes:
; a HDC (For the screen window To draw the card on)
; an X positon And a Y position To draw the card at
; a card number (cards.h lists the different values)
; a mode number (again cards.h lists the different values)
; AND a RGB background color
; What the function does depends on the value of the mode.
; If the upper bit of md (which is an INT) is set, then it shouldnt save And
; resore the corner pixels (As explained below)
;
; modes greater than 7 should (As far As I can tell) do nothing.
; mode 0 is "draw face card"
; mode 1 is "draw back"
; mode 2 is "draw highlighted face card"
; mode 3 is "draw empty card spot"
; mode 4 is "erase card"
; mode 5 is "draw empty card spot but doesnt paint background"
; mode 6 is "draw red X card"
; AND mode 7 is "draw green O card"
;
; all modes use the same "drawing logic" except For mode 4 which doesnt draw
; any bitmap.
;
; You need a resource ID And a raster OP To do the drawing
; For modes 0 And 2, the resource ID uses this formula
; resource id equals ((((card number SHL 2) mod 0dh) plus ((card number And
; 3) times 0dh)) plus 1)
; For mode 1, the resource ID is just the card number
; For modes 3 And 5, the resource ID is 53 (the resource ID of the empty card
; spot graphic, also the contant hb IN cards.h)
; For mode 1, the resource ID is just the card number
; For mode 6, the resource ID is 67 (the resource ID of the card With the red
; X on a green background graphic, also the contant xb IN cards.h)
; For mode 7, the resource ID is 68 (the resource ID of the card With the
; green O on a green background graphic, also the contant ob IN cards.h)
; AND mode 4 doesnt use any ID since it doesnt draw anything.
;
; For the raster OP, all modes use SRCCOPY except For:
; mode 2 which uses NOTSRCCOPY
; AND modes 3 And 5 which use SRCAND
;
; Also, If the mode is 0, the background color is set To white (0xFFFFFF)
; before drawing. And after drawing, If the card is a red card (resource IDs
; 0x0E To ox17 And 0x1B To 0x24), it paints over the boarders of the card
; using PatBlt And the BLACKNESS rasterop.
;
; If the mode is 3 Or 4, it creates a solid brush using the background color,
; uses SetBrushOrgEx To set the brush origin To the screen DC origin And then
; uses PatBlt To paint over the area of the card using PATCOPY.
;
; If the mode has the top bit clear (As explained above) And the size matches
; With the Default card size, before drawing, it saves the corner pixels of
; the cards (the card bitmaps I am using have one pixel IN each corner) And
; then Restore them after drawing.
;
; To do the actual drawing, you need To load the bitmap resource INTO memory
; AND load the resulting HBITMAP INTO a memory DC.
; You also need To set the background color of the screen DC To whatever was
; passed in (unless its mode 0, IN which Case its 0xFFFFFF As explained
; above). And then, you need To copy the Data from the memory DC To the
; screen DC using either BitBlt Or StretchBlt As appropriate.
;
; Remeber To free all the GDI resources (bitmaps, memory DCs etc) that you used.
; AND also To Restore the background color To whatever it was
; before you changed it.
; If the function is a sucess, you Return TRUE.
; If the function is a failure (e.g. a GDI function CALL fails), you Return
; FALSE.
;
; Hoepfully someone can use this information To implement cards.dll IN a way
; that is legally safe.
;}
Re: cards.dll apprendre à utiliser un dll
Salut,
Merci du partage mesa. Javais aussi fait un code qui affiche toutes les cartes d'un coup. Le voici au cas ou
Par contre, je n'affiche pas les cartes aux couleurs inversé, suffi de regarder dans la procedure AffichageDesCartes() L'option y est noté
@++
Merci du partage mesa. Javais aussi fait un code qui affiche toutes les cartes d'un coup. Le voici au cas ou
Code : Tout sélectionner
; /////////////////////////////////////////////////////
; // Autor : Venom //
; // Project name : Afficher carte (cards.dll) //
; // Version : V 1.0 //
; // Compilator : PureBasic V5.71 //
; // Date : 27/02/2020 //
; // OS : Windows 10 //
; /////////////////////////////////////////////////////
; La DLL "cards.dll" utilise cinq fonctions:
; Fonction Description
; -------- ------------
; cdtAnimate Anime le dos des cartes. Elle fonctionne uniquement avec des cartes de taille normal dessinés avec la fonction "cdtDraw".
; cdtDraw Dessine une carte à jouer de taille standard (x = 71 y = 96).
; cdtDrawExt Identique à la fonction "cdtDraw". La seule différence est que cette fonction possède deux paramètres suplémentaires qui vous permetteront d'indiquer la taille (largeur et hauteur) des cartes.
; cdtInit Initialise la DLL. Les deux paramètres permettent de récupèrer la largeur et la hauteur des cartes à jouer.
; cdtTerm Libère les ressources allouées.
;parametre cdDraw:
; ---------------
; DC Handle du contexte de périphérique dans lequel le tracé de la carte à jouer sera effectuée.
; X,Y Position de la carte à jouer en pixel.
; Card Numéro (appelé égalemnt ID) de la carte à jouer.
; Typ Type de la carte. Les valeurs possibles sont "0", "1" et "2" (permet d'inverser les couleurs).
; Color Couleur de fond de la carte. Par défaut, cette couleur est blanche.
;- Window Constants
Enumeration
#Window_0
EndEnumeration
;- Gadgets Constants
Enumeration
#Canvas_0
#Card
EndEnumeration
; Chemin vers la Dll
Global CheminDll$ = "cards.dll"
; Variables
Global LargeurFenetre = 852, HauteurFenetre = 672
Global Dll_ID, HDC, TailleX, TailleY, Card, IDCarte = 0
; Declaration des procedures
Declare InitialisationDeLaDll()
Declare AffichageDesCartes()
Declare AffichageDosDesCartes()
; ///////////////////////////////////////////////
; /////////// Ouverture de la fenetre ///////////
; ///////////////////////////////////////////////
InitialisationDeLaDll()
If OpenWindow(#Window_0, 0, 0, LargeurFenetre, HauteurFenetre, "Afficher les cartes (cards.dll)", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
CanvasGadget(#Canvas_0, 0, 0, LargeurFenetre, HauteurFenetre, 0)
AffichageDesCartes()
EndIf
; ///////////////////////////////////////////////
; /////////////////// Boucle ////////////////////
; ///////////////////////////////////////////////
Repeat
EventID = WaitWindowEvent()
If EventID = #PB_Event_Gadget
Select EventGadget()
EndSelect
EndIf
Until EventID = #PB_Event_CloseWindow
CloseLibrary(Dll_ID) ; Ferme la Dll et libère la mémoire associée
; ///////////////////////////////////////////////
; ///////////////// Procedures //////////////////
; ///////////////////////////////////////////////
Procedure InitialisationDeLaDll()
Dll_ID = OpenLibrary(#PB_Any, CheminDll$) ; Ouverture de la Dll
If Dll_ID > 0 ; On verifie bien que la Dll ce charge
CallFunction(Dll_ID, "cdtInit", @TailleX, @TailleY) ; cdtInit voir ligne 21. @TailleX, @TailleY est la taille de base des cartes
Else ; Sinon on affiche un message d'erreur
MessageRequester("Information", "Erreur. Cards.dll est introuvable." +#CRLF$+"Verifiez le chemin du fichier.", #PB_MessageRequester_Error)
End ; Et on quitte
EndIf
EndProcedure
Procedure AffichageDesCartes()
; HDC : ID dans lequel la carte sera dessiner.
; X,Y : Position de la carte à jouer en pixel. (0 x 0)
; Card : Numéro (appelé égalemnt ID) de la carte à jouer.
;- Affiche les cartes classics
For y = 0 To HauteurFenetre Step 96
For x = 0 To LargeurFenetre-TailleX Step 71
If IDCarte < 52 ; il y a 52 cartes a afficher
If CreateImage(#Card, TailleX, TailleY)
HDC = StartDrawing(CanvasOutput(#Canvas_0))
CallFunction(Dll_ID, "cdtDraw", HDC, x, y, IDCarte, 0, #White) ; Remplacer le 0 par un 2 pour inversé la couleur des cartes.
StopDrawing()
EndIf
IDCarte = IDCarte+1
EndIf
Next
Next
AffichageDosDesCartes() ; Appele la procedure qui affiche le dos des cartes
EndProcedure
Procedure AffichageDosDesCartes()
IDCarte = IDCarte+1 ; on ajoute un +1 pour ne pas réafficher le roi de pic dans les dos de cartes
;- Affiche les dos de carte
For y = 480 To HauteurFenetre Step 96
For x = 0 To LargeurFenetre-TailleX Step 71
If IDCarte < 69
If CreateImage(#Card, TailleX, TailleY)
HDC = StartDrawing(CanvasOutput(#Canvas_0))
CallFunction(Dll_ID, "cdtDraw", HDC, x, y, IDCarte, 1, #White) ; cdtDraw voir ligne 19 et 27 a 31.
StopDrawing()
EndIf
IDCarte = IDCarte+1
EndIf
Next
Next
EndProcedure
@++
Windows 10 x64, PureBasic 5.73 x86 & x64
GPU : radeon HD6370M, CPU : p6200 2.13Ghz
GPU : radeon HD6370M, CPU : p6200 2.13Ghz