纸牌程序调用
最近想做个算24的小游戏,想调用win的纸牌图片,怎么去调用的,谢谢 本帖最后由 love008 于 2016-2-18 19:28 编辑WIN7 64位系统下还有点问题,
#include <GDIPlus.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <Array.au3>
Opt ("MustDeclareVars", 1)
_Main ( )
_Main (True)
Func _Main ($mixed=False)
Local $a_hBMP, $a_hBitmap, $hGraphic, $hGUI, $hInstance
Local $ressource = "cards.dll"
; 加载资源DLL到数据文件
$hInstance = _WinAPI_LoadLibraryEx ($ressource, $LOAD_LIBRARY_AS_DATAFILE)
; 从库加载位图
; 数组中的=DLL索引, =真实次序, =BMP句柄
Local $j = 15
For $i = 0 To 38
If $i = 12 Or $i = 25 Or $i =38 Then
$a_hBMP[$i] = $j -13
$a_hBMP[$i] = $i +1
$a_hBMP[$i] = _WinAPI_LoadBitmap ($hInstance, $a_hBMP[$i])
Else
$a_hBMP[$i] = $j
$a_hBMP[$i] = $i +1
$a_hBMP[$i] = _WinAPI_LoadBitmap ($hInstance, $a_hBMP[$i])
EndIf
$j += 1
Next
$j = 2
For $i = 39 To 50
$a_hBMP[$i] = $j
$a_hBMP[$i] = $i +1
$a_hBMP[$i] = _WinAPI_LoadBitmap ($hInstance, $a_hBMP[$i])
$j += 1
Next
$a_hBMP = 1
$a_hBMP = 52
$a_hBMP = _WinAPI_LoadBitmap ($hInstance, $a_hBMP)
If $mixed Then
; 获取随机顺序
Local $aImagesIndex, $RandomIndex
For $i = 0 To 51
Do
$RandomIndex = Random(0, 51, 1)
_ArraySearch($aImagesIndex, String($RandomIndex))
If @error Then $aImagesIndex[$i] = String($RandomIndex)
Until $aImagesIndex[$i]
Next
;设置BMP处理随机顺序
Local $aTmp
For $i = 0 To UBound($aTmp) -1
$aTmp[$i] = $a_hBMP[$aImagesIndex[$i]]
$aTmp[$i] = $a_hBMP[$aImagesIndex[$i]]
$aTmp[$i] = $a_hBMP[$aImagesIndex[$i]]
Next
; 内部排序
_ArraySort($aTmp, 0, 0, 12, 1)
_ArraySort($aTmp, 0, 13, 25, 1)
_ArraySort($aTmp, 0, 26, 38, 1)
_ArraySort($aTmp, 0, 39, 51, 1)
$a_hBMP = $aTmp
$aTmp = 0
EndIf
; 创建GUI
Local $title='清一色纸牌'
If $mixed Then $title = '随机纸牌'
$hGUI = GUICreate ($title, 710, 350)
GUISetBkColor(0x008000)
GUISetState ()
; 初始化GDI+库
_GDIPlus_Startup ()
; 通过位图句柄创建对象
For $i = 0 To UBound($a_hBitmap) -1
$a_hBitmap[$i] = _GDIPlus_BitmapCreateFromHBITMAP ($a_hBMP[$i])
Next
; 通过窗口句柄创建一个图形对象
$hGraphic = _GDIPlus_GraphicsCreateFromHWND ($hGUI)
; 绘制所有的位图对象
Local $x = 20, $y = 20, $count
For $i = 0 To UBound($a_hBitmap) -1
$count = $i +1
_GDIPlus_GraphicsDrawImage ($hGraphic, $a_hBitmap[$i], $x, $y)
If $i > 1 And Mod($count, 13) = 0 Then
$x += 100
Else
$x += 20
EndIf
If $i = 25 Then
$x = 20
$y += 140
EndIf
Next
;循环直到用户退出
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
; 清理资源
For $i = 0 To UBound($a_hBitmap) -1
_GDIPlus_ImageDispose ($a_hBitmap[$i])
_WinAPI_DeleteObject ($a_hBMP[$i])
Next
_WinAPI_FreeLibrary ($hInstance)
; 关闭GDI+库
_GDIPlus_ShutDown ()
GUIDelete()
EndFunc ;==>_Main
winxp+autoit3.3.6.1下测试通过
通过窗口句柄创建一个图形对象 测试只有一个绿色窗口 本帖最后由 zldfsz 于 2016-2-18 10:04 编辑
win7用户拷贝XP的cards.dll到脚本目录后测试成功,附上cards.dll网盘下载地址:
点击去百度云网盘下载cards.dll
测试3楼的确实只有绿屏 非常好,收藏以后作为参考!
感谢分享!
页:
[1]