wolf9228 Posted July 12, 2012 Posted July 12, 2012 (edited) Allows the project to register and receive messages to specific functions All FilesRegMsg.zip RegisterMsg.au3 expandcollapse popup#include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include <Constants.au3> #include <WinAPI.au3> Global $Hookhandle = 0, $GUIRegMsgProcA = 0, $RegisterMsgArray[1][2],$RegNotficCodeArray[1][2] _ ,$WPhandle = 0,$GUIRegMsgProcB = 0,$CurrentwParam = 0,$CurrentlParam = 0,$GUIRegMsgProcBPtr = 0 , _ $Organize_WM_COMMAND_NotficCode = True ,$Test_WM_COMMAND_NotficCode = True,$CurrentParenthWnd = 0 _ ,$ParentWinsArray[1] Func GUIRegisterMsgEx($hWndParent,$Message,$MsgProcName) if (Not (_WinAPI_IsWindow($hWndParent)) Or _WinAPI_GetParent($hWndParent)) Then Return False Local $ElementsA , $ElementsB , $MsgAndProcArray[1][2] , $RegMsgProc $RegMsgProc = DllCallbackRegister($MsgProcName,"LRESULT","HWND;UINT;WPARAM;LPARAM") if @error Then Return False DllCallbackFree($RegMsgProc) if (Not($Hookhandle)) Then Local $lpdwProcessId,$HMOD $GUIRegMsgProcA = DllCallbackRegister("GUIRegMsgProcA","LRESULT","INT;WPARAM;LPARAM") if @error Then Return False $GUIRegMsgProcB = DllCallbackRegister("GUIRegMsgProcB","LRESULT","HWND;UINT;WPARAM;LPARAM") if @error Then DllCallbackFree($GUIRegMsgProcA) Return False EndIf $GUIRegMsgProcBPtr = DllCallbackGetPtr($GUIRegMsgProcB) $HMOD = _WinAPI_GetModuleHandle(0) $Hookhandle = _WinAPI_SetWindowsHookEx($WH_CALLWNDPROC,DllCallbackGetPtr($GUIRegMsgProcA) _ ,$HMOD,_WinAPI_GetWindowThreadProcessId($hWndParent,$lpdwProcessId)) if (Not($Hookhandle)) Then DllCallbackFree($GUIRegMsgProcA) DllCallbackFree($GUIRegMsgProcB) Return False EndIf OnAutoItExitRegister("atGUIRegisterMsgExit") EndIf $ElementsA = ArraySearch($RegisterMsgArray,$hWndParent,0) if ($ElementsA <> -1) Then $MsgAndProcArray = $RegisterMsgArray[$ElementsA][1] $ElementsB = ArraySearch($MsgAndProcArray,$Message,0) if ($ElementsB <> -1) Then $MsgAndProcArray[$ElementsB][1] = $MsgProcName $RegisterMsgArray[$ElementsA][1] = $MsgAndProcArray Else ReDim $MsgAndProcArray[UBound($MsgAndProcArray) + 1][2] $MsgAndProcArray[UBound($MsgAndProcArray) - 2][0] = $Message $MsgAndProcArray[UBound($MsgAndProcArray) - 2][1] = $MsgProcName $RegisterMsgArray[$ElementsA][1] = $MsgAndProcArray EndIf Else ReDim $RegisterMsgArray[UBound($RegisterMsgArray) + 1][2] ReDim $MsgAndProcArray[UBound($MsgAndProcArray) + 1][2] $RegisterMsgArray[UBound($RegisterMsgArray) - 2][0] = $hWndParent $MsgAndProcArray[UBound($MsgAndProcArray) - 2][0] = $Message $MsgAndProcArray[UBound($MsgAndProcArray) - 2][1] = $MsgProcName $RegisterMsgArray[UBound($RegisterMsgArray) - 2][1] = $MsgAndProcArray EndIf $ElementsA = ArraySearch($ParentWinsArray,$hWndParent) if ($ElementsA = -1) Then $ParentWinsArray[UBound($ParentWinsArray) - 1] = $hWndParent ReDim $ParentWinsArray[UBound($ParentWinsArray) + 1] EndIf Return True EndFunc Func UnGUIRegisterMsgEx($hWndParent,$Message) if (Not (_WinAPI_IsWindow($hWndParent)) Or _WinAPI_GetParent($hWndParent)) Then Return False $ElementsA = ArraySearch($RegisterMsgArray,$hWndParent,0) if ($ElementsA <> -1) Then $MsgAndProcArray = $RegisterMsgArray[$ElementsA][1] $ElementsB = ArraySearch($MsgAndProcArray,$Message,0) if ($ElementsB <> -1) Then if UBound($MsgAndProcArray) > 2 Then Local $NewMsgAndProcArray[UBound($MsgAndProcArray) - 1][2] , $j = 0 For $i = 0 To UBound($MsgAndProcArray) - 1 if $ElementsB = $i Then ContinueLoop $NewMsgAndProcArray[$j][0] = $MsgAndProcArray[$i][0] $NewMsgAndProcArray[$j][1] = $MsgAndProcArray[$i][1] $j += 1 Next $RegisterMsgArray[$ElementsA][1] = $NewMsgAndProcArray Else Local $NewMsgAndProcArray[1][2] $RegisterMsgArray[$ElementsA][1] = $NewMsgAndProcArray EndIf Else Return False EndIf Else Return False EndIf Return True EndFunc Func GUICtrlSetOnEventEx($ControlID,$NotficCode,$NCodeProcName) if Not IsHWnd($ControlID) Then $ControlID = GUICtrlGetHandle($ControlID) if (Not (_WinAPI_IsWindow($ControlID)) Or Not(_WinAPI_GetParent($ControlID))) Then Return False Local $ElementsA , $ElementsB , $NCodeAndProcArray[1][2] , $RegNCodeProc $RegNCodeProc = DllCallbackRegister($NCodeProcName,"NONE","HWND;INT;INT") if @error Then Return False DllCallbackFree($RegNCodeProc) if (Not($Hookhandle)) Then Local $lpdwProcessId,$HMOD $GUIRegMsgProcA = DllCallbackRegister("GUIRegMsgProcA","LRESULT","INT;WPARAM;LPARAM") if @error Then Return False $GUIRegMsgProcB = DllCallbackRegister("GUIRegMsgProcB","LRESULT","HWND;UINT;WPARAM;LPARAM") if @error Then DllCallbackFree($GUIRegMsgProcA) Return False EndIf $GUIRegMsgProcBPtr = DllCallbackGetPtr($GUIRegMsgProcB) $HMOD = _WinAPI_GetModuleHandle(0) $Hookhandle = _WinAPI_SetWindowsHookEx($WH_CALLWNDPROC,DllCallbackGetPtr($GUIRegMsgProcA) _ ,$HMOD,_WinAPI_GetWindowThreadProcessId($ControlID,$lpdwProcessId)) if (Not($Hookhandle)) Then DllCallbackFree($GUIRegMsgProcA) DllCallbackFree($GUIRegMsgProcB) Return False EndIf OnAutoItExitRegister("atGUIRegisterMsgExit") EndIf $ElementsA = ArraySearch($RegNotficCodeArray,$ControlID,0) if ($ElementsA <> -1) Then $NCodeAndProcArray = $RegNotficCodeArray[$ElementsA][1] $ElementsB = ArraySearch($NCodeAndProcArray,$NotficCode,0) if ($ElementsB <> -1) Then $NCodeAndProcArray[$ElementsB][1] = $NCodeProcName $RegNotficCodeArray[$ElementsA][1] = $NCodeAndProcArray Else ReDim $NCodeAndProcArray[UBound($NCodeAndProcArray) + 1][2] $NCodeAndProcArray[UBound($NCodeAndProcArray) - 2][0] = $NotficCode $NCodeAndProcArray[UBound($NCodeAndProcArray) - 2][1] = $NCodeProcName $RegNotficCodeArray[$ElementsA][1] = $NCodeAndProcArray EndIf Else ReDim $RegNotficCodeArray[UBound($RegNotficCodeArray) + 1][2] ReDim $NCodeAndProcArray[UBound($NCodeAndProcArray) + 1][2] $RegNotficCodeArray[UBound($RegNotficCodeArray) - 2][0] = $ControlID $NCodeAndProcArray[UBound($NCodeAndProcArray) - 2][0] = $NotficCode $NCodeAndProcArray[UBound($NCodeAndProcArray) - 2][1] = $NCodeProcName $RegNotficCodeArray[UBound($RegNotficCodeArray) - 2][1] = $NCodeAndProcArray EndIf $ElementsA = ArraySearch($ParentWinsArray,_WinAPI_GetParent($ControlID)) if ($ElementsA = -1) Then $ParentWinsArray[UBound($ParentWinsArray) - 1] = _WinAPI_GetParent($ControlID) ReDim $ParentWinsArray[UBound($ParentWinsArray) + 1] EndIf Return True EndFunc Func UnGUICtrlSetOnEventEx($ControlID,$NotficCode) if Not IsHWnd($ControlID) Then $ControlID = GUICtrlGetHandle($ControlID) if (Not (_WinAPI_IsWindow($ControlID)) Or Not(_WinAPI_GetParent($ControlID))) Then Return False $ElementsA = ArraySearch($RegNotficCodeArray,$ControlID,0) if ($ElementsA <> -1) Then $NCodeAndProcArray = $RegNotficCodeArray[$ElementsA][1] $ElementsB = ArraySearch($NCodeAndProcArray,$NotficCode,0) if ($ElementsB <> -1) Then if UBound($NCodeAndProcArray) > 2 Then Local $NewNCodeAndProcArray[UBound($NCodeAndProcArray) - 1][2] , $j = 0 For $i = 0 To UBound($NCodeAndProcArray) - 1 if $ElementsB = $i Then ContinueLoop $NewNCodeAndProcArray[$j][0] = $NCodeAndProcArray[$i][0] $NewNCodeAndProcArray[$j][1] = $NCodeAndProcArray[$i][1] $j += 1 Next $RegNotficCodeArray[$ElementsA][1] = $NewNCodeAndProcArray Else Local $NewNCodeAndProcArray[1][2] $RegNotficCodeArray[$ElementsA][1] = $NewNCodeAndProcArray EndIf Else Return False EndIf Else Return False EndIf Return True EndFunc Func GUIRegMsgProcA($nCode,$wParam,$lParam) if ($nCode < 0) Then Return _WinAPI_CallNextHookEx($Hookhandle,$nCode,$wParam,$lParam) Local $ElementsA = -1,$ElementsB = -1,$ElementsC = -1,$ElementsD = -1,$ihwnd = 0,$iMessage = 0 Local $tagCWPSTRUCT,$CWPSTRUCT,$CtrlHwnd,$NotficCode,$ControlID,$iNMHDR $xtagCWPSTRUCT = "LPARAM lParam;WPARAM wParam;UINT message;HWND hwnd" $CWPSTRUCT = DllStructCreate($xtagCWPSTRUCT,$lParam) $iMessage = DllStructGetData($CWPSTRUCT,"message") $ihwnd = DllStructGetData($CWPSTRUCT,"hwnd") Switch ($iMessage) Case $WM_COMMAND $CtrlHwnd = HWnd(DllStructGetData($CWPSTRUCT,"lParam")) $NotficCode = _WinAPI_HiWord(DllStructGetData($CWPSTRUCT,"wParam")) $ControlID = _WinAPI_LoWord(DllStructGetData($CWPSTRUCT,"wParam")) $ElementsC = ArraySearch($RegNotficCodeArray,$CtrlHwnd,0) if ($ElementsC <> -1) Then _ $ElementsD = ArraySearch($RegNotficCodeArray[$ElementsC][1],$NotficCode,0) Case $WM_NOTIFY Local $xtagNMHDR = "HWND hwndFrom;UINT_PTR idFrom;UINT code" $iNMHDR = DllStructCreate($xtagNMHDR,DllStructGetData($CWPSTRUCT,"lParam")) $CtrlHwnd = DllStructGetData($iNMHDR,"hwndFrom") $NotficCode = DllStructGetData($iNMHDR,"code") $ControlID = DllStructGetData($iNMHDR,"idFrom") $ElementsC = ArraySearch($RegNotficCodeArray,$CtrlHwnd,0) if ($ElementsC <> -1) Then _ $ElementsD = ArraySearch($RegNotficCodeArray[$ElementsC][1],$NotficCode,0) EndSwitch $ElementsA = ArraySearch($RegisterMsgArray,$ihwnd,0) if ($ElementsA <> -1) Then $ElementsB = ArraySearch($RegisterMsgArray[$ElementsA][1],$iMessage,0) if ($ElementsB = -1 And $ElementsD = -1) Then Return _ _WinAPI_CallNextHookEx($Hookhandle,$nCode,$wParam,$lParam) if Not ($WPhandle) Then $WPhandle = _WinAPI_SetWindowLong($ihwnd,$GWL_WNDPROC,$GUIRegMsgProcBPtr) Else _WinAPI_SetWindowLong($ihwnd,$GWL_WNDPROC,$GUIRegMsgProcBPtr) EndIf Return _WinAPI_CallNextHookEx($Hookhandle,$nCode,$wParam,$lParam) EndFunc Func GUIRegMsgProcB($hWnd,$Message,$wParam,$lParam) Local $ElementsA = -1,$ElementsB = -1,$ElementsC = -1,$ElementsD = -1,$CtrlHwnd,$NotficCode Local $ControlID,$CurrentProcC = "" , $CurrentProcD = "",$xtagNMHDR,$iNMHDR,$NCodeAndProcArray Local $MsgAndProcArray,$pReturn $CurrentwParam = 0 $CurrentlParam = 0 $CurrentParenthWnd = 0 Switch ($Message) Case $WM_COMMAND $CtrlHwnd = HWnd($lParam) $NotficCode = _WinAPI_HiWord($wParam) $ControlID = _WinAPI_LoWord($wParam) $ElementsC = ArraySearch($RegNotficCodeArray,$CtrlHwnd,0) if ($ElementsC <> -1) Then _ $ElementsD = ArraySearch($RegNotficCodeArray[$ElementsC][1],$NotficCode,0) if ($ElementsD <> -1) Then $NCodeAndProcArray = $RegNotficCodeArray[$ElementsC][1] $CurrentwParam = $wParam $CurrentlParam = $lParam $CurrentParenthWnd = $hWnd $CurrentProcC = $NCodeAndProcArray[$ElementsD][1] if ($Organize_WM_COMMAND_NotficCode = True) Then if ($Test_WM_COMMAND_NotficCode = True) Then $Test_WM_COMMAND_NotficCode = False Call($CurrentProcC,$CtrlHwnd,$ControlID,$NotficCode) $Test_WM_COMMAND_NotficCode = True EndIf Else Call($CurrentProcC,$CtrlHwnd,$ControlID,$NotficCode) EndIf EndIf Case $WM_NOTIFY $xtagNMHDR = "HWND hwndFrom;UINT_PTR idFrom;UINT code" $iNMHDR = DllStructCreate($xtagNMHDR,$lParam) $CtrlHwnd = DllStructGetData($iNMHDR,"hwndFrom") $NotficCode = DllStructGetData($iNMHDR,"code") $ControlID = DllStructGetData($iNMHDR,"idFrom") $ElementsC = ArraySearch($RegNotficCodeArray,$CtrlHwnd,0) if ($ElementsC <> -1) Then _ $ElementsD = ArraySearch($RegNotficCodeArray[$ElementsC][1],$NotficCode,0) if ($ElementsD <> -1) Then $NCodeAndProcArray = $RegNotficCodeArray[$ElementsC][1] $CurrentwParam = $wParam $CurrentlParam = $lParam $CurrentParenthWnd = $hWnd $CurrentProcC = $NCodeAndProcArray[$ElementsD][1] Call($CurrentProcC,$CtrlHwnd,$ControlID,$NotficCode) EndIf EndSwitch $ElementsA = ArraySearch($RegisterMsgArray,$hwnd,0) if ($ElementsA <> -1) Then $ElementsB = ArraySearch($RegisterMsgArray[$ElementsA][1],$Message,0) if ($ElementsB <> -1) Then $MsgAndProcArray = $RegisterMsgArray[$ElementsA][1] $CurrentProcD = $MsgAndProcArray[$ElementsB][1] $pReturn = Call($CurrentProcD,$hWnd,$Message,$wParam,$lParam) if ($pReturn) Then Return $pReturn EndIf return _WinAPI_CallWindowProc($WPhandle,$hWnd,$Message,$wParam,$lParam) EndFunc Func GetwParam() Return $CurrentwParam EndFunc Func GetlParam() Return $CurrentlParam EndFunc Func GetParenthWnd() Return $CurrentParenthWnd EndFunc Func ArraySearch($Array,$Value,$ColIndex = -1) if ($ColIndex == -1) Then For $i = 0 To UBound($Array) - 1 if $Array[$i] == $Value Then Return $i Next Else if ($ColIndex < 0 Or $ColIndex > (UBound($Array,2) - 1)) Then Return -1 For $i = 0 To UBound($Array) - 1 if $Array[$i][$ColIndex] == $Value Then Return $i Next EndIf Return -1 EndFunc Func atGUIRegisterMsgExit() For $i = 0 To UBound($ParentWinsArray) - 1 if _WinAPI_IsWindow($ParentWinsArray[$i]) Then _WinAPI_DestroyWindow($ParentWinsArray[$i]) Next _WinAPI_UnhookWindowsHookEx($Hookhandle) DllCallbackFree($GUIRegMsgProcA) DllCallbackFree($GUIRegMsgProcB) EndFuncExample1.au3 expandcollapse popup#Include <GuiButton.au3> #Include "RegisterMsg.au3" ; GUICtrlSetOnEventEx($ControlID,$NotficCode,$NCodeProcName) ;$NotficCode ==> (WM_COMMAND Notification Code And WM_NOTIFY Notification Code) GUICreate("My GUI Button") $Button_1 = GUICtrlCreateButton("Clicked Button 1", 10,30,200,30,$BS_NOTIFY) GUICtrlSetOnEventEx($Button_1,$BN_CLICKED,"ClickedButton_1") GUICtrlSetOnEventEx($Button_1,$BN_SETFOCUS,"SetFocusButton_1") GUICtrlSetOnEventEx($Button_1,$BN_KILLFOCUS,"KillFocusButton_1") GUICtrlSetOnEventEx($Button_1,$BCN_HOTITEMCHANGE,"HotitemChanegButton_1") $Button_2 = GUICtrlCreateButton("Dblclk Button 2", 10,70,200,30,$BS_NOTIFY) GUICtrlSetOnEventEx($Button_2,$BN_DBLCLK,"DblclkButton_2") GUICtrlSetOnEventEx($Button_2,$BN_SETFOCUS,"SetFocusButton_2") GUICtrlSetOnEventEx($Button_2,$BN_KILLFOCUS,"KillFocusButton_2") GUICtrlSetOnEventEx($Button_2,$BCN_HOTITEMCHANGE,"HotitemChanegButton_2") $Button_3 = GUICtrlCreateButton("Button 3", 10,110,200,30) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_3 MsgBox(0, 'Testing', 'Button 3 was pressed') EndSelect WEnd Exit Func ClickedButton_1($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() MsgBox(0,"MSG","Clicked Button_1") EndFunc Func SetFocusButton_1($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() TrayTip("MSG", "SetFocus Button_1", 5, 1) EndFunc Func KillFocusButton_1($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() TrayTip("MSG", "KillFocus Button_1", 5, 1) EndFunc Func HotitemChanegButton_1($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() TrayTip("MSG", "HotitemChaneg Button_1", 5, 1) EndFunc Func DblclkButton_2($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() MsgBox(0,"MSG","Dblclk Button_2") EndFunc Func SetFocusButton_2($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() TrayTip("MSG", "SetFocus Button_2", 5, 1) EndFunc Func KillFocusButton_2($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() TrayTip("MSG", "KillFocus Button_2", 5, 1) EndFunc Func HotitemChanegButton_2($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() TrayTip("MSG", "HotitemChaneg Button_2", 5, 1) EndFuncExample2.au3 expandcollapse popup#include <GUIComboBox.au3> #Include "RegisterMsg.au3" ; GUICtrlSetOnEventEx($ControlID,$NotficCode,$NCodeProcName) ;$NotficCode ==> (WM_COMMAND Notification Code And WM_NOTIFY Notification Code) $hGUI = GUICreate("(UDF) ComboBox Create", 400, 296) $ComboBox = _GUICtrlComboBox_Create($hGUI, "", 2, 20, 396, 296) GUICtrlSetOnEventEx($ComboBox,$CBN_CLOSEUP,"CLOSEUP") GUICtrlSetOnEventEx($ComboBox,$CBN_DROPDOWN,"DROPDOWN") GUICtrlSetOnEventEx($ComboBox,$CBN_SELCHANGE,"SELCHANGE") GUISetState() _GUICtrlComboBox_BeginUpdate($ComboBox) _GUICtrlComboBox_AddDir($ComboBox, "", $DDL_DRIVES, False) _GUICtrlComboBox_EndUpdate($ComboBox) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() Func CLOSEUP($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() MsgBox(0,"MSG","CLOSEUP") EndFunc Func DROPDOWN($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() MsgBox(0,"MSG","DROPDOWN") EndFunc Func SELCHANGE($CtrlHwnd,$ControlID,$NotficCode) $WPARAM = GetwParam() $LPARAM = GetlParam() $HWND = GetParenthWnd() MsgBox(0,"MSG","SELCHANGE") EndFuncExample3.au3 expandcollapse popup#include <GDIPlus.au3> #Include "RegisterMsg.au3" $hGUIA = GUICreate("My GUI A") GUISetState() _GDIPlus_Startup() $hImageA = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\BKGNDA.bmp") $BmpWidthA = _GDIPlus_ImageGetWidth($hImageA) $BmpHeightA = _GDIPlus_ImageGetHeight($hImageA) $hBmpImageA = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageA) _GDIPlus_ImageDispose($hImageA) _GDIPlus_Shutdown() GUIRegisterMsgEx($hGUIA,0x0014,"WM_ERASEBKGND_A") ; 0x0014 ==> WM_ERASEBKGND Msg RedrawWindow($hGUIA,0,0,5) $hGUIB = GUICreate("My GUI B") GUISetState() _GDIPlus_Startup() $hImageB = _GDIPlus_ImageLoadFromFile(@ScriptDir & "\BKGNDB.bmp") $BmpWidthB = _GDIPlus_ImageGetWidth($hImageB) $BmpHeightB = _GDIPlus_ImageGetHeight($hImageB) $hBmpImageB = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImageB) _GDIPlus_ImageDispose($hImageB) _GDIPlus_Shutdown() GUIRegisterMsgEx($hGUIB,0x0014,"WM_ERASEBKGND_B") ; 0x0014 ==> WM_ERASEBKGND Msg RedrawWindow($hGUIB,0,0,5) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd Exit Func WM_ERASEBKGND_A($hWnd, $Msg, $wParam, $lParam) if ($hBmpImageA) Then Local $BGhWnd = WindowFromDC($wParam) $Pos = WinGetClientSize($BGhWnd) $hdc = CreateCompatibleDC($wParam) $HGDIOBJ = SelectObject($hdc,$hBmpImageA) StretchBlt($wParam,0,0,$Pos[0],$Pos[1],$hdc,0,0,$BmpWidthA,$BmpHeightA,0x00CC0020) ;0x00CC0020 ==> SRCCOPY $HGDIOBJ = SelectObject($hdc,$HGDIOBJ) Return True EndIf EndFunc Func WM_ERASEBKGND_B($hWnd, $Msg, $wParam, $lParam) if ($hBmpImageB) Then Local $BGhWnd = WindowFromDC($wParam) $Pos = WinGetClientSize($BGhWnd) $hdc = CreateCompatibleDC($wParam) $HGDIOBJ = SelectObject($hdc,$hBmpImageB) StretchBlt($wParam,0,0,$Pos[0],$Pos[1],$hdc,0,0,$BmpWidthB,$BmpHeightB,0x00CC0020) ;0x00CC0020 ==> SRCCOPY $HGDIOBJ = SelectObject($hdc,$HGDIOBJ) Return True EndIf EndFunc Func StretchBlt($hdcDest,$nXOriginDest,$nYOriginDest,$nWidthDest,$nHeightDest,$hdcSrc,$nXOriginSrc, _ $nYOriginSrc,$nWidthSrc,$nHeightSrc,$dwRop) $Rt = DllCall("Gdi32.dll" ,"BOOL","StretchBlt","ptr",$hdcDest,"int",$nXOriginDest,"int",$nYOriginDest,"int",$nWidthDest , _ "int",$nHeightDest,"ptr",$hdcSrc,"int",$nXOriginSrc,"int",$nYOriginSrc,"int",$nWidthSrc,"int",$nHeightSrc,"DWORD",$dwRop) if @error Or $Rt[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$Rt[0]) EndFunc Func CreateCompatibleDC($hdc) $HDC = DllCall("Gdi32.dll" ,"ptr","CreateCompatibleDC","ptr",$hdc) if @error Or $HDC[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HDC[0]) EndFunc Func SelectObject($hdc,$hgdiobj) $HGDIOBJ = DllCall("Gdi32.dll" ,"ptr","SelectObject","ptr",$hdc,"ptr",$hgdiobj) if @error Or $HGDIOBJ[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HGDIOBJ[0]) EndFunc Func DeleteObject($hObject) $Rt = DllCall("Gdi32.dll","BOOL","DeleteObjectW","ptr",$hObject) if @error Or $Rt[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$Rt[0]) EndFunc Func WindowFromDC($hDC) $HWND = DllCall("User32.dll","ptr","WindowFromDC","ptr",$hdc) if @error Or $HWND[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$HWND[0]) EndFunc Func RedrawWindow($hWnd,$lprcUpdate,$hrgnUpdate,$flags) $BOOL = DllCall("User32.dll","BOOL","RedrawWindow","ptr",$hWnd,"ptr",$lprcUpdate _ ,"ptr",$hrgnUpdate,"UINT",$flags) if @error Or $BOOL[0] = 0 Then Return SetError(1,0,0) Return SetError(0,0,$BOOL[0]) EndFunc Edited November 10, 2014 by wolf9228 صرح السماء كان هنا
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