Sign in to follow this  
Followers 0
wolf9228

Update Resource Autoit Exe File

2 posts in this topic

#1 ·  Posted (edited)

DOWNLOAD

UpdateRes_Au3ExeFile.ZIP

http://www.4shared.com/file/121351089/6001108d/UpdateRes_Au3ExeFile.html

DOWNLOAD

http://files.upload2world.com/get-7-2009-upload2world_com_nvx7pde7.zip

UpdateRes_Au3ExeFile.au3

#Include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 1)
Opt("OnExitFunc", "endscript")
Const $Style_Stretch = 1 , $Style_Tile = 2 , $Style_Center = 3 , $Style_Stretch_Center = 4 , $Style_Stretch_Tile  = 5
Global $HICON_WM_SETCURSOR , $StrResName , $WM_ERASEBKGND_ARRAY[1][9] , $OriginalAutoitExeFile , $OriginalBinary
Func GetAutoitScriptCode($AutoitExeFile)
Local $nBytes
Local $hFile = _WinAPI_CreateFile($AutoitExeFile, 2,2)
if Not $hFile Then Return -1
Local $tSize = FileGetSize($AutoitExeFile) + 1
Local $DATA = DllStructCreate("byte[" & $tSize & "]")
_WinAPI_ReadFile($hFile, DllStructGetPtr($DATA), $tSize, $nBytes)
if @error Then
_WinAPI_CloseHandle($hFile)
return -2
EndIf
_WinAPI_CloseHandle($hFile)
Local $Binary = String(DllStructGetData($DATA,1))
Local $pos_sub_str = StringInStr($Binary, "6E64656E63793E0D0A3C2F617373656D626C793E0D0A")
if @error Then Return -3
$pos_sub_str -= 1
$pos_sub_str += StringLen("6E64656E63793E0D0A3C2F617373656D626C793E0D0A")
Local $Len = StringLen($Binary)
Local $LenAutoitScriptCode = $Len - $pos_sub_str
Local $AutoitScriptCode = StringRight($Binary,$LenAutoitScriptCode)
Dim $ArrayResult[2]
$ArrayResult[0] = $AutoitScriptCode
$ArrayResult[1] = $Binary
Return $ArrayResult
EndFunc

Func InsertAutoitScriptCode($AutoitExeFile,$AutoitScriptCode)
Local $nBytes
Local $hFile = _WinAPI_CreateFile($AutoitExeFile, 2,2)
if Not $hFile Then Return -1
Local $tSize = FileGetSize($AutoitExeFile) + 1
Local $DATA = DllStructCreate("byte[" & $tSize & "]")
_WinAPI_ReadFile($hFile, DllStructGetPtr($DATA), $tSize, $nBytes)
if @error Then
_WinAPI_CloseHandle($hFile)
return -2
EndIf
_WinAPI_CloseHandle($hFile)
Local $Binary = String(DllStructGetData($DATA,1))
Local $pos_sub_str = StringInStr($Binary, "6E64656E63793E0D0A3C2F617373656D626C793E0D0A")
if @error Then Return -3
$pos_sub_str -= 1
$pos_sub_str += StringLen("6E64656E63793E0D0A3C2F617373656D626C793E0D0A")
Local $Len = StringLen($Binary)
Local $LenOutbyteExeCode = $Len - $pos_sub_str
Local $ExeBinaryWithOutAutoitScriptCode = StringLeft($Binary,$Len - $LenOutbyteExeCode)
Local $Strbyte = ""
For $i = 1 To $LenOutbyteExeCode Step 1
$Strbyte &= "0"
Next
Local $OutExeFile = $ExeBinaryWithOutAutoitScriptCode & $Strbyte & $AutoitScriptCode
Local $FileOpen = FileOpen($AutoitExeFile,2)
FileWrite($FileOpen,Binary($OutExeFile))
FileClose($FileOpen)
Return True
EndFunc

Func OriginalFile($AutoitExeFile,$Binary)
If Not($OriginalBinary) Then
$OriginalAutoitExeFile = StringTrimRight($AutoitExeFile,3) & "_Original.exe"
$OriginalBinary = $Binary
EndIf
EndFunc

