froufrou Posted June 16, 2009 Share Posted June 16, 2009 (edited) This is part of the code i am using.What i need help with is when over most of the GIU mouse changes as wanted.But when over controls or pics of anykind the mouse goes back to normal.Is there any way to fix that? I already did the changing of the system cursor while my script runs and then changing back to default.But i really would like it to change only on my GUI. Thanks in Advance expandcollapse popupGUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","new.cur") if @error Then MsgBox(0,"Nope","not happening") $Splash = GUICreate("AutoIt CD/DVD Burner", $width, $height, -1, -1, $WS_POPUP, BitOR($WS_EX_LAYERED, $DS_MODALFRAME)) SetBitmap($Splash, $hImage, 0) GUISetState() WinSetOnTop($Splash, "", 1) $controlGui = GUICreate("ControlGUI", $width, $height, 0, -4, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_ACCEPTFILES, $WS_EX_MDICHILD), $Splash) Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) If $hWnd = $Splash or $controlGui Then DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndIf EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA) _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetBitmap Edited June 16, 2009 by froufrou Link to comment Share on other sites More sharing options...
froufrou Posted June 16, 2009 Author Share Posted June 16, 2009 (edited) Well i thought i would make another example so it would be easier for someone to help me. This is the same way,I need to keep my custom cursor over controls.In this example the cursor changes when hovering the label. Please Help this noob. I even attached the cursor. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $msg,$x2,$Cur,$hwnd GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","new.cur") if @error Then MsgBox(0,"dd","whoopsie!") $hwnd = GUICreate("test",300,300) $x2 = GUICtrlCreateLabel("0", 10, 50, 50) GUISetState() Do $msg = GUIGetMsg() ;~ Sleep(50) Until $msg = $GUI_EVENT_CLOSE Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndFunccursor.zip Edited June 16, 2009 by froufrou Link to comment Share on other sites More sharing options...
picea892 Posted June 17, 2009 Share Posted June 17, 2009 Hi Frou Frou Try this #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) Global $msg,$x2,$Cur,$hwnd GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","new.cur") if @error Then MsgBox(0,"dd","whoopsie!") $hwnd = GUICreate("test",300,300) $x2 = GUICtrlCreateLabel("0", 10, 50, 50) GUISetCursor(-1,1) GUISetState() Do $msg = GUIGetMsg() ;~ Sleep(50) Until $msg = $GUI_EVENT_CLOSE Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndFunc Link to comment Share on other sites More sharing options...
froufrou Posted June 17, 2009 Author Share Posted June 17, 2009 hi picea892 Thanks for reply! I tried that before,I think.But did again when you posted to be sure.The cursor still changes when over the label.Just can't seem to figure this one out. Link to comment Share on other sites More sharing options...
froufrou Posted June 17, 2009 Author Share Posted June 17, 2009 (edited) Well,It's ugly,but i figured it out.Got my custom cursor on my GUI and over controls too. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $msg,$x2,$x3,$Cur,$hwnd,$doo GUIRegisterMsg($WM_SETCURSOR, 'WM_SETCURSOR') $Cur = DllCall("user32.dll", "int", "LoadCursorFromFile", "str","new.cur") if @error Then MsgBox(0,"Nope","Not Happening") $hwnd = GUICreate("test",300,300) $x2 = GUICtrlCreateLabel("Label Test", 10, 50, 50) $x3 = GUICtrlCreateButton("Button Test", 10, 100) GUISetState() Do $doo = GUIGetCursorInfo ($hwnd) If ($doo[4])> 0 Then WM_SETCURSOR(-1,-1,-1,-1) Else EndIf $msg = GUIGetMsg() Sleep(10) Until $msg = $GUI_EVENT_CLOSE Func WM_SETCURSOR($hWnd, $iMsg, $iWParam, $iLParam) DllCall("user32.dll", "int", "SetCursor", "int", $Cur[0]) Return 0 EndFunc Edited June 17, 2009 by froufrou 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