Page 1 of 2
drawing Cards
Posted: Tue Jun 17, 2003 10:16 am
by Rings
windows only
This code uses the cards.dll from the windows-systemdrawer.
feel free to create you own blackjack now
Code: Select all
Procedure CardDraw(hdc,NR,X,Y,X2,Y2)
Result=OpenLibrary(1,"cards.dll")
If Result
cdtInit=IsFunction(1,"cdtInit")
cdtDrawExt=IsFunction(1,"cdtDrawExt")
cdtTerm=IsFunction(1,"cdtTerm")
EndIf
Result=CallFunctionFast(cdtInit,@w,@h)
Result=CallFunctionFast(cdtDrawExt,hdc,X,Y,X2,Y2,NR,0,0)
Result= CallFunctionFast(cdtTerm)
CloseLibrary(1)
EndProcedure
If OpenWindow(0, 0, 0, 400, 300, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar, "click this window to draw a card ")
Repeat
ev.l = WaitWindowEvent()
If ev=513
beep_(100,100)
hdc.l = StartDrawing(WindowOutput())
CardDraw(hdc,Random(60),WindowMouseX(),WindowMouseY(),80,100)
StopDrawing()
EndIf
Until ev=#PB_Event_CloseWindow
EndIf
End
Posted: Tue Jun 17, 2003 2:38 pm
by Fred
Excellent

Posted: Tue Jun 17, 2003 3:30 pm
by LarsG
I get a "Syntax Error!" on line 4... 8O