Func UpdateFreeResource($AutoitExeFile , $InpResFile , $RsName , $RsType )
Local $ArrayResult = GetAutoitScriptCode($AutoitExeFile)
if Not IsArray($ArrayResult) Then Return -1
Local $AutoitScriptCode = $ArrayResult[0] , $Binary = $ArrayResult[1]
OriginalFile($AutoitExeFile,$Binary)
Local $nBytes ,$tSize , $hFile, $result ,$ResArray[3][3] ,$paramtype1 , $paramtype2 , $result,$rh , $DATA
$ResArray[0][1] = "ResourceName"
$ResArray[0][2] = "ResourceType"
$ResArray[1][0] = "Name"
$ResArray[2][0] = "Type"

$hFile = _WinAPI_CreateFile($InpResFile, 2,2)
if Not $hFile Then Return -1
$tSize = FileGetSize($InpResFile) + 1
$DATA = DllStructCreate("byte[" & $tSize & "]")
_WinAPI_ReadFile($hFile, DllStructGetPtr($DATA), $tSize, $nBytes)
if @error Then
_WinAPI_CloseHandle($hFile)
return -2
EndIf
_WinAPI_CloseHandle($hFile)

if IsString($RsType) Then
$paramtype1 = "str"
$RsType = StringUpper($RsType)
ELSE
$paramtype1 = "long"
$RsType = Int($RsType)
EndIf
if IsString($RsName) Then
$paramtype2 = "str"
$RsName = StringUpper($RsName)
ELSE
$paramtype2 = "long"
$RsName = Int($RsName)
EndIf

$result = DllCall("kernel32.dll", "hwnd", "BeginUpdateResource", "str", $AutoitExeFile, "int", 0)
if Not @error Then
$rh = $result[0]
if $rh = 0 Then return -3
Else
return -3
EndIf

$result = DllCall("kernel32.dll", "int", "UpdateResource", "hwnd", $rh, $paramtype1 , $RsType, $paramtype2, $RsName, "short", 0, "ptr", _
DllStructGetPtr($DATA), "long" , DllStructGetSize($DATA))
if Not @error Then
if $result[0] = 0 Then return -4
Else
return -4
EndIf

$result = DllCall("kernel32.dll", "int", "EndUpdateResource", "hwnd", $rh, "int", 0)
if Not @error Then
if $result[0] = 0 Then return -5
Else
return -5
EndIf

$ResArray[0][0] = 2
$ResArray[1][1] = $RsName
$ResArray[1][2] = $RsType
$ResArray[2][1] = VarGetType($RsName)
$ResArray[2][2] = VarGetType($RsType)
$result = InsertAutoitScriptCode($AutoitExeFile,$AutoitScriptCode)
if $result = False Then Return -6
return $ResArray
EndFunc

Func UpdateBitmapResource($AutoitExeFile,$BitmapFile,$RsName)
Local $nBytes ,$tSize ,$bitmap , $RT_BITMAP = 2 , $hFile , $tBuffer , $result , $FILE_BEGIN = 0 ,$ResArray[3][3] , _
$IMAGE_BITMAP =0 , $LR_LOADFROMFILE = 0x0010 ,$paramtype2
Local $ArrayResult = GetAutoitScriptCode($AutoitExeFile)
if Not IsArray($ArrayResult) Then Return -1
Local $AutoitScriptCode = $ArrayResult[0] , $Binary = $ArrayResult[1]
OriginalFile($AutoitExeFile,$Binary)
$ResArray[0][1] = "ResourceName"
$ResArray[0][2] = "ResourceType"
$ResArray[1][0] = "Name"
$ResArray[2][0] = "Type"
Local $hBitmap = _WinAPI_LoadImage(_WinAPI_GetModuleHandle(0),$BitmapFile,$IMAGE_BITMAP ,0,0,$LR_LOADFROMFILE)
if Not ($hBitmap) Then return -1

if IsString($RsName) Then
$paramtype2 = "str"
$RsName = StringUpper($RsName)
ELSE
$paramtype2 = "long"
$RsName = Int($RsName)
EndIf

$hFile = _WinAPI_CreateFile($BitmapFile, 2,2)
if Not $hFile Then Return -2

