Kohr Posted December 8, 2006 Share Posted December 8, 2006 Does anyone know how to do the following using cards.dll? 1. Draw the card in a rotated position. 2. Click and drag the card. No big deal if it cannot be done. I just thought it would be a nice ability to add to card games. Example code shows different cards drawn. Thanks. Kohr CODEexpandcollapse popup;"This function uses code developed by Paul Campbell (PaulIA) for the Auto3Lib project" ; Created by Kohr #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ;Globals for Auto3Lib Global $gaLibDlls[64][2] = [[0, 0]] Global Const $RECT = "int;int;int;int" Global Const $RECT_LEFT = 1 Global Const $RECT_TOP = 2 Global Const $RECT_RIGHT = 3 Global Const $RECT_BOTTOM = 4 $GUImain = GUICreate("Cards", 950, 450) $a = GUICtrlCreateButton("cards", 10, 400, 50, 20) GUICtrlSetOnEvent($a, "Cards") $b = GUICtrlCreateButton("backs", 60, 400, 50, 20) GUICtrlSetOnEvent($b, "BackCard") $c = GUICtrlCreateButton("Clear", 110, 400, 50, 20) GUICtrlSetOnEvent($c, "ClearBoard") $d = GUICtrlCreateButton("Move", 160, 400, 50, 20) GUICtrlSetOnEvent($d, "MoveCard") $e = GUICtrlCreateButton("bigcard", 210, 400, 50, 20) GUICtrlSetOnEvent($e, "BigCard") GUISetState(@SW_SHOW, $GUImain) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked") While 1 Sleep(200) WEnd Func CloseClicked() Exit EndFunc ;==>CloseClicked Func Cards() $hDLL = DllOpen("cards.dll") $hdc = DllCall("user32.dll", "int", "GetDC", "hwnd", $GUImain) $hdc = $hdc[0] DllCall($hDLL, "int", "cdtInit", "int_ptr", 0, "int_ptr", 0) $card = 0 $x = 0 $y = 0 For $i = 1 To 13 For $j = 1 To 4 DllCall($hDLL, "int", "cdtDraw", "int", $hdc, "int", $x, "int", $y, "int", $card, "int", 0, "int", 0) $card += 1 $y += 95 Next $x += 70 $y = 0 Next DllCall($hDLL, "none", "cdtTerm") DllClose($hDLL) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $GUImain, "int", $hdc) EndFunc ;==>Cards Func BackCard() $hDLL = DllOpen("cards.dll") $hdc = DllCall("user32.dll", "int", "GetDC", "hwnd", $GUImain) $hdc = $hdc[0] DllCall($hDLL, "int", "cdtInit", "int_ptr", 0, "int_ptr", 0) $card = 53 $x = 0 $y = 0 For $i = 1 To 4 For $j = 1 To 4 DllCall($hDLL, "int", "cdtDraw", "int", $hdc, "int", $x, "int", $y, "int", $card, "int", 1, "int", 0) $card += 1 $y += 95 Next $x += 70 $y = 0 Next DllCall($hDLL, "none", "cdtTerm") DllClose($hDLL) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $GUImain, "int", $hdc) EndFunc ;==>BackCard Func ClearBoard() $x = 0 $y = 0 Local $rRect $rRect = _DllStructCreate($RECT) _DllStructSetData($rRect, $RECT_TOP, $y) _DllStructSetData($rRect, $RECT_LEFT, $x) _DllStructSetData($rRect, $RECT_BOTTOM, $y + 450) _DllStructSetData($rRect, $RECT_RIGHT, $x + 950) _InvalidateRect($GUImain, $rRect, True) EndFunc ;==>ClearBoard Func MoveCard() Local $rRect $rRect = _DllStructCreate($RECT) $hDLL = DllOpen("cards.dll") $hdc = DllCall("user32.dll", "int", "GetDC", "hwnd", $GUImain) $hdc = $hdc[0] DllCall($hDLL, "int", "cdtInit", "int_ptr", 0, "int_ptr", 0) $card = 0 $x = 0 $y = 0 For $i = 1 To 10 For $j = 1 To 10 DllCall($hDLL, "int", "cdtDraw", "int", $hdc, "int", $x, "int", $y, "int", $card, "int", 0, "int", 0) Sleep(20) _DllStructSetData($rRect, $RECT_TOP, $y) _DllStructSetData($rRect, $RECT_LEFT, $x) _DllStructSetData($rRect, $RECT_BOTTOM, $y + 96) _DllStructSetData($rRect, $RECT_RIGHT, $x + 71) _InvalidateRect($GUImain, $rRect, True) $y += 10 Next $x += 40 $y = 0 Next DllCall($hDLL, "none", "cdtTerm") DllClose($hDLL) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $GUImain, "int", $hdc) EndFunc ;==>MoveCard Func BigCard() $hDLL = DllOpen("cards.dll") $hdc = DllCall("user32.dll", "int", "GetDC", "hwnd", $GUImain) $hdc = $hdc[0] DllCall($hDLL, "int", "cdtInit", "int_ptr", 0, "int_ptr", 0) $card = 0 $x = 0 $y = 0 ;~ DLLCall($hDLL,"int","cdtDraw","int",$hdc,"int", $x,"int", $y,"int",$card,"int",0,"int", 0) DllCall($hDLL, "int", "cdtDrawExt", "int", $hdc, "int", $x, "int", $y, "int", 150, "int", 170, "int", $card, "int", 0, "int", 0) $card += 1 $y += 95 DllCall($hDLL, "none", "cdtTerm") DllClose($hDLL) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $GUImain, "int", $hdc) EndFunc ;==>test #region --- Auto3Lib START --- Func _DllOpen($sFileName) Local $hDLL Local $iIndex $sFileName = StringUpper($sFileName) For $iIndex = 1 To $gaLibDlls[0][0] If $sFileName = $gaLibDlls[$iIndex][0] Then Return $gaLibDlls[$iIndex][1] EndIf Next $hDLL = DllOpen($sFileName) $iIndex = $gaLibDlls[0][0] + 1 $gaLibDlls[0][0] = $iIndex $gaLibDlls[$iIndex][0] = $sFileName $gaLibDlls[$iIndex][1] = $hDLL Return $hDLL EndFunc ;==>_DllOpen Func _DllStructCreate($sStruct, $pPointer = 0) Local $rResult If $pPointer = 0 Then $rResult = DllStructCreate($sStruct) Else $rResult = DllStructCreate($sStruct, $pPointer) EndIf Return $rResult EndFunc ;==>_DllStructCreate Func _DllStructSetData($rStruct, $iElement, $vValue, $iIndex = -1) Local $rResult If $iIndex = -1 Then $rResult = DllStructSetData($rStruct, $iElement, $vValue) Else $rResult = DllStructSetData($rStruct, $iElement, $vValue, $iIndex) EndIf Return $rResult EndFunc ;==>_DllStructSetData Func _DllStructGetPtr($rStruct, $iElement = 0) Local $rResult If $iElement = 0 Then $rResult = DllStructGetPtr($rStruct) Else $rResult = DllStructGetPtr($rStruct, $iElement) EndIf Return $rResult EndFunc ;==>_DllStructGetPtr Func _InvalidateRect($hWnd, $rRect = 0, $bErase = True) Local $pRect Local $aResult Local $hUser32 If $rRect <> 0 Then $pRect = _DllStructGetPtr($rRect) $hUser32 = _DllOpen("User32.dll") $aResult = DllCall($hUser32, "int", "InvalidateRect", "hwnd", $hWnd, "ptr", $pRect, "int", $bErase) Return ($aResult[0] <> 0) EndFunc ;==>_InvalidateRect #endregion --- Auto3Lib END --- AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Zedna Posted January 6, 2007 Share Posted January 6, 2007 Does anyone know how to do the following using cards.dll?1. Draw the card in a rotated position.Look here Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now