Kohr Posted December 9, 2006 Share Posted December 9, 2006 (edited) I discovered this from Larry cards.dll and I thought I would try to make a udf for it.Examples: Displays all cards, moving a card, moving a card while leaving the image, sizable cards, cards backs (sizable), and an example of how to redraw the cards if the gui is not active (see the Restore function).Now to attempt a card game.KohrEDITAdded a better way to redraw based on code from Diablo and Zedna_linenums:0'>expandcollapse popup;"This function uses code developed by Paul Campbell (PaulIA) for the Auto3Lib project" ;Redraw functions by Diablo & Zedna ; Created by Kohr #include <GUIConstants.au3> #Include<Array.au3> Opt("GUIOnEventMode", 1) Global $GUIfocus = 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 Example", 950, 450) $a = GUICtrlCreateButton("AllCards", 10, 400, 60, 20) GUICtrlSetOnEvent($a, "AllCards") $b = GUICtrlCreateButton("AllBacks", 70, 400, 60, 20) GUICtrlSetOnEvent($b, "BackCard") $c = GUICtrlCreateButton("Clear", 130, 400, 60, 20) GUICtrlSetOnEvent($c, "ClearBoard") $d = GUICtrlCreateButton("MoveCard", 190, 400, 60, 20) GUICtrlSetOnEvent($d, "MoveCard") $d2 = GUICtrlCreateButton("MoveCard2", 190, 430, 60, 20) GUICtrlSetOnEvent($d2, "MoveCard2") $e = GUICtrlCreateButton("CardSizes", 250, 400, 60, 20) GUICtrlSetOnEvent($e, "CardSizes") ;used to redraw GUI $hdc = DllCall("user32.dll", "int", "GetDC", "hwnd", $GUImain) $hdc = $hdc[0] Global $memory_bm Global $client_rect = WinGetClientSize($GUImain) Global $memory_dc = _CreateCompatibleDC($hdc) Global $memory_bm = _CreateCompatibleBitmap($hdc, $client_rect[0], $client_rect[1]) _SelectObject($memory_dc, $memory_bm) AdlibEnable("Restore") GUISetState(@SW_SHOW, $GUImain) GUISetOnEvent($GUI_EVENT_CLOSE, "CloseClicked") While 1 Sleep(200) WEnd Func AllCards() _Card("spades", "ace", 0, 0) _Card("spades", "two", 70, 0) _Card("spades", "three", 140, 0) _Card("spades", "four", 210, 0) _Card("spades", "five", 280, 0) _Card("spades", "six", 350, 0) _Card("spades", "seven", 420, 0) _Card("spades", "eight", 490, 0) _Card("spades", "nine", 560, 0) _Card("spades", "ten", 630, 0) _Card("spades", "jack", 700, 0) _Card("spades", "queen", 770, 0) _Card("spades", "king", 840, 0) _Card("hearts", "ace", 0, 95) _Card("hearts", "two", 70, 95) _Card("hearts", "three", 140, 95) _Card("hearts", "four", 210, 95) _Card("hearts", "five", 280, 95) _Card("hearts", "six", 350, 95) _Card("hearts", "seven", 420, 95) _Card("hearts", "eight", 490, 95) _Card("hearts", "nine", 560, 95) _Card("hearts", "ten", 630, 95) _Card("hearts", "jack", 700, 95) _Card("hearts", "queen", 770, 95) _Card("hearts", "king", 840, 95) _Card("diamond", "ace", 0, 190) _Card("diamond", "two", 70, 190) _Card("diamond", "three", 140, 190) _Card("diamond", "four", 210, 190) _Card("diamond", "five", 280, 190) _Card("diamond", "six", 350, 190) _Card("diamond", "seven", 420, 190) _Card("diamond", "eight", 490, 190) _Card("diamond", "nine", 560, 190) _Card("diamond", "ten", 630, 190) _Card("diamond", "jack", 700, 190) _Card("diamond", "queen", 770, 190) _Card("diamond", "king", 840, 190) _Card("clubs", "ace", 0, 285) _Card("clubs", "two", 70, 285) _Card("clubs", "three", 140, 285) _Card("clubs", "four", 210, 285) _Card("clubs", "five", 280, 285) _Card("clubs", "six", 350, 285) _Card("clubs", "seven", 420, 285) _Card("clubs", "eight", 490, 285) _Card("clubs", "nine", 560, 285) _Card("clubs", "ten", 630, 285) _Card("clubs", "jack", 700, 285) _Card("clubs", "queen", 770, 285) _Card("clubs", "king", 840, 285) EndFunc ;==>AllCards Func MoveCard() _Card("spades", "king", 0, 0, 70, 95, 0, 1, 150, 150, 1, $GUImain) _Card("spades", "king", 150, 150, 70, 95, 0, 1, 300, 0, 1, $GUImain) _Card("spades", "king", 300, 0, 70, 95, 0, 1, 450, 150, 1, $GUImain) _Card("spades", "king", 450, 150, 70, 95, 0, 1, 600, 0, 1, $GUImain) EndFunc ;==>MoveCard Func MoveCard2() $x = 0 $y = 0 $space = 10 While $x < 150 _Card("spades", "ace", $x, $y) $x += $space $y += $space WEnd While $y <> 0 _Card("spades", "ace", $x, $y) $x += $space $y -= $space WEnd While $x < 450 _Card("spades", "ace", $x, $y) $x += $space $y += $space WEnd While $y <> 0 _Card("spades", "ace", $x, $y) $x += $space $y -= $space WEnd _Card("spades", "ace", $x, $y) EndFunc ;==>MoveCard2 Func BackCard() _Card("spades", "ace", 0, 0, 70, 95, 53) _Card("spades", "two", 70, 0, 70, 95, 54) _Card("spades", "three", 140, 0, 70, 95, 55) _Card("spades", "four", 210, 0, 70, 95, 56) _Card("spades", "five", 280, 0, 70, 95, 57) _Card("spades", "six", 350, 0, 70, 95, 58) _Card("spades", "seven", 420, 0, 70, 95, 59) _Card("spades", "eight", 490, 0, 70, 95, 60) _Card("spades", "nine", 560, 0, 70, 95, 61) _Card("spades", "ten", 630, 0, 70, 95, 62) _Card("spades", "jack", 700, 0, 70, 95, 63) _Card("spades", "queen", 770, 0, 70, 95, 64) _Card("spades", "king", 840, 0, 70, 95, 65) _Card("spades", "king", 0, 95, 70, 95, 67) _Card("spades", "king", 70, 95, 70, 95, 68) EndFunc ;==>BackCard Func ClearBoard() $x = 0 $y = 0 Local $rRect $size = WinGetClientSize("") $rRect = _DllStructCreate($RECT) _DllStructSetData($rRect, $RECT_TOP, $y) _DllStructSetData($rRect, $RECT_LEFT, $x) _DllStructSetData($rRect, $RECT_BOTTOM, $y + $size[1]) _DllStructSetData($rRect, $RECT_RIGHT, $x + $size[0]) _InvalidateRect($GUImain, $rRect, True) EndFunc ;==>ClearBoard Func CardSizes() _Card("spades", "ace", 0, 0, 10, 15) _Card("spades", "two", 10, 0, 20, 30) _Card("spades", "three", 30, 0, 30, 40) _Card("spades", "four", 60, 0, 40, 55) _Card("spades", "five", 100, 0, 50, 65) _Card("spades", "six", 150, 0, 60, 75) _Card("spades", "seven", 210, 0, 70, 85) _Card("spades", "eight", 280, 0, 80, 95) _Card("spades", "nine", 360, 0, 90, 105) _Card("spades", "ten", 450, 0, 100, 115) _Card("spades", "jack", 550, 0, 110, 125) _Card("spades", "queen", 660, 0, 120, 135) _Card("spades", "king", 780, 0, 130, 145) EndFunc ;==>CardSizes Func Restore() $ret = WinGetState($GUImain) If $GUIfocus = 1 Then _BitBlt($memory_dc, 0, 0, $client_rect[0], $client_rect[1], $hdc, 0, 0) EndIf If $ret <> 15 Then $GUIfocus = 0 Else If $GUIfocus = 0 Then If $ret = 15 Then _BitBlt($hdc, 0, 0, $client_rect[0], $client_rect[1], $memory_dc, 0, 0) $GUIfocus = 1 EndIf EndIf EndIf EndFunc ;==>Restore #cs _Card($Suit, $Rank, $PosX, $PosY, $Width = 70, $Height = 95, $DrawBack = 0, $Move = 0, $MoveX = 0, $MoveY = 0, $Erase = 1, $hGui = 0) Parameters: $Suit - Card suit ("CLUBS", "DIAMOND", "HEARTS", "SPADES") $Rank - Card rank ("ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING") $PosX - left coordinate to start drawing card $PosY - top coordinate to start drawing card $Width - Width of card. $Height - Height of card. $DrawBack - Back of Card to draw. CROSSHATCH = 53, /* XP = CROSSHATCH */ WEAVE1 = 54, /* XP = SKY */ WEAVE2 = 55, /* XP = MINERAL */ ROBOT = 56, /* XP = FISH */ FLOWERS = 57, /* XP = FROG */ VINE1 = 58, /* XP = MOONFLOWER */ VINE2 = 59, /* XP = ISLAND */ FISH1 = 60, /* XP = SQUARES */ FISH2 = 61, /* XP = MAGENTA */ SHELLS = 62, /* XP = SANDDUNES */ CASTLE = 63, /* XP = SPACE */ ISLAND = 64, /* XP = LINES */ CARDHAND = 65, /* XP = TOYCARS */ UNUSED = 66, /* XP = UNUSED */ THE_X = 67, /* XP = THE_X */ THE_O = 68 /* XP = THE_0 */ $Move - Move card test. Set to anything other than 0 to enable movement $MoveX - Move to left coordinate $MoveY - Move to top coordinate $Erase - Set to 1 to Erase the card while moving. $hGui - GUI window (needed so it knows where to erase old card while moving). #ce Func _Card($Suit, $Rank, $PosX, $PosY, $Width = 70, $Height = 95, $DrawBack = 0, $Move = 0, $MoveX = 0, $MoveY = 0, $Erase = 1, $hGui = 0) Local $rRect $Moving = 1 $tempX = -1 $tempY = -1 $rRect = _DllStructCreate($RECT) If $DrawBack < 53 Then $Suit = StringUpper($Suit) $Rank = StringUpper($Rank) $Array = _ArrayCreate("CLUBS", "DIAMOND", "HEARTS", "SPADES") $SuitValue = _ArraySearch($Array, $Suit) If @error Then MsgBox(0, "Error", "Invalid Suit") Return 0 EndIf $Array = _ArrayCreate("ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING") $RankValue = _ArraySearch($Array, $Rank) If @error Then MsgBox(0, "Error", "Invalid Rank") Return 0 EndIf $Card = ($RankValue * 4) + $SuitValue EndIf $hDLL = DllOpen("cards.dll") $result = DllCall("user32.dll", "int", "GetDC", "hwnd", $GUImain) $result = $result[0] DllCall($hDLL, "int", "cdtInit", "int_ptr", 0, "int_ptr", 0) If $DrawBack < 53 Then If $Move = 0 Then DllCall($hDLL, "int", "cdtDrawExt", "int", $result, "int", $PosX, "int", $PosY, "int", $Width, "int", $Height, "int", $Card, "int", 0, "int", 0) Else While $Moving = 1 DllCall($hDLL, "int", "cdtDrawExt", "int", $result, "int", $PosX, "int", $PosY, "int", $Width, "int", $Height, "int", $Card, "int", 0, "int", 0) If $tempX = 0 Then If $tempY = 0 Then $Moving = 0 EndIf EndIf If $Moving = 0 Then ExitLoop EndIf If $Erase = 1 Then _DllStructSetData($rRect, $RECT_TOP, $PosY) _DllStructSetData($rRect, $RECT_LEFT, $PosX) _DllStructSetData($rRect, $RECT_BOTTOM, $PosY + $Height + 1) _DllStructSetData($rRect, $RECT_RIGHT, $PosX + $Width + 1) _InvalidateRect($hGui, $rRect, True) EndIf $tempX = $MoveX - $PosX If $tempX > 0 Then $PosX += 1 EndIf If $tempX < 0 Then $PosX -= 1 EndIf $tempY = $MoveY - $PosY If $tempY > 0 Then $PosY += 1 EndIf If $tempY < 0 Then $PosY -= 1 EndIf WEnd EndIf Else DllCall($hDLL, "int", "cdtDrawExt", "int", $result, "int", $PosX, "int", $PosY, "int", $Width, "int", $Height, "int", $DrawBack, "int", 1, "int", 0x0000ff) EndIf DllCall($hDLL, "none", "cdtTerm") DllClose($hDLL) DllCall("user32.dll", "int", "ReleaseDC", "hwnd", $GUImain, "int", $result) EndFunc ;==>_Card Func CloseClicked() Exit EndFunc ;==>CloseClicked #region --- Redraw GUI START --- Func _CreateCompatibleDC($hdc, $dll_h = 'gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_499f.asp Local $ret = DllCall($dll_h, 'ptr', 'CreateCompatibleDC', 'ptr', $hdc) Return $ret[0] EndFunc ;==>_CreateCompatibleDC Func _CreateCompatibleBitmap($hdc, $w, $h, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1cxc.asp Local $ret = DllCall($dll_h, 'ptr', 'CreateCompatibleBitmap', _ 'ptr', $hdc, _ 'int', $w, _ 'int', $h) Return $ret[0] EndFunc ;==>_CreateCompatibleBitmap Func _BitBlt($destination_hdc, $destination_x, $destination_y, $destination_width, $destination_height, _ $source_hdc, $source_x, $source_y, $code = 0xCC0020, $dll_h = 'Gdi32.dll') ;~ Const $SRCCOPY = 0xCC0020 ;~ http://msdn.microsoft.com/library/en-us/gdi/bitmaps_0fzo.asp Local $ret = DllCall($dll_h, 'int', 'BitBlt', _ 'ptr', $destination_hdc, _ 'int', $destination_x, _ 'int', $destination_y, _ 'int', $destination_width, _ 'int', $destination_height, _ 'ptr', $source_hdc, _ 'int', $source_x, _ 'int', $source_y, _ 'int', $code) Return $ret[0] EndFunc ;==>_BitBlt Func _SelectObject($hdc, $hgdiobj, $dll_h = 'Gdi32.dll') ;~ ;http://msdn.microsoft.com/library/en-us/gdi/devcons_9v3o.asp Local $ret = DllCall($dll_h, 'hwnd', 'SelectObject', 'ptr', $hdc, 'hwnd', $hgdiobj) Return $ret[0] EndFunc ;==>_SelectObject #endregion --- Redraw GUI END --- #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 --- Edited December 10, 2006 by Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Zedna Posted December 9, 2006 Share Posted December 9, 2006 Nice wrapper functions.Look at BlackJack from Diablo where is similar approach Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Kohr Posted December 9, 2006 Author Share Posted December 9, 2006 Thanks Zedna for the info. I will check it out for more ideas and methods. Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Kohr Posted December 10, 2006 Author Share Posted December 10, 2006 Improved how the gui is redrawn. Example shows you can minimize/restore and the cards are redrawn. I tried to get them to rotate most of the day and never could figure it out . 1st post has new code. Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Kohr Posted December 10, 2006 Author Share Posted December 10, 2006 Shuffle Deck function. Add this to controls $f = GUICtrlCreateButton("shuffle", 310, 400, 60, 20) GUICtrlSetOnEvent($f, "ShuffleCards") oÝ÷ Ù(n}ù^~éܶ*'jëh×6Func ShuffleCards() Local $Deck[1] Local $DeckTemp[1] $Suit = _ArrayCreate("CLUBS", "DIAMOND", "HEARTS", "SPADES") $Rank = _ArrayCreate("ACE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN", "JACK", "QUEEN", "KING") For $i = 0 To UBound($Suit) - 1 For $j = 0 To UBound($Rank) - 1 _ArrayAdd($Deck,$Suit[$i] & ":" & $Rank[$j]) Next Next $Deck[0] = UBound($Deck) - 1 For $i = 1 To 52 $del = Random(1,53-$i,1) _ArrayAdd($DeckTemp,$Deck[$del]) _ArrayDelete($Deck,$del) Next $k = 0 $x = 0 $y = 0 For $i = 1 To 4 For $j = 1 To 13 $k += 1 $ret = StringSplit($DeckTemp[$k],":") _Card($ret[1], $ret[2], $x, $y) $x += 70 Next $x = 0 $y += 95 Next EndFunc AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Zedna Posted December 10, 2006 Share Posted December 10, 2006 Improved how the gui is redrawn. Example shows you can minimize/restore and the cards are redrawn. I tried to get them to rotate most of the day and never could figure it out .1st post has new code.KohrAs I suggested for Diablo here:Great page about using cards.dll - also about rotating Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Kohr Posted December 10, 2006 Author Share Posted December 10, 2006 (edited) As I suggested for Diablo here:Great page about using cards.dll - also about rotatingZedna what part of "I could never figure it out" do you not understand. I saw that link you have now double posted long before I made this and I stated I tried to make it work. I did not see anywhere in the game link you have provided now twice where any of the cards are rotated.If you know how to actually rotate then help otherwise please don't repost the same thing over and over. Thanks.Kohr Edited December 10, 2006 by Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Zedna Posted December 10, 2006 Share Posted December 10, 2006 Zedna what part of "I could never figure it out" do you not understand. I saw that link you have now double posted long before I made this and I stated I tried to make it work. I did not see anywhere in the game link you have provided now twice where any of the cards are rotated.If you know how to actually rotate then help otherwise please don't repost the same thing over and over. Thanks.KohrPart 10 and Part 12 from my last post Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zedna Posted December 10, 2006 Share Posted December 10, 2006 (edited) If you tried something and need help then post here your AutoIt code you have and we can help you ...EDIT: Maybe I didn't understand you correctly due to my limited English knowledge. If it's the case then sorry. Edited December 10, 2006 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Kohr Posted December 10, 2006 Author Share Posted December 10, 2006 My main problem is probably with my lack of real understanding of C#. When I saw that they are drawing rotated cards it looks like they are using "DrawImage" to accomplish this. So from there I tried to use that command. I tried to use it with gdi32.dll (I don't think it is in there) and I tried it with gdiplus.dll. I was basically just doing trial and error. I never "really" knew what combination was not right so I decided I would need to learn a little bit more about C# before trying to take the way they did it in the post and transfer it over to AutoIt. Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Zedna Posted December 10, 2006 Share Posted December 10, 2006 There is no need to learn C#. It's very similar to VB which is almost the same as AutoIt3. I will make some AutoIt rotate cards example for you, stay tuned ... Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Kohr Posted December 10, 2006 Author Share Posted December 10, 2006 There is no need to learn C#. It's very similar to VB which is almost the same as AutoIt3.I will make some AutoIt rotate cards example for you, stay tuned ...That would be great Zedna. I mainly need a push in the right direction.Thanks.Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab Link to comment Share on other sites More sharing options...
Zedna Posted December 10, 2006 Share Posted December 10, 2006 Bad news I didn't solve it.Here is what I did but there is problem with DrawImage:It's method of Graphic class from gdi+ and I don't know how to create object of this class in AutoIt.So maybe create some helper Dll in C++ for that (create Graphic, call DrawImage to proper DC and points).for details see at MSDN:http://msdn.microsoft.com/library/default....oningimages.asphttp://msdn.microsoft.com/library/default....s/drawimage.aspexpandcollapse popup#include <GUIConstants.au3> #NoTrayIcon $Form1 = GUICreate("Rotate cards test", 300, 200) GUISetBkColor(0x008000) GUISetState(@SW_SHOW) $hDLL = DLLOpen("cards.dll") $hdc = DllCall("user32.dll","int","GetDC","hwnd",$Form1) $hdc = $hdc[0] DLLCall($hDLL,"int","cdtInit","int_ptr",0,"int_ptr",0) Global $memory_dc = _CreateCompatibleDC( $hdc) Global $memory_bm = _CreateCompatibleBitmap( $hdc, 71, 97) ; standard drawing ; X=48 Y=32 DLLCall($hDLL,"int","cdtDraw","int",$hdc,"int", 48,"int", 32,"int", 11,"int",1,"int", 0xffffff) ; rotated drawing ; X=0 Y=0 DLLCall($hDLL,"int","cdtDraw","int",$memory_dc,"int", 0,"int", 0,"int", 11,"int",1,"int", 0xffffff) ; rotated card will be at X=148 Y=132 $apoints = DllStructCreate("int,int,int,int,int,int") ; 3x point: X,Y DllStructSetData($apoints, 1, 148) ; X DllStructSetData($apoints, 2, 132+71) ; Y+71 DllStructSetData($apoints, 3, 148) ; X DllStructSetData($apoints, 4, 132) ; Y DllStructSetData($apoints, 5, 148+97) ; X+97 DllStructSetData($apoints, 6, 132+71) ; Y+71 _DrawImage( $memory_bm, $hdc, DllStructGetPtr($apoints)) ; !!! problem !!! $apoints = 0 ; not neccessery ;~ DLLCall("user32.dll","int","InvalidateRect","hwnd",$Form1,"int",0,"int",0) ; lpRect=null bErase=True While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Func OnAutoItExit ( ) DLLCall($hDLL,"none","cdtTerm") DLLClose($hDLL) DLLCall("user32.dll","int","ReleaseDC","hwnd",$Form1,"int",$hdc) _DeleteObject( $memory_bm) _DeleteDC( $memory_dc) EndFunc ; !!! problem !!! Func _DrawImage( $hdc_src, $hdc_dest, $points) ; what here? ; maybe DllCall() some helper DLL created in C++ ; see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/aboutGDIPlus/imagesbitmapsandmetafiles/drawingpositioningandcloningimages.asp ; see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusreference/classes/graphicsclass/graphicsmethods/graphicsdrawimagemethods/drawimage.asp Return 0 EndFunc ; == functions from gdi32.au3 == Func _CreateCompatibleDC( $hdc, $dll_h = 'gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_499f.asp Local $ret = DllCall( $dll_h, 'ptr', 'CreateCompatibleDC', 'ptr', $hdc) Return $ret[0] EndFunc Func _CreateCompatibleBitmap( $hdc, $w, $h, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/bitmaps_1cxc.asp Local $ret = DllCall( $dll_h, 'ptr', 'CreateCompatibleBitmap', _ 'ptr', $hdc, _ 'int', $w, _ 'int', $h) Return $ret[0] EndFunc Func _DeleteObject( $hObject, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_1vsk.asp Local $ret = DllCall( $dll_h, 'int', 'DeleteObject', 'hwnd', $hObject) Return $ret[0] EndFunc Func _DeleteDC( $hdc, $dll_h = 'Gdi32.dll') ;~ http://msdn.microsoft.com/library/en-us/gdi/devcons_2p2b.asp Local $ret = DllCall( $dll_h, 'int', 'DeleteDC', 'ptr', $hdc) Return $ret[0] EndFunc 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