$tSize = FileGetSize($BitmapFile) + 1
$bitmap = DllStructCreate("char[" & $tSize & "]")
_WinAPI_SetFilePointer($hFile, 14 , $FILE_BEGIN)
_WinAPI_ReadFile($hFile, DllStructGetPtr($bitmap), $tSize, $nBytes)
if @error Then
_WinAPI_CloseHandle($hFile)
return -3
EndIf
_WinAPI_CloseHandle($hFile)


$result = DllCall("kernel32.dll", "hwnd", "BeginUpdateResource", "str", $AutoitExeFile, "int", 0)
if Not @error Then
Local $rh = $result[0]
if $rh = 0 Then return -4
Else
return -4
EndIf


$result = DllCall("kernel32.dll", "int", "UpdateResource", "hwnd", $rh, "Long", int($RT_BITMAP), $paramtype2 , $RsName, "short", 0, "ptr", _
DllStructGetPtr($bitmap), 'dword', DllStructGetSize($bitmap))

if Not @error Then
if $result[0] = 0 Then return -5
Else
return -5
EndIf

$result = DllCall("kernel32.dll", "int", "EndUpdateResource", "hwnd", $rh, "int", 0)
if Not @error Then
if $result[0] = 0 Then return -6
Else
return -6
EndIf

$ResArray[0][0] = 2
$ResArray[1][1] = $RsName
$ResArray[1][2] = $RT_BITMAP
$ResArray[2][1] = VarGetType($RsName)
$ResArray[2][2] = VarGetType($RT_BITMAP)
$result = InsertAutoitScriptCode($AutoitExeFile,$AutoitScriptCode)
if $result = False Then Return -6
return $ResArray
EndFunc

Func endscript()
Local $FileOpen = FileOpen($OriginalAutoitExeFile,2)
FileWrite($FileOpen,Binary($OriginalBinary))
FileClose($FileOpen)
EndFunc

LoadImageFromResourc.au3

Func LoadImageFromFreeResourc($RsName , $RsType , $GDIPlus_ShutDown = True)
; $GDIP_IMAGETYPE_BITMAP - Bitmap types: BMP, PNG, GIF, JPEG, TIFF, ICO, EXIF [Return HBITMAP Handle AND  imageobject[Bitmap Handle]]
;$GDIP_IMAGETYPE_METAFILE - Metafile types: EMF, WMF [Return HENHMETAFILE Handle  (AND\OR) imageobject]
;$GDIP_IMAGETYPE_UNKNOWN [Return new object]
Local $paramtype1 , $paramtype2
Local $ModuleHandle =_WinAPI_GetModuleHandle(0)
if @error Then Return -1
if IsString($RsType) Then
$paramtype1 = "str"
$RsType = StringUpper($RsType)
ELSE
$paramtype1 = "long"
$RsType = Int($RsType)
EndIf
if IsString($RsName) Then
$paramtype2 = "str"
$RsName = StringUpper($RsName)
ELSE
$paramtype2 = "long"
$RsName = Int($RsName)
EndIf
Local $FindResource = DllCall("kernel32.dll", "int", "FindResourceA", "int", $ModuleHandle, $paramtype2, $RsName, $paramtype1, $RsType)
if @error Then
Return -2
Else
$FindResource = $FindResource[0]
if $FindResource = 0 Then Return -2
EndIf

Local $SizeofResource = DllCall("kernel32.dll", "long", "SizeofResource", "hwnd",$ModuleHandle, "hwnd", $FindResource)
if @error Then
Return -3
Else
$SizeofResource = $SizeofResource[0]
if $SizeofResource = 0 Then Return -3
EndIf

Local $LoadResource = DllCall("kernel32.dll", "ptr", "LoadResource", "hwnd",$ModuleHandle, "hwnd", $FindResource)
if @error Then
Return -4
Else
$LoadResource = $LoadResource[0]
if $LoadResource = 0 Then Return -4
EndIf

Local $LockResource = DllCall("kernel32.dll", "ptr", "LockResource", "ptr", $LoadResource)
if @error Then
Return -5
Else
$LockResource = $LockResource[0]
if $LockResource = 0 Then Return -5
EndIf

Local $LockResource = DllCall("kernel32.dll", "ptr", "LockResource", "ptr", $LoadResource)
if @error Then
Return -6
Else
$LockResource = $LockResource[0]
if $LockResource = 0 Then Return -6
EndIf