Posted: Tue Jun 17, 2003 6:21 pm
by RJP Computing
Where can I find the documentation on the DLL. That would be fun to use.
Thanks
Posted: Tue Jun 17, 2003 7:03 pm
by Rings
RJP Computing wrote:Where can I find the documentation on the DLL. That would be fun to use.
Thanks
http://www.google.de/search?q=cards.dll ... uche&meta=
Posted: Wed Jun 18, 2003 1:36 am
by Karbon
Now that's a tip n' trick! Awesome!
Re: drawing Cards
Posted: Wed Jun 18, 2003 1:43 am
by PB
> This code uses the cards.dll from the windows-systemdrawer.
Note that this file is only installed if the user chose to install Games
when installing Windows. (I didn't and your example crashes).

Posted: Wed Jun 18, 2003 5:10 am
by midebor
On my system (win 98) I found cards.dll and cards32.dll in the windows/system drawer. Using cards.dll produces system error but with cards32.dll everything works fine.
Michel
Posted: Wed Jun 18, 2003 6:06 am
by midebor
Just to show the value of the cards I modified your code as follows:
Code: Select all
Procedure CardDraw(hdc,NR,X,Y,X2,Y2)
Result=OpenLibrary(1,"cards32.dll")
If Result
cdtInit=IsFunction(1,"cdtInit")
cdtDrawExt=IsFunction(1,"cdtDrawExt")
cdtTerm=IsFunction(1,"cdtTerm")
EndIf
Result=CallFunctionFast(cdtInit,@w,@h)
Result=CallFunctionFast(cdtDrawExt,hdc,X,Y,X2,Y2,NR,0,0)
Result= CallFunctionFast(cdtTerm)
CloseLibrary(1)
EndProcedure
If OpenWindow(0, 0, 0, 400, 300, #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_TitleBar, "click this window to draw a card ")
Repeat
ev.l = WaitWindowEvent()
If ev=513
beep_(100,100)
hdc.l = StartDrawing(WindowOutput())
For a=0 To 3
For i=a To 51 Step 4
CardDraw(hdc,i,WindowMouseX(),WindowMouseY(),80,100)
Delay(500)
Next i
Next a
StopDrawing()
EndIf
Until ev=#PB_Event_CloseWindow
EndIf
End
Michel
no32
Posted: Sat Jun 28, 2003 1:55 am
by TronDoc
I have w98fe and get the system error message.
I do not have cards32.dll only cards.dll.
Any way to make this work?
The games that came with windoze work fine.
Thanks.
Joe
Posted: Sat Jun 28, 2003 3:29 am
by midebor
@TronDoc
Send me an email
Posted: Mon Jun 16, 2008 9:50 pm
by Rook Zimbabwe
Just thought I would play with this for an idea I had...
Code: Select all
; modified from original 3.94
; not without some difficulty
;
Enumeration
#Library
#Window
EndEnumeration
Procedure CardDraw(hdc,NR,X,Y,X2,Y2)
Result=OpenLibrary(#Library,"cards32.dll") ; or cards.dll
If Result
;cdtInit=IsFunction(1,"cdtInit")
;cdtDrawExt=IsFunction(1,"cdtDrawExt")
;cdtTerm=IsFunction(1,"cdtTerm")
*cdtInit = GetFunction(#Library, "cdtInit")
*cdtDrawExt = GetFunction(#Library, "cdtDrawExt")
*cdtTerm = GetFunction(#Library,"cdtTerm")
EndIf
Result=CallFunctionFast(*cdtInit,@w,@h)
Result=CallFunctionFast(*cdtDrawExt,hdc,X,Y,X2,Y2,NR,0,0)
Result= CallFunctionFast(*cdtTerm)
CloseLibrary(#Library)
EndProcedure
If OpenWindow(#Window, 0, 0, 800, 600,"Click this window to draw a card ", #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_TitleBar)
Repeat
ev.l = WaitWindowEvent()
If ev=513
Beep_(100,100)
hdc.l = StartDrawing(WindowOutput(#Window))
For a=0 To 3
For i=a To 51 Step 4
CardDraw(hdc,i,WindowMouseX(#Window),WindowMouseY(#Window),80,100)
Delay(500)
Next i
Next a
StopDrawing()
EndIf
Until ev=#PB_Event_CloseWindow
EndIf
End
I get an error on line 21 evary time... I thought I had midified it to the new standard... what did I do wrong?

Posted: Mon Jun 16, 2008 10:05 pm
by maw
Because you CallFunctionFast() even if OpenLibrary fails in the procedure CardDraw...
Posted: Mon Jun 16, 2008 10:23 pm
by ts-soft
I have changed the code with check, enableexplicit and prototypes
Code: Select all
EnableExplicit
Enumeration
#Library
#Window
EndEnumeration
Prototype cdtInit(a, b)
Prototype cdtDrawExt(a, b, c, d, e, f, g = 0, h = 0)
Prototype cdtTerm()
Procedure CardDraw(hdc, NR, X, Y, X2, Y2)
Protected w.l, h.l
If OpenLibrary(#Library, "cards.dll") ; or cards32.dll
Protected cdtInit.cdtInit = GetFunction(#Library, "cdtInit")
Protected cdtDrawExt.cdtDrawExt = GetFunction(#Library, "cdtDrawExt")
Protected cdtTerm.cdtTerm = GetFunction(#Library, "cdtTerm")
cdtInit(@w, @h)
cdtDrawExt(hdc, X, Y, X2, Y2, Nr)
cdtTerm()
Else
Debug "DLL not found"
EndIf
CloseLibrary(#Library)
EndProcedure
Define.l ev, hdc, a, i
If OpenWindow(#Window, 0, 0, 800, 600, "Click this window to draw a card ", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar)
Repeat
ev.l = WaitWindowEvent(500)
If ev = 513
Beep_(100, 100)
hdc.l = StartDrawing(WindowOutput(#Window))
For a = 0 To 3
For i = a To 51 Step 4
CardDraw(hdc, i, WindowMouseX(#Window), WindowMouseY(#Window), 80, 100)
Next i
Next a
StopDrawing()
EndIf
Until ev = #PB_Event_CloseWindow
EndIf
End
I have only cards.dll on winxp. On vista is another dll and doesn't work
greetings
Thomas
Posted: Tue Jun 17, 2008 2:40 am
by Rook Zimbabwe
Thomas! You got ir in one!!! Great Job!!!
Now I have to figure out how to get card clicked... I may chuck the cards.dll and just load about 55 sprites as a deck... Off a single PNG or something so I can get CLICKED on card and throw them around the screen much easier... Hmmm?
Onward, thank you for showing me a way!
