wolf9228 Posted October 11, 2010 Share Posted October 11, 2010 (edited) New ScriptButtonHover2.rarA simple mistake in the type of data through functionsButtonHoverDelete($controlID)ButtonHoverSetState($controlID,$ENABLE = 1,$SHOW = 1)ButtonHoverSetPos($controlID,$Left,$Top,$Width,$Height)mistake in this lineif Not ($count) Then Return FalseLine correctlyif Not int($count) Then Return FalseStatic_Example.au3expandcollapse popup#include <Static_ButtonHover.au3> #include "Data.au3" $NhBMP = LoadBitmap_FromFile("NORMAL.bmp") $PhBMP = LoadBitmap_FromFile("PRESS.bmp") $OhBMP = LoadBitmap_FromFile("OVER.bmp") $COLOR_Or_HBITMAP = LoadBitmap_FromFile("BKGND.bmp") Global $misc1 = WavFile() ;file WAVE ;Data.au3 $ByteStruct = DllStructCreate("BYTE[" & StringLen($misc1) / 2 & "]") DllStructSetData($ByteStruct,1,$misc1) $BytePtr = DllStructGetPtr($ByteStruct) $TEXTCOLOOR = 0x1F1F1F $GUI = GUICreate("Static_ButtonHover") GuiSetBackGroundImage($GUI,$COLOR_Or_HBITMAP) GuiSetBackGroundSound($BytePtr) $Button_A = CreateButtonHover ("ButtonA", 180, 80, 70, 15,$NhBMP,$PhBMP,$OhBMP,$TEXTCOLOOR) GUICtrlSetFont(@extended, 8, 800, 0, "Arial") ; @extended oR -1 $Button_B = CreateButtonHover ("ButtonB", 180, 120, 90, 30,$NhBMP,$PhBMP,$OhBMP,$TEXTCOLOOR) GUICtrlSetFont(-1, 12, 800, 0, "Arial") ; @extended oR -1 $Button_C = CreateButtonHover ("ButtonC", 180, 180, 190, 30,$NhBMP,$PhBMP,$OhBMP,$TEXTCOLOOR) GUICtrlSetFont(@extended, 16, 800, 0, "Arial") ; @extended oR -1 $Button_D = CreateButtonHover ("ButtonD", 180, 240, 190, 60, $NhBMP,$PhBMP,$OhBMP,$TEXTCOLOOR) GUICtrlSetFont(-1, 20, 800, 0, "Arial") ; @extended oR -1 GUISetState(@SW_SHOW) While 1 $MSG = GUIGetMsg() Switch $MSG Case $GUI_EVENT_CLOSE Exit Case $Button_A MsgBox(0,"MSG","Button_A") Case $Button_B MsgBox(0,"MSG","Button_B") Case $Button_C MsgBox(0,"MSG","Button_C") Case $Button_D MsgBox(0,"MSG","Button_D") EndSwitch WEndStatic_ButtonHover.au3expandcollapse popup#Include <WinAPI.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StaticConstants.au3> #include <Constants.au3> Global $ButtonHoverStruct = 0 , $TagButtonHoverStruct = "" , _ $BackGroundStruct = 0 , $TagBackGroundStruct = "" OnAutoItExitRegister("Cleanup") Func CreateButtonHover($Text,$L,$T,$W,$H,$NhBMP,$PhBMP,$OhBMP,$TEXTCOLOOR = 0,$Font = 0) Local $STM_SETIMAGE_HOVER = 0x0172 , $SS_BITMAP_HOVER = 0x0000000E _ , $SS_REALSIZECONTROL_HOVER = 0x00000040 , $iPID_HOVER = 0 $controlID1 = GUICtrlCreateLabel("",$L,$T,$W,$H,$SS_REALSIZECONTROL_HOVER + $SS_BITMAP_HOVER + $SS_NOTIFY) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) $HWNDA = GUICtrlGetHandle($controlID1) $USER = GUICtrlCreateDummy() $controlID2 = GUICtrlCreateLabel($Text,$L,$T,$W,$H, $SS_CENTERIMAGE + $SS_CENTER) if ($TEXTCOLOOR) Then GUICtrlSetColor(-1,$TEXTCOLOOR) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT) if ($Font) Then GUICtrlSetFont(-1,(($H) / 2) - 1, 600, 0, "Arial") $HWNDB = GUICtrlGetHandle($controlID2) Local $count if Not IsDllStruct($ButtonHoverStruct) Then $hmod = _WinAPI_GetModuleHandle(0) $DLLREGISTER = DllCallbackRegister("ButtonHoverProc", "long", "int;wparam;lparam") $DLLPTR = DllCallbackGetPtr($DLLREGISTER) $HHOOK = _WinAPI_SetWindowsHookEx($WH_MOUSE,$DLLPTR,$hmod, _ _WinAPI_GetWindowThreadProcessId(_WinAPI_GetParent($HWNDA),$iPID_HOVER)) $count = "1" $TagButtonHoverStruct = _ "INT COUNT;HANDLE DLLREGISTER;HANDLE HHOOK;INT MOUSEFIRST;INT LBUTTONDOWN;" & _ "HWND HOVER;INT " & String($HWNDA) & ";HWND HWNDA" & $count & ";HWND HWNDB" & $count & _ ";INT USER" & $count & ";HANDLE NhBMP" & $count & ";HANDLE PhBMP" & $count & _ ";HANDLE OhBMP" & $count $ButtonHoverStruct = DllStructCreate($TagButtonHoverStruct) DllStructSetData($ButtonHoverStruct,"COUNT",Int($count)) DllStructSetData($ButtonHoverStruct,String($HWNDA),Int($count)) DllStructSetData($ButtonHoverStruct,"DLLREGISTER",$DLLREGISTER) DllStructSetData($ButtonHoverStruct,"HHOOK",$HHOOK) DllStructSetData($ButtonHoverStruct,"MOUSEFIRST",0) DllStructSetData($ButtonHoverStruct,"LBUTTONDOWN",0) DllStructSetData($ButtonHoverStruct,"HOVER",0) Else Local $count = String(DllStructGetData($ButtonHoverStruct,"COUNT") + 1) Local $iLength = DllStructGetSize($ButtonHoverStruct) $TagButtonHoverStruct &= _ ";INT " & String($HWNDA) & ";HWND HWNDA" & $count & ";HWND HWNDB" & $count & _ ";INT USER" & $count & ";HANDLE NhBMP" & $count & ";HANDLE PhBMP" & $count & _ ";HANDLE OhBMP" & $count $iButtonHoverStruct = DllStructCreate($TagButtonHoverStruct) DllCall("kernel32.dll","none","RtlMoveMemory","ptr",DllStructGetPtr($iButtonHoverStruct) _ ,"ptr",DllStructGetPtr($ButtonHoverStruct),"ulong_ptr",$iLength) $ButtonHoverStruct = $iButtonHoverStruct DllStructSetData($ButtonHoverStruct,"COUNT",Int($count)) DllStructSetData($ButtonHoverStruct,String($HWNDA),Int($count)) EndIf DllStructSetData($ButtonHoverStruct,"HWNDA" & $count,$HWNDA) DllStructSetData($ButtonHoverStruct,"HWNDB" & $count,$HWNDB) DllStructSetData($ButtonHoverStruct,"USER" & $count,$USER) DllStructSetData($ButtonHoverStruct,"NhBMP" & $count,$NhBMP) DllStructSetData($ButtonHoverStruct,"PhBMP" & $count,$PhBMP) DllStructSetData($ButtonHoverStruct,"OhBMP" & $count,$OhBMP) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$NhBMP) Return SetError (0, $controlID2,$USER) EndFunc ;$controlID ==> Return CreateButtonHover Func ButtonHoverDelete($controlID) $HWNDA = GUICtrlGetHandle($controlID - 1) if Not ($HWNDA) Then Return False $count = String(DllStructGetData($ButtonHoverStruct,String($HWNDA))) if Not int($count) Then Return False $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) $USER = DllStructGetData($ButtonHoverStruct,"USER" & $count) $ButtonHoverPtr = DllStructGetPtr($ButtonHoverStruct) $Size1 = DllStructGetSize($ButtonHoverStruct) $Size2 = DllStructGetSize( _ DllStructCreate( _ "INT COUNT;HANDLE DLLREGISTER;HANDLE HHOOK;INT MOUSEFIRST;INT LBUTTONDOWN;" & _ "HWND HOVER")) $Size3 = DllStructGetSize( _ DllStructCreate( _ "INT " & String($HWNDA) & ";HWND HWNDA" & $count & ";HWND HWNDB" & _ $count & ";INT USER" & $count & ";HANDLE NhBMP" & $count & ";HANDLE PhBMP" & $count & _ ";HANDLE OhBMP" & $count)) $PriorBeforeCount = (($count - 1) * $Size3) + $Size2 $PriorAfterCount = ($count * $Size3) + $Size2 $TagButtonHoverStruct = StringReplace($TagButtonHoverStruct, _ ";INT " & String($HWNDA) & ";HWND HWNDA" & $count & ";HWND HWNDB" & _ $count & ";INT USER" & $count & ";HANDLE NhBMP" & $count & ";HANDLE PhBMP" & $count & _ ";HANDLE OhBMP" & $count,"") $iButtonHoverStruct = DllStructCreate($TagButtonHoverStruct) $iButtonHoverPtr = DllStructGetPtr($iButtonHoverStruct) DllCall("kernel32.dll","none","RtlMoveMemory","ptr",$iButtonHoverPtr,"ptr",$ButtonHoverPtr, _ "ulong_ptr",$PriorBeforeCount) $OutPtrA = DllStructGetPtr($iButtonHoverStruct) + $PriorBeforeCount $OutPtrB = DllStructGetPtr($ButtonHoverStruct) + $PriorAfterCount DllCall("kernel32.dll","none","RtlMoveMemory","ptr",$OutPtrA,"ptr",$OutPtrB,"ulong_ptr", _ $Size1 - $PriorAfterCount) $ButtonHoverStruct = $iButtonHoverStruct GUICtrlDelete(_WinAPI_GetDlgCtrlID($HWNDA)) GUICtrlDelete(_WinAPI_GetDlgCtrlID($HWNDB)) GUICtrlDelete($USER) Return True EndFunc ;$controlID ==> Return CreateButtonHover Func ButtonHoverSetState($controlID,$ENABLE = 1,$SHOW = 1) $HWNDA = GUICtrlGetHandle($controlID - 1) if Not ($HWNDA) Then Return False $count = String(DllStructGetData($ButtonHoverStruct,String($HWNDA))) if Not int($count) Then Return False $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) _WinAPI_EnableWindow($HWNDA,$ENABLE) _WinAPI_EnableWindow($HWNDB,$ENABLE) $uFlags = $SWP_NOMOVE+$SWP_NOSIZE+$SWP_NOZORDER+$SWP_FRAMECHANGED; if ($SHOW) Then $uFlags += $SWP_SHOWWINDOW Else $uFlags += $SWP_HIDEWINDOW EndIf _WinAPI_SetWindowPos($HWNDA,$HWND_TOP,0,0,0,0,$uFlags) _WinAPI_SetWindowPos($HWNDB,$HWND_TOP,0,0,0,0,$uFlags) Return True EndFunc ;$controlID ==> Return CreateButtonHover Func ButtonHoverSetPos($controlID,$Left,$Top,$Width,$Height) $HWNDA = GUICtrlGetHandle($controlID - 1) if Not ($HWNDA) Then Return False $count = String(DllStructGetData($ButtonHoverStruct,String($HWNDA))) if Not int($count) Then Return False $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $ControlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $HWNDA) If @error Then Return False $ControlID = $ControlID[0] GUICtrlSetPos ($controlID,$Left,$Top,$Width,$Height) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) $ControlID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $HWNDB) If @error Then Return False $ControlID = $ControlID[0] GUICtrlSetPos ($controlID,$Left,$Top,$Width,$Height) Return True EndFunc Func ButtonHoverProc($nCode, $wParam, $lParam) $HHOOK = DllStructGetData($ButtonHoverStruct,"HHOOK") If $nCode < 0 Then _ Return _WinAPI_CallNextHookEx($HHOOK, $nCode, $wParam, $lParam) Local _ $WM_MOUSEFIRST_HOVER = 0x0200 , _ $WM_LBUTTONDOWN_HOVER = 0x0201 , _ $WM_LBUTTONUP_HOVER = 0x0202 , _ $STM_SETIMAGE_HOVER = 0x0172 , _ $Tag_struct ="LONG x;LONG y;HWND hwnd;UINT wHitTestCode;ULONG_PTR dwExtraInfo" $MOUSEHOOKSTRUCT = DllStructCreate($Tag_struct,$lParam) $hWnd = DllStructGetData($MOUSEHOOKSTRUCT,3) $uiMsg = $wParam $HOVER = DllStructGetData($ButtonHoverStruct,"HOVER") $MOUSEFIRST = DllStructGetData($ButtonHoverStruct,"MOUSEFIRST") $LBUTTONDOWN = DllStructGetData($ButtonHoverStruct,"LBUTTONDOWN") $count = String(DllStructGetData($ButtonHoverStruct,String($hWnd))) if Not ($count == "0") Then $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) If $uiMsg = $WM_MOUSEFIRST_HOVER And $MOUSEFIRST = 0 Then $OhBMP = DllStructGetData($ButtonHoverStruct,"OhBMP" & $count) DllStructSetData($ButtonHoverStruct,"HOVER",$HWNDA) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$OhBMP) _WinAPI_RedrawWindow($HWNDB,0,0, $RDW_INVALIDATE ) DllStructSetData($ButtonHoverStruct,"MOUSEFIRST",1) Else If $HOVER = $HWNDA Then Select Case $uiMsg = $WM_LBUTTONDOWN_HOVER And $LBUTTONDOWN = 0 $PhBMP = DllStructGetData($ButtonHoverStruct,"PhBMP" & $count) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$PhBMP) _WinAPI_RedrawWindow($HWNDB,0,0, $RDW_INVALIDATE ) DllStructSetData($ButtonHoverStruct,"LBUTTONDOWN",1) Case $uiMsg = $WM_LBUTTONUP_HOVER And $LBUTTONDOWN = 1 $OhBMP = DllStructGetData($ButtonHoverStruct,"OhBMP" & $count) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$OhBMP) _WinAPI_RedrawWindow($HWNDB,0,0, $RDW_INVALIDATE ) $USER = DllStructGetData($ButtonHoverStruct,"USER" & $count) GUICtrlSendToDummy($USER) DllStructSetData($ButtonHoverStruct,"LBUTTONDOWN",0) EndSelect Else If $uiMsg = $WM_LBUTTONUP_HOVER And $LBUTTONDOWN = 1 Then $count = String(DllStructGetData($ButtonHoverStruct,String($HOVER))) $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) $NhBMP = DllStructGetData($ButtonHoverStruct,"NhBMP" & $count) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$NhBMP) _WinAPI_RedrawWindow($HWNDB,0,0, $RDW_INVALIDATE ) DllStructSetData($ButtonHoverStruct,"LBUTTONDOWN",0) $count = String(DllStructGetData($ButtonHoverStruct,String($hWnd))) $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) $OhBMP = DllStructGetData($ButtonHoverStruct,"OhBMP" & $count) DllStructSetData($ButtonHoverStruct,"HOVER",$HWNDA) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$OhBMP) _WinAPI_RedrawWindow($HWNDB,0,0, $RDW_INVALIDATE ) DllStructSetData($ButtonHoverStruct,"MOUSEFIRST",1) EndIf EndIf EndIf Else If $LBUTTONDOWN = 1 Then If $uiMsg = $WM_LBUTTONUP_HOVER Then $count = String(DllStructGetData($ButtonHoverStruct,String($HOVER))) $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) $NhBMP = DllStructGetData($ButtonHoverStruct,"NhBMP" & $count) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$NhBMP) _WinAPI_RedrawWindow($HWNDB,0,0, $RDW_INVALIDATE ) DllStructSetData($ButtonHoverStruct,"LBUTTONDOWN",0) EndIf Else If $MOUSEFIRST = 1 Then $count = String(DllStructGetData($ButtonHoverStruct,String($HOVER))) $HWNDA = DllStructGetData($ButtonHoverStruct,"HWNDA" & $count) $HWNDB = DllStructGetData($ButtonHoverStruct,"HWNDB" & $count) $NhBMP = DllStructGetData($ButtonHoverStruct,"NhBMP" & $count) _SendMessage($HWNDA,$STM_SETIMAGE_HOVER,0,$NhBMP) _WinAPI_RedrawWindow($HWNDB,0,0, $RDW_INVALIDATE ) DllStructSetData($ButtonHoverStruct,"MOUSEFIRST",0) EndIf EndIf EndIf Return _WinAPI_CallNextHookEx($HHOOK, $nCode, $wParam, $lParam) EndFunc ;$STYLE ==> 1 Stretch = 1 , Tile = 2 , Center = 3 ; $hWnd ==> Gui hWnd Func GuiSetBackGroundImage($hWnd,$COLOREF_Or_HBITMAP,$STYLE = 1) if Not IsPtr($COLOREF_Or_HBITMAP) Then $Pos = WinGetPos($hWnd) $COLOREF_Or_HBITMAP = _WinAPI_CreateSolidBitmap($hWnd,$COLOREF_Or_HBITMAP,$Pos[2],$Pos[3],0) EndIf $IMAGEW = GetBmpWidth($COLOREF_Or_HBITMAP) $IMAGEH = GetBmpHeight($COLOREF_Or_HBITMAP) if Not IsDllStruct($BackGroundStruct) Then $count = "1" $TagButtonHoverStruct = _ "INT COUNT;INT " & String($hWnd) & ";HWND HWNDBG" & $count & ";HANDLE HBITMAPBG" & $count & _ ";INT IMAGEW" & $count & ";INT IMAGEH" & $count & ";INT STYLE" & $count $BackGroundStruct = DllStructCreate($TagButtonHoverStruct) DllStructSetData($BackGroundStruct,"COUNT",int($count)) DllStructSetData($BackGroundStruct,String($hWnd),int($count)) DllStructSetData($BackGroundStruct,"HWNDBG" & $count,$hWnd) DllStructSetData($BackGroundStruct,"HBITMAPBG" & $count,$COLOREF_Or_HBITMAP) DllStructSetData($BackGroundStruct,"IMAGEW" & $count,$IMAGEW) DllStructSetData($BackGroundStruct,"IMAGEH" & $count,$IMAGEH) DllStructSetData($BackGroundStruct,"STYLE" & $count,$STYLE) Else $count = DllStructGetData($BackGroundStruct,String($hWnd)) if ($count) Then $count = String($count) DllStructSetData($BackGroundStruct,"HBITMAPBG" & $count,$COLOREF_Or_HBITMAP) DllStructSetData($BackGroundStruct,"IMAGEW" & $count,$IMAGEW) DllStructSetData($BackGroundStruct,"IMAGEH" & $count,$IMAGEH) DllStructSetData($BackGroundStruct,"STYLE" & $count,$STYLE) Else $count = String(DllStructGetData($BackGroundStruct,"COUNT") + 1) $TagButtonHoverStruct &= _ ";INT " & String($hWnd) & ";HWND HWNDBG" & $count & ";HANDLE HBITMAPBG" & $count & _ ";INT IMAGEW" & $count & ";INT IMAGEH" & $count & ";INT STYLE" & $count $iLength = DllStructGetSize($BackGroundStruct) $iBackGroundStruct = DllStructCreate($TagButtonHoverStruct) DllCall("kernel32.dll","none","RtlMoveMemory","ptr",DllStructGetPtr($iBackGroundStruct) _ ,"ptr",DllStructGetPtr($BackGroundStruct),"ulong_ptr",$iLength) $BackGroundStruct = $iBackGroundStruct DllStructSetData($BackGroundStruct,"COUNT",int($count)) DllStructSetData($BackGroundStruct,String($hWnd),int($count)) DllStructSetData($BackGroundStruct,"HWNDBG" & $count,$hWnd) DllStructSetData($BackGroundStruct,"HBITMAPBG" & $count,$COLOREF_Or_HBITMAP) DllStructSetData($BackGroundStruct,"IMAGEW" & $count,$IMAGEW) DllStructSetData($BackGroundStruct,"IMAGEH" & $count,$IMAGEH) DllStructSetData($BackGroundStruct,"STYLE" & $count,$STYLE) EndIf EndIf GUIRegisterMsg($WM_ERASEBKGND,"BackGroundProc") _WinAPI_RedrawWindow($hWnd,0,0,$RDW_ERASE + $RDW_ERASENOW) EndFunc ;$lpszSound ==> FileName Or Ptr to an image of a sound in memory.; File Type File.wav Func GuiSetBackGroundSound($lpszSound,$fuSound = 0) Local $SND_MEMORY = 4, $SND_ASYNC = 1 ,$SND_SYNC = 0,$SND_NODEFAULT = 2 , _ $SND_LOOP = 0x0008 , $SND_NOSTOP = 0x0010 ,$SND_FILENAME = 0x00020000 if IsPtr($lpszSound) Then if Not($fuSound) Then $fuSound = BitOR($SND_MEMORY,$SND_ASYNC,$SND_NODEFAULT,$SND_LOOP,$SND_NOSTOP) $Type = "ptr" Else Local $Type = "str" if Not($fuSound) Then $fuSound = BitOR($SND_FILENAME,$SND_ASYNC,$SND_NODEFAULT,$SND_LOOP,$SND_NOSTOP) EndIf $BOOL = DllCall("winmm.dll", "int", "sndPlaySound",$Type,$lpszSound,"UINT",$fuSound) If @error Then Return SetError(1, 0, 0) Return $BOOL[0] EndFunc Func BackGroundProc($hWnd, $Msg, $wParam, $lParam) $count = DllStructGetData($BackGroundStruct,String($hWnd)) if ($count) Then $count = String($count) $HWNDBG = DllStructGetData($BackGroundStruct,"HWNDBG" & $count) if ($HWNDBG = $hWnd) Then $HBITMAPBG = DllStructGetData($BackGroundStruct,"HBITMAPBG" & $count) $IMAGEW = DllStructGetData($BackGroundStruct,"IMAGEW" & $count) $IMAGEH = DllStructGetData($BackGroundStruct,"IMAGEH" & $count) $STYLE = DllStructGetData($BackGroundStruct,"STYLE" & $count) $CDC = _WinAPI_CreateCompatibleDC($wParam) $Object = _WinAPI_SelectObject($CDC,$HBITMAPBG) Select Case $STYLE = 1 StretchBlt($wParam, 0, 0 , _WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd), $CDC, 0, 0, _ $IMAGEW ,$IMAGEH, $SRCCOPY) Case $STYLE = 2 For $i = 0 To (_WinAPI_GetClientHeight($hWnd) - 1) Step $IMAGEH For $j = 0 To (_WinAPI_GetClientWidth($hWnd) - 1) Step $IMAGEW _WinAPI_BitBlt($wParam,$j,$i, _WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd), _ $CDC ,0,0,$SRCCOPY) Next Next Case $STYLE = 3 if ($IMAGEW < _WinAPI_GetClientWidth($hWnd)) Then $j = ((_WinAPI_GetClientWidth($hWnd) - $IMAGEW) / 2) Else $j = 0 EndIf if($IMAGEH < _WinAPI_GetClientHeight($hWnd)) Then $i = ( (_WinAPI_GetClientHeight($hWnd) -$IMAGEH) / 2) Else $i = 0 EndIf _WinAPI_BitBlt($wParam,$j,$i,_WinAPI_GetClientWidth($hWnd), _WinAPI_GetClientHeight($hWnd) , _ $CDC ,0,0,$SRCCOPY) EndSelect $Object = _WinAPI_SelectObject($CDC, $Object) Return True EndIf EndIf EndFunc Func LoadBitmap_FromFile($sFileName) Return _WinAPI_LoadImage(_WinAPI_GetModuleHandle(0),$sFileName,0 ,0,0,0x0010) EndFunc Func LoadBitmap_FromResources($resource_Name) Return _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(0), $resource_Name) EndFunc Func GetBmpWidth($hBMP) $tagBITMAPINFO_HOVER = "DWORD biSize;LONG biWidth;LONG biHeight;USHORT biPlanes;" & _ "USHORT biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;" & _ "LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant;BYTE rgbBlueElement1;" & _ "BYTE rgbGreenElement1;BYTE rgbRedElement1;BYTE rgbReservedElement1" $BITMAPINFO = DllStructCreate($tagBITMAPINFO_HOVER) DllStructSetData($BITMAPINFO,"biSize",DllStructGetSize($BITMAPINFO)) $hDC = _WinAPI_CreateCompatibleDC(0) _WinAPI_GetDIBits($hDC,$hBmp,0,0,0,DllStructGetPtr($BITMAPINFO),0) Return DllStructGetData($BITMAPINFO,"biWidth") EndFunc Func GetBmpHeight($hBMP) $tagBITMAPINFO_HOVER = "DWORD biSize;LONG biWidth;LONG biHeight;USHORT biPlanes;" & _ "USHORT biBitCount;DWORD biCompression;DWORD biSizeImage;LONG biXPelsPerMeter;" & _ "LONG biYPelsPerMeter;DWORD biClrUsed;DWORD biClrImportant;BYTE rgbBlueElement1;" & _ "BYTE rgbGreenElement1;BYTE rgbRedElement1;BYTE rgbReservedElement1" $BITMAPINFO = DllStructCreate($tagBITMAPINFO_HOVER) DllStructSetData($BITMAPINFO,"biSize",DllStructGetSize($BITMAPINFO)) $hDC = _WinAPI_CreateCompatibleDC(0) _WinAPI_GetDIBits($hDC,$hBmp,0,0,0,DllStructGetPtr($BITMAPINFO),0) Return DllStructGetData($BITMAPINFO,"biHeight") EndFunc Func StretchBlt($hdcDest,$nXOriginDest,$nYOriginDest,$nWidthDest,$nHeightDest,$hdcSrc,$nXOriginSrc, _ $nYOriginSrc,$nWidthSrc,$nHeightSrc,$dwRop) $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) if @error Then Return 0 Return $DllCall[0] EndFunc Func Cleanup() $HHOOK = DllStructGetData($ButtonHoverStruct,"HHOOK") _WinAPI_UnhookWindowsHookEx($HHOOK) $DLLREGISTER = DllStructGetData($ButtonHoverStruct,"DLLREGISTER") DllCallbackFree($DLLREGISTER) EndFunc Edited October 12, 2010 by wolf9228 صرح السماء كان هنا Link to comment Share on other sites More sharing options...
eracross Posted October 11, 2010 Share Posted October 11, 2010 Cool! imma use this thanks. Link to comment Share on other sites More sharing options...
Valuater Posted October 12, 2010 Share Posted October 12, 2010 Looks a lot like mine... no mention? 8) Link to comment Share on other sites More sharing options...
wolf9228 Posted October 12, 2010 Author Share Posted October 12, 2010 Cool! imma use this thanks.You're welcome ... Thank you for supporting the project صرح السماء كان هنا Link to comment Share on other sites More sharing options...
wolf9228 Posted October 12, 2010 Author Share Posted October 12, 2010 Looks a lot like mine... no mention?8)I do not use mine to prove the truth and the truth like the sun but there are blind And sighted صرح السماء كان هنا Link to comment Share on other sites More sharing options...
Valuater Posted October 12, 2010 Share Posted October 12, 2010 Four score and seven years ago our fathers set forth on this contenet a new nation, Concieved in liberty and dedicated to the proposition.. 8) Link to comment Share on other sites More sharing options...
mesale0077 Posted October 13, 2010 Share Posted October 13, 2010 (edited) your nice code sound play and sound stop added button thank you Edited October 17, 2010 by mesale0077 Link to comment Share on other sites More sharing options...
wolf9228 Posted October 14, 2010 Author Share Posted October 14, 2010 (edited) Four score and seven years ago our fathers set forth on this contenet a new nation, Concieved in liberty and dedicated to the proposition..8)Human freedom achieved From self Before be achieved on the ground ... Conflict does not stop ... Between racism and freedom ... Ideal human comparative ... Everyone see the universe from the perspective of self Edited October 14, 2010 by wolf9228 صرح السماء كان هنا Link to comment Share on other sites More sharing options...
Zibit Posted October 15, 2010 Share Posted October 15, 2010 wow well done like it ^^ Creator Of Xtreme DevelopersPixel Pattern UDFTray GUI UDFMathssend & recive register scriptMouse Control via Webcam Link to comment Share on other sites More sharing options...
wolf9228 Posted October 20, 2010 Author Share Posted October 20, 2010 (edited) your nice code sound play and sound stop added button thank you expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <WinAPI.au3> ;Multimedia Functions ;http://msdn.microsoft.com/en-us/library/dd743586(v=VS.85).aspx Global $CharStruct_Of_lpData,$SLoop = 0, $SCountLoop = -1,$hwi,$RegisterProc OnAutoItExitRegister("Cleanup") $hGUI = GUICreate("My Gui",300,200) GUISetState() SetBackGroundSound("chimes.wav") While 1 $GUIMsg = GUIGetMsg() Switch $GUIMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func SetBackGroundSound($FileName_Or_CharStruct_Of_WavFile) $hwi = PlayWavFile($FileName_Or_CharStruct_Of_WavFile,1) If ($hwi) Then _ GUIRegisterMsg($WM_ACTIVATE,"MSGProc") Return $hwi EndFunc Func MSGProc($hWnd,$Msg,$wParam,$lParam) $WA = _WinAPI_LoWord($wParam) Switch $WA Case 1,2 Restart($hwi) Case Else Pause($hwi) EndSwitch EndFunc Func PlayWavFile($FileName_Or_CharStruct_Of_WavFile,$Loop = 0,$CountLoop = -1) Local $nBytes $SLoop = $Loop if ($SCountLoop = -1 ) Then $SCountLoop = $CountLoop if IsString($FileName_Or_CharStruct_Of_WavFile) Then $PtrSize = FileGetSize($FileName_Or_CharStruct_Of_WavFile) $wavehdr_tag = _ "ptr lpData;" & _ "DWORD dwBufferLength;" & _ "DWORD dwBytesRecorded;" & _ "DWORD_PTR dwUser;" & _ "DWORD dwFlags;" & _ "DWORD dwLoops;" & _ "ptr lpNext;" & _ "DWORD_PTR reserved" $WAVEHDR = DllStructCreate($wavehdr_tag) $CharStruct_Of_lpData = DllStructCreate("char [" & $PtrSize & "]") $hFile = _WinAPI_CreateFile($FileName_Or_CharStruct_Of_WavFile,2,2) if Not($hFile) Then Return SetError(1,0,0) _WinAPI_ReadFile($hFile,DllStructGetPtr($CharStruct_Of_lpData),$PtrSize,$nBytes) _WinAPI_CloseHandle($hFile) DllStructSetData($WAVEHDR,"dwBufferLength",$PtrSize) DllStructSetData($WAVEHDR,"lpData",DllStructGetPtr($CharStruct_Of_lpData) + 44) DllStructSetData($WAVEHDR,"dwFlags",1 + 2) ;WHDR_DONE + WHDR_PREPARED DllStructSetData($WAVEHDR,"dwLoops",0) ;The dwLoops clearly does not work / Not used $pwh = DllStructGetPtr($WAVEHDR) ElseIf IsDllStruct($FileName_Or_CharStruct_Of_WavFile) Then $CharStruct_Of_lpData = $FileName_Or_CharStruct_Of_WavFile $PtrSize = DllStructGetSize($CharStruct_Of_lpData) $wavehdr_tag = _ "ptr lpData;" & _ "DWORD dwBufferLength;" & _ "DWORD dwBytesRecorded;" & _ "DWORD_PTR dwUser;" & _ "DWORD dwFlags;" & _ "DWORD dwLoops;" & _ "ptr lpNext;" & _ "DWORD_PTR reserved" $WAVEHDR = DllStructCreate($wavehdr_tag) DllStructSetData($WAVEHDR,"dwBufferLength",$PtrSize) DllStructSetData($WAVEHDR,"lpData",DllStructGetPtr($CharStruct_Of_lpData) + 44) DllStructSetData($WAVEHDR,"dwFlags",1 + 2) ;WHDR_DONE + WHDR_PREPARED DllStructSetData($WAVEHDR,"dwLoops",0) ;The dwLoops clearly does not work / Not used $pwh = DllStructGetPtr($WAVEHDR) Else Return SetError(2,0,0) EndIf $cbwh = DllStructGetSize($WAVEHDR) $OFFSET_FORMATTAG = 20 $OFFSET_CHANNELS = 22 $OFFSET_SAMPLESPERSEC = 24 $OFFSET_AVGBYTESPERSEC = 28 $OFFSET_BLOCKALIGN = 32 $OFFSET_BITSPERSAMPLE = 34 $OFFSET_DATA = 44 $TagWAVEFORMATEX = _ "WORD wFormatTag;" & _ "WORD nChannels;" & _ "DWORD nSamplesPerSec;" & _ "DWORD nAvgBytesPerSec;" & _ "WORD nBlockAlign;" & _ "WORD wBitsPerSample;" & _ "WORD cbSize" $WAVEFORMATEX = DllStructCreate($TagWAVEFORMATEX) $nChannels = DllStructCreate("DWORD",DllStructGetPtr($CharStruct_Of_lpData) + $OFFSET_CHANNELS) $nSamplesPerSec = DllStructCreate("WORD",DllStructGetPtr($CharStruct_Of_lpData) + $OFFSET_SAMPLESPERSEC) $nAvgBytesPerSec = DllStructCreate("DWORD",DllStructGetPtr($CharStruct_Of_lpData) + $OFFSET_AVGBYTESPERSEC) $nBlockAlign = DllStructCreate("WORD",DllStructGetPtr($CharStruct_Of_lpData) + $OFFSET_BLOCKALIGN) $wBitsPerSample = DllStructCreate("WORD",DllStructGetPtr($CharStruct_Of_lpData) + $OFFSET_BITSPERSAMPLE) Local $WAVE_FORMAT_PCM = 1 DllStructSetData($WAVEFORMATEX,"wFormatTag",$WAVE_FORMAT_PCM) DllStructSetData($WAVEFORMATEX,"nChannels",DllStructGetData($nChannels,1)) DllStructSetData($WAVEFORMATEX,"nSamplesPerSec",DllStructGetData($nSamplesPerSec,1)) DllStructSetData($WAVEFORMATEX,"nAvgBytesPerSec",DllStructGetData($nAvgBytesPerSec,1)) DllStructSetData($WAVEFORMATEX,"nBlockAlign", DllStructGetData($nBlockAlign,1)) DllStructSetData($WAVEFORMATEX,"wBitsPerSample",DllStructGetData($wBitsPerSample,1)) DllStructSetData($WAVEFORMATEX,"cbSize",0) $RegisterProc = DllCallbackRegister("waveOutProc","none","ptr;uint;ptr;ptr;ptr") $RegisterProcPtr = DllCallbackGetPtr($RegisterProc) Local $WAVE_MAPPER = -1 $MMRESULT = DllCall("Winmm.dll","UINT","waveOutOpen","ptr*",0,"UINT",$WAVE_MAPPER, _ "ptr",DllStructGetPtr($WAVEFORMATEX),"ptr",$RegisterProcPtr,"ptr",0,"DWORD",0x00030000) ;0x00030000 CALLBACK_FUNCTION If @error Then Return SetError(3,0,0) if Not ($MMRESULT[0] = 0) Then Return SetError(3,$MMRESULT[0],0) $hwi = $MMRESULT[1] $MMRESULT = DllCall("Winmm.dll","int","waveOutWrite","ptr",$hwi,"ptr",$pwh,"UINT",$cbwh) Sleep(10) ;Must sleep If @error Then Return SetError(4,0,0) if Not ($MMRESULT[0] = 0) Then Return SetError(4,$MMRESULT[0],0) Return SetError(0,0,$hwi) EndFunc Func waveOutProc($hwi,$uMsg,$dwInstance,$dwParam1,$dwParam2) Local _ $MM_WOM_OPEN = 0x3BB , _ $MM_WOM_CLOSE = 0x3BC , _ $MM_WOM_DONE = 0x3BD Switch $uMsg Case $MM_WOM_OPEN Case $MM_WOM_DONE if $SCountLoop <= -1 Then if ($SLoop) Then AdlibRegister("LOOP",1) Else AdlibUnRegister("LOOP") AdlibRegister("CLOSE",1) EndIf Else if $SCountLoop > 1 And ($SLoop) Then AdlibRegister("LOOP",1) $SCountLoop -= 1 Else AdlibUnRegister("LOOP") AdlibRegister("CLOSE",1) EndIf EndIf Case $MM_WOM_CLOSE EndSwitch EndFunc Func Reset($hwi) $MMRESULT = DllCall("Winmm.dll","int","waveOutReset","ptr",$hwi) if Not ($MMRESULT[0] = 0) Then Return SetError(1,$MMRESULT[0],0) Return SetError(0,0,1) EndFunc Func GetVolume($hwi) $MMRESULT = DllCall("Winmm.dll","int","waveOutGetVolume","ptr",$hwi,"DWORD*",0) if Not ($MMRESULT[0] = 0) Then Return SetError(1,$MMRESULT[0],0) Return SetError(0,0,$MMRESULT[2]) EndFunc Func SetVolume($hwi,$Volume = 0xFFFF) ;0xFFFF Full $MMRESULT = DllCall("Winmm.dll","int","waveOutSetVolume","ptr",$hwi,"DWORD",$Volume) if Not ($MMRESULT[0] = 0) Then Return SetError(1,$MMRESULT[0],0) Return SetError(0,0,1) EndFunc Func Pause($hwi) $MMRESULT = DllCall("Winmm.dll","int","waveOutPause","ptr",$hwi) if Not ($MMRESULT[0] = 0) Then Return SetError(1,$MMRESULT[0],0) Return SetError(0,0,1) EndFunc Func Restart($hwi) $MMRESULT = DllCall("Winmm.dll","int","waveOutRestart","ptr",$hwi) if Not ($MMRESULT[0] = 0) Then Return SetError(1,$MMRESULT[0],0) Return SetError(0,0,1) EndFunc Func CLOSE() AdlibUnRegister("CLOSE") DllCall("Winmm.dll","int","waveOutClose","ptr",$hwi) $SLoop = 0 $SCountLoop = -1 DllCallbackFree($RegisterProc) EndFunc Func BreakLoop() Global $SLoop = 0 , $SCountLoop = -1 EndFunc Func LOOP() AdlibUnRegister("LOOP") PlayWavFile($CharStruct_Of_lpData,$SLoop,$SCountLoop) EndFunc Func Cleanup() DllCall("Winmm.dll","int","waveOutClose","ptr",$hwi) DllCallbackFree($RegisterProc) EndFunc Edited October 23, 2010 by wolf9228 صرح السماء كان هنا Link to comment Share on other sites More sharing options...
wolf9228 Posted October 20, 2010 Author Share Posted October 20, 2010 wow well done like it ^^ صرح السماء كان هنا 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