Local $uFlags = 0x0002 , $dwBytes = $SizeofResource
Local $hMemory = DllCall("Kernel32.dll","hwnd","GlobalAlloc","long",$uFlags,"long",$dwBytes)
if @error Then
Return -7
Else
$hMemory = $hMemory[0]
if $hMemory = 0 Then Return -7
EndIf
Local $hLock = DllCall("Kernel32.dll","ptr","GlobalLock","hwnd",$hMemory)
if @error Then
Return -8
Else
$hLock = $hLock[0]
if $hLock = 0 Then Return -8
EndIf
Local $Destination = $hLock , $Source = $LockResource, $Length = $SizeofResource
DllCall("Kernel32.dll","none","RtlMoveMemory","ptr",$Destination,"ptr",$Source,"long",$Length)
if @error Then
Return -9
EndIf
Local $fDeleteOnRelease = True , $Status , $ppstm , $Error
Local $Error = DllCall("Ole32.dll","int","CreateStreamOnHGlobal","ptr",$hLock ,"int",$fDeleteOnRelease,"ptr*",0)
if @error Then
Return -10
Else
if Not ($Error[0] = 0) Then Return -10
$ppstm = $Error[3]
EndIf
_WinAPI_FreeLibrary($ModuleHandle)
Local $gdiplusOpen = DllOpen("gdiplus.dll")
Local $ImageType = 0 , $ImageWidth = 0 ,$ImageHeight = 0 , $struct_GdiplusStartupInput , $Input , $LPInput , $VOID _
, $LPVOID_token , $Status , $HBITMAP , $HENHMETAFILE , $GdiPlus_Dll_Hwnd , $GdiPlus_Token
$struct_GdiplusStartupInput = _
"int GdiplusVersion;" & _
"int DebugEventCallback;" & _
"int SuppressBackgroundThread;" & _
"int SuppressExternalCodecs;"
$Input = DllStructCreate($struct_GdiplusStartupInput)
DllStructSetData($Input,"GdiplusVersion",1)
DllStructSetData($Input,"DebugEventCallback",0)
DllStructSetData($Input,"SuppressBackgroundThread",0)
DllStructSetData($Input,"SuppressExternalCodecs",0)
$LPInput = DllStructGetPtr($Input)
$VOID = DllStructCreate("int")
$LPVOID_token = DllStructGetPtr($VOID)
$Status = DllCall($gdiplusOpen,"int","GdiplusStartup","ptr",$LPVOID_token,"ptr",$LPInput,"ptr",0)
if @error Then
Return -11
Else
if Not ($Status[0] = 0) Then Return -11
$LPVOID_token = $Status[1]
EndIf
Local $stream = $ppstm , $image = 0
$Status = DllCall($gdiplusOpen,"int","GdipLoadImageFromStream","ptr",$stream,"int*",$image)
if @error Then
Return -12
Else
if Not ($Status[0] = 0) Then Return -12
$image = $Status[2]
EndIf
$Status = DllCall($gdiplusOpen,"int","GdipGetImageWidth","hwnd",$image,"int*",0)
if Not @error Then
if $Status[0] = 0 Then $ImageWidth = $Status[2]
EndIf
$Status = DllCall($gdiplusOpen,"int","GdipGetImageHeight","hwnd",$image,"int*",0)
if Not @error Then
if $Status[0] = 0 Then $ImageHeight = $Status[2]
EndIf
$Status = DllCall($gdiplusOpen,"int","GdipGetImageType","hwnd",$image,"int*",0)
if Not @error Then
Local $CaseMsg = $Status[2]
Select
Case $CaseMsg = 0
$ImageType = "ImageTypeUnknown"
Case $CaseMsg = 1
$ImageType = "ImageTypeBitmap"
$Status = DllCall($gdiplusOpen, "int", "GdipCreateHBITMAPFromBitmap", "hwnd", $image, "int*", 0, "int", 0)
if Not @error Then
if ($Status[0] = 0) Then $HBITMAP = $Status[2]
EndIf
Case $CaseMsg = 2
$ImageType = "ImageTypeMetafile"
Local $metafile = $image
$Status = DllCall($gdiplusOpen,"int","GdipGetHemfFromMetafile","hwnd",$metafile,"int*",0)
if Not @error Then
if ($Status[0] = 0) Then $HENHMETAFILE = $Status[2]
EndIf
EndSelect
EndIf
if $GDIPlus_ShutDown = True Then
DllCall($gdiplusOpen,"int","GdiplusShutdown","ptr",$LPVOID_token)
DllClose($gdiplusOpen)
$GdiPlus_Dll_Hwnd = 0
$GdiPlus_Token = 0
Else
$GdiPlus_Dll_Hwnd = $gdiplusOpen
$GdiPlus_Token = $LPVOID_token
EndIf
Dim $ImageArray[2][8]
$ImageArray[0][0] = "imageobject"
$ImageArray[0][1] = "HBITMAP"
$ImageArray[0][2] = "HENHMETAFILE"
$ImageArray[0][3] = "ImageType"
$ImageArray[0][4] = "ImageWidth"
$ImageArray[0][5] = "ImageHeight"
$ImageArray[0][6] = "GdiPlus Dll Hwnd "
$ImageArray[0][7] = "GdiPlus Token"
$ImageArray[1][0] = $image
$ImageArray[1][1] = $HBITMAP
$ImageArray[1][2] = $HENHMETAFILE
$ImageArray[1][3] = $ImageType
$ImageArray[1][4] = $ImageWidth
$ImageArray[1][5] = $ImageHeight
$ImageArray[1][6] = $GdiPlus_Dll_Hwnd
$ImageArray[1][7] = $GdiPlus_Token
return $ImageArray
EndFunc


Func LoadBitmap_FromResources($resource_Name)
Local $paramtype2
Local $ModuleHandle =_WinAPI_GetModuleHandle(0)
if @error Then Return -1
if IsString($resource_Name) Then
$paramtype2 = "str"
$resource_Name = StringUpper($resource_Name)
ELSE
$paramtype2 = "long"
$resource_Name = Int($resource_Name)
EndIf
Local $HBITMAP =  DllCall("User32.dll", "hwnd","LoadBitmapA","hwnd",$ModuleHandle,$paramtype2,$resource_Name)
if Not @error Then
if $HBITMAP[0] = 0 Then return -2
Else
return -2
EndIf
Return $HBITMAP[0]
EndFunc

ERASEBKGND_NO_UPX.au3

#Region
#AutoIt3Wrapper_UseUpx=n
#EndRegion
#Include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "LoadImageFromResourc.au3"
Opt('MustDeclareVars', 1)
Const $Style_Stretch = 1 , $Style_Tile = 2 , $Style_Center = 3 , $Style_Stretch_Center = 4 , $Style_Stretch_Tile  = 5
Global  $WM_ERASEBKGND_ARRAY[1][9]

Dim $nMsg
Local $hWnd1 = GUICreate("Form", 700, 514, 100, 100)
GUICtrlCreateButton("", 10, 30, 100,100)
GUICtrlCreateCombo("item1", 10, 150,100,100)
GUICtrlCreateLabel("LabelTxt", 10, 270,100,100)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
;GUI_REGISTER_MSG_WM_ERASEBKGND($AutoitExeFile , $hWnd , $RsName, $RsType , $ImageStyle = 1 , $BkColor = 15526360)
GUI_REGISTER_MSG_WM_ERASEBKGND( $hWnd1 , "Autoit","ImageRes", 1) ;$Style_Stretch = 1


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

Local $hWnd2 = GUICreate("Form", 700, 514, 100, 100)
GUICtrlCreateButton("", 10, 30, 100,100)
GUICtrlCreateCombo("item1", 10, 150,100,100)
GUICtrlCreateLabel("LabelTxt", 10, 270,100,100)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
;GUI_REGISTER_MSG_WM_ERASEBKGND($AutoitExeFile , $hWnd , $RsName, $RsType , $ImageStyle = 1 , $BkColor = 15526360)
GUI_REGISTER_MSG_WM_ERASEBKGND( $hWnd2 , "messenger","ImageRes", 2) ;$Style_Tile = 2

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd


Local $hWnd3 = GUICreate("Form", 700, 514, 100, 100)
GUICtrlCreateButton("", 10, 30, 100,100)
GUICtrlCreateCombo("item1", 10, 150,100,100)
GUICtrlCreateLabel("LabelTxt", 10, 270,100,100)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
;GUI_REGISTER_MSG_WM_ERASEBKGND($AutoitExeFile , $hWnd , $RsName, $RsType , $ImageStyle = 1 , $BkColor = 15526360)
GUI_REGISTER_MSG_WM_ERASEBKGND( $hWnd3 , "Autoit","ImageRes", 3) ;$Style_Center = 3

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

