Func _GUICtrlCreatePic($filedir,$left = 0,$top = 0)
Local Const $STM_SETIMAGE = 0x0172
Local Const $STM_GETIMAGE = 0x0173
Local $hForm,$Pic,$hPic,$hBitmap,$hObj,$hImage,$hStream,$bData,$hData,$pData,$tData,$Lenght,$open
$open = FileOpen($filedir,16)
$bData = FileRead($open)
FileClose($open)
$Lenght = BinaryLen($bData)
$hData = _MemGlobalAlloc($Lenght,2)
$pData = _MemGlobalLock($hData)
$tData = DllStructCreate("byte[" & $Lenght & "]",$pData)
DllStructSetData($tData,1,$bData)
_MemGlobalUnlock($hData)
$hStream = _WinAPI_CreateStreamOnHGlobal($hData)
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromStream($hStream)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
$Width = _GDIPlus_ImageGetWidth($hImage)
$Height = _GDIPlus_ImageGetHeight($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
$Pic = GUICtrlCreatePic("",$left,$top,$Width,$Height)
$hPic = GUICtrlGetHandle($Pic)
_SendMessage($hPic,$STM_SETIMAGE,0,$hBitmap)
$hObj = _SendMessage($hPic,$STM_GETIMAGE)
_WinAPI_DeleteObject($hBitmap)
Return $Pic
EndFunc
Func _GUICtrlSetPic($id,$filedir)
Local Const $STM_SETIMAGE = 0x0172
Local Const $STM_GETIMAGE = 0x0173
Local $hForm,$Pic,$hPic,$hBitmap,$hObj,$hImage,$hStream,$bData,$hData,$pData,$tData,$Width,$Height,$Lenght,$open
$open = FileOpen($filedir,16)
$bData = FileRead($open)
FileClose($open)
$Lenght = BinaryLen($bData)
$hData = _MemGlobalAlloc($Lenght,2)
$pData = _MemGlobalLock($hData)
$tData = DllStructCreate("byte[" & $Lenght & "]",$pData)
DllStructSetData($tData,1,$bData)
_MemGlobalUnlock($hData)
$hStream = _WinAPI_CreateStreamOnHGlobal($hData)
_GDIPlus_Startup()
$hImage = _GDIPlus_BitmapCreateFromStream($hStream)
$hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
_GDIPlus_ImageDispose($hImage)
_GDIPlus_Shutdown()
$hPic = GUICtrlGetHandle($id)
_SendMessage($hPic,$STM_SETIMAGE)
_SendMessage($hPic,$STM_SETIMAGE,0,$hBitmap)
_SendMessage($hPic,$STM_GETIMAGE)
_WinAPI_DeleteObject($hBitmap)
Return 1
EndFunc
Func _GUICtrlDeletPic($id)
GUICtrlDelete($id)
EndFunc
Func _chuxiancishu($string,Const $find)
Local $return = 0
Local $stringlen = StringLen($find)
While StringInStr($string,$find)
$string = StringTrimLeft($string,StringInStr($string,$find) + $stringlen - 1)
$return += 1
WEnd
Return $return
EndFunc
Func _GDIPlus_BitmapCreateFromStream($hStream)
Local $aResult = DllCall($ghGDIPDll,"uint","GdipCreateBitmapFromStream","ptr",$hStream,"ptr*",0)
If @error Then
Return SetError(@error,@extended,0)
EndIf
Return $aResult[2]
EndFunc ;==>_GDIPlus_BitmapCreateFromStream