Local $hWnd4 = GUICreate("Form", 700, 514, 100, 100)
GUICtrlCreateButton("", 10, 30, 100,100)
GUICtrlCreateCombo("item1", 10, 150,100,100)
GUICtrlCreateLabel("LabelTxt", 10, 270,100,100)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
;GUI_REGISTER_MSG_WM_ERASEBKGND($AutoitExeFile , $hWnd , $RsName, $RsType , $ImageStyle = 1 , $BkColor = 15526360)
GUI_REGISTER_MSG_WM_ERASEBKGND( $hWnd4 , "Autoit","ImageRes", 4) ;$Style_Stretch_Center = 4


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            ExitLoop

    EndSwitch
WEnd

Local $hWnd5 = GUICreate("Form", 700, 514, 100, 100)
GUICtrlCreateButton("", 10, 30, 100,100)
GUICtrlCreateCombo("item1", 10, 150,100,100)
GUICtrlCreateLabel("LabelTxt", 10, 270,100,100)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUISetState(@SW_SHOW)
;GUI_REGISTER_MSG_WM_ERASEBKGND($AutoitExeFile , $hWnd , $RsName, $RsType , $ImageStyle = 1 , $BkColor = 15526360)
GUI_REGISTER_MSG_WM_ERASEBKGND( $hWnd5 , "messenger","ImageRes", 5) ;$Style_Stretch_Tile = 5


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd


Func WM_ERASEBKGND($hWnd, $Msg, $wParam, $lParam)

Local $MCHK = False
For $I = 0 To $WM_ERASEBKGND_ARRAY[0][0]
IF $WM_ERASEBKGND_ARRAY[$I][1] = $hWnd Then
$MCHK = True
ExitLoop
EndIf
Next
if $MCHK = False Then Return False
Local $imageobject = $WM_ERASEBKGND_ARRAY[$I][2]
Local $gdiplusOpen = $WM_ERASEBKGND_ARRAY[$I][5]
Local $ImageStyle = $WM_ERASEBKGND_ARRAY[$I][6]
Local $ImageWidth = $WM_ERASEBKGND_ARRAY[$I][3]
Local $ImageHeight = $WM_ERASEBKGND_ARRAY[$I][4]
Local $BkColor = $WM_ERASEBKGND_ARRAY[$I][8]
Local $tRect = _WinAPI_GetClientRect($hWnd)
Local $iX = DllStructGetData($tRect, "Left")
Local $iY = DllStructGetData($tRect, "Top")
Local $iR = DllStructGetData($tRect, "Right")
Local $iB = DllStructGetData($tRect, "Bottom")

Local $D_C = _WinAPI_CreateCompatibleDC($wParam)
Local $SolidBitmap = $BkColor
Local $Object = _WinAPI_SelectObject($D_C, $SolidBitmap)
StretchBlt($wParam, 0, 0 ,$iR,$iB, $D_C, 0, 0,$ImageWidth , $ImageHeight, $SRCCOPY)

if $imageobject And $gdiplusOpen Then

Local $Graphics = DllCall($gdiplusOpen,"int","GdipCreateFromHDC","hwnd",$wParam,"int*",0)
if @error Then Return False
if Not ($Graphics[0] = 0) Then Return False
$Graphics = $Graphics[2]

Select
Case $ImageStyle = 1 ;$Style_Stretch
Local $Status = DllCall($gdiplusOpen,"int","GdipDrawImageRectI","hwnd",$Graphics,"hwnd",$imageobject,"int",$iX,"int",$iY,"int",$iR,"int",$iB)
if @error Then Return False
if Not ($Status[0] = 0) Then Return False
Case $ImageStyle = 2 ;Style_Tile
For $i2 = $iY To ($iB) Step $ImageHeight
For $i1 = $iX To ($iR) Step $ImageWidth
Local $Status = DllCall($gdiplusOpen,"int","GdipDrawImageRectI","hwnd",$Graphics,"hwnd",$imageobject,"int",$i1,"int",$i2,"int",$ImageWidth,"int",$ImageHeight)
if @error Then Return False
if Not ($Status[0] = 0) Then Return False
Next
Next
Case $ImageStyle = 3 ;Style_Center
if ($ImageWidth < $iR) Then
Local $i1 = ( ($iR / 2) - ($ImageWidth / 2) )
Else
Local $i1 = 0
EndIf
if($ImageHeight < $iB) Then
Local $i2 = ( ( $iB / 2) - ($ImageHeight / 2) )
Else
Local $i2 = 0
EndIf
Local $Status = DllCall($gdiplusOpen,"int","GdipDrawImageRectI","hwnd",$Graphics,"hwnd",$imageobject,"int",$i1,"int",$i2,"int",$ImageWidth,"int",$ImageHeight)
if @error Then Return False
if Not ($Status[0] = 0) Then Return False
Case $ImageStyle = 4 ;$Style_Stretch_Center
Local $Status = DllCall($gdiplusOpen,"int","GdipDrawImageRectI","hwnd",$Graphics,"hwnd",$imageobject,"int",$iX,"int",$iY,"int",$iR,"int",$iB)
if @error Then Return False
if Not ($Status[0] = 0) Then Return False
if ($ImageWidth < $iR) Then
Local $i1 = ( ($iR / 2) - ($ImageWidth / 2) )
Else
Local $i1 = 0
EndIf
if($ImageHeight < $iB) Then
Local $i2 = ( ( $iB / 2) - ($ImageHeight / 2) )
Else
Local $i2 = 0
EndIf
Local $Status = DllCall($gdiplusOpen,"int","GdipDrawImageRectI","hwnd",$Graphics,"hwnd",$imageobject,"int",$i1,"int",$i2,"int",$ImageWidth,"int",$ImageHeight)
if @error Then Return False
if Not ($Status[0] = 0) Then Return False
Case $ImageStyle = 5 ;$Style_Stretch_Tile
Local $Status = DllCall($gdiplusOpen,"int","GdipDrawImageRectI","hwnd",$Graphics,"hwnd",$imageobject,"int",$iX,"int",$iY,"int",$iR,"int",$iB)
if @error Then Return False
if Not ($Status[0] = 0) Then Return False
For $i2 = $iY To ($iB) Step $ImageHeight
For $i1 = $iX To ($iR) Step $ImageWidth
Local $Status = DllCall($gdiplusOpen,"int","GdipDrawImageRectI","hwnd",$Graphics,"hwnd",$imageobject,"int",$i1,"int",$i2,"int",$ImageWidth,"int",$ImageHeight)
if @error Then Return False
if Not ($Status[0] = 0) Then Return False
Next
Next
Case Else
Return False
EndSelect

_WinAPI_SelectObject($D_C, $Object)
$WM_ERASEBKGND_ARRAY[$I][7] = True ;;$CHK_WM_ERASEBKGND
Return True
EndIf

EndFunc



Func GUI_REGISTER_MSG_WM_ERASEBKGND($hWnd , $RsName, $RsType , $ImageStyle = 1 , $BkColor = 15526360)
Local $MCHK = False
For $I = 0 To $WM_ERASEBKGND_ARRAY[0][0]
IF $WM_ERASEBKGND_ARRAY[$I][1] = $hWnd Then
$MCHK = True
ExitLoop
EndIf
Next
If $MCHK = False Then ;;$MCHK = False
Local $BITMAPWM_ERASEBKGND = LoadImageFromFreeResourc($RsName , $RsType , False);$GDIPlus_ShutDown =False
If IsArray($BITMAPWM_ERASEBKGND) Then
If Not ($BITMAPWM_ERASEBKGND[1][0]) Or Not ($BITMAPWM_ERASEBKGND[1][3] = "ImageTypeBitmap") Then ;;imageobject and ImageTypeBitmap
Local $GdiPlus_Dll = $BITMAPWM_ERASEBKGND[1][6] ;GdiPlus Dll Hwnd
Local $GdiPlus_Token = $BITMAPWM_ERASEBKGND[1][7] ;GdiPlus Token
DllCall($GdiPlus_Dll,"int","GdiplusShutdown","ptr",$GdiPlus_Token)
DllClose($GdiPlus_Dll)
Return -1
Else ;Not ($BITMAPWM_ERASEBKGND[1][0]) Or Not ($BITMAPWM_ERASEBKGND[1][3] = "ImageTypeBitmap")
$WM_ERASEBKGND_ARRAY[0][0] += 1
ReDim $WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0] + 1][9]
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][1] = $hWnd ;WIN handle
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][2] = $BITMAPWM_ERASEBKGND[1][0] ;imageobject
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][3] = $BITMAPWM_ERASEBKGND[1][4] ;ImageWidth
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][4] = $BITMAPWM_ERASEBKGND[1][5] ;ImageHeight
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][5] = $BITMAPWM_ERASEBKGND[1][6] ;GdiPlus Dll Hwnd
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][6] = $ImageStyle ;$ImageStyle
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][7] = False ;$CHK_WM_ERASEBKGND
$BkColor = _WinAPI_CreateSolidBitmap($hWnd, $BkColor, $BITMAPWM_ERASEBKGND[1][4], $BITMAPWM_ERASEBKGND[1][5])
$WM_ERASEBKGND_ARRAY[$WM_ERASEBKGND_ARRAY[0][0]][8] = $BkColor ;background color
$I = $WM_ERASEBKGND_ARRAY[0][0]
EndIf ;;Not ($BITMAPWM_ERASEBKGND[1][0]) Or Not ($BITMAPWM_ERASEBKGND[1][3] = "ImageTypeBitmap")
Else ;IsArray
Return -1
EndIf ;IsArray
Else ;$MCHK = True
$WM_ERASEBKGND_ARRAY[$I][1] = $hWnd ;WIN handle
$WM_ERASEBKGND_ARRAY[$I][2] = $BITMAPWM_ERASEBKGND[1][0] ;imageobject
$WM_ERASEBKGND_ARRAY[$I][3] = $BITMAPWM_ERASEBKGND[1][4] ;ImageWidth
$WM_ERASEBKGND_ARRAY[$I][4] = $BITMAPWM_ERASEBKGND[1][5] ;ImageHeight
$WM_ERASEBKGND_ARRAY[$I][5] = $BITMAPWM_ERASEBKGND[1][6] ;GdiPlus Dll Hwnd
$WM_ERASEBKGND_ARRAY[$I][6] = $ImageStyle ;$ImageStyle
$WM_ERASEBKGND_ARRAY[$I][7] = False ;$CHK_WM_ERASEBKGND
$BkColor = _WinAPI_CreateSolidBitmap($hWnd, $BkColor, $BITMAPWM_ERASEBKGND[1][4], $BITMAPWM_ERASEBKGND[1][5])
$WM_ERASEBKGND_ARRAY[$I][8] = $BkColor ;background color
EndIf ;$MCHK
GUIRegisterMsg($WM_ERASEBKGND, "WM_ERASEBKGND")
_WinAPI_RedrawWindow($hWnd)
if ($WM_ERASEBKGND_ARRAY[$I][7] = False ) Then Return -2 ;;$CHK_WM_ERASEBKGND
Return True
EndFunc


Func StretchBlt($hdcDest,$nXOriginDest,$nYOriginDest,$nWidthDest,$nHeightDest,$hdcSrc,$nXOriginSrc, _
$nYOriginSrc,$nWidthSrc,$nHeightSrc,$dwRop)
Local $DllCall = DllCall("Gdi32.dll" ,"int","StretchBlt","hwnd",$hdcDest,"int",$nXOriginDest,"int",$nYOriginDest,"int",$nWidthDest , _
"int",$nHeightDest,"hwnd",$hdcSrc,"int",$nXOriginSrc,"int",$nYOriginSrc,"int",$nWidthSrc,"int",$nHeightSrc,"long",$dwRop)
Return $DllCall[0]
EndFunc

UPD_RES_ERASEBKGND.EXE.au3

#Include "UpdateRes_Au3ExeFile.au3"
UpdateFreeResource("ERASEBKGND_NO_UPX.EXE","AutoitImage.png","Autoit","ImageRes")
UpdateFreeResource("ERASEBKGND_NO_UPX.EXE","messenger.gif","messenger","ImageRes")
Edited by wolf9228

صرح السماء كان هنا

 

Share this post


Link to post
Share on other sites



wolf9228,

This looks interesting but what does it do?

Regards,

4Eyes

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0