sandin Posted December 11, 2008 Share Posted December 11, 2008 (edited) EDIT: all resolved, though, for last 2 questions, my solutions were workarounds, is there a faster way to do this?EDIT2: 4th question addedEDIT3: Everything resolvedHi,I have few questions about treeview:1. In the help files there is nice example of how to get listview item's information using $tagNMITEMACTIVATE, so is there the same for treeview (I couldn't find any in the help files)2. Now I know how to edit treeview item's txt, and save it, but I can't retrieve new txt using _GUICtrlTreeView_GetText, is there another way to get the new label of an item?3. I couldn't find any example for dragging treeview's item from one to another place in the treeview, can someone show me, or direct me to the example?4. Is there a way to set any of the shell32.dll icon as mouse pointer while dragging an treeview item?Tnx.Script example:expandcollapse popup#include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <Constants.au3> Opt("PixelCoordMode", 2) Global $Startx, $Starty, $Endx, $Endy, $aM_Mask, $aMask, $nc Global Const $VK_F2 = 0x71 Global Const $VK_ESC = 0x1B Global $just_edited = False, $fDragging = False, $hDragItem, $fWhere, $moving_txt, $item_above_drag, $item_below_drag Opt("GUICloseOnESC", 0) Global $iEditFlag = 0 $hGUI = GUICreate("Test GUI", 300, 200) GUICtrlCreateLabel("F2 - Edit text, Enter - Set text, ESC - Cancel edit", 16, 10, 250, 16) $hTreeView = _GUICtrlTreeView_Create($hGUI, 10, 40, 280, 140, _ BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVIS_DROPHILITED, $TVS_SHOWSELALWAYS, $WS_TABSTOP), $WS_EX_CLIENTEDGE) For $i = 1 To 5 $hItem = _GUICtrlTreeView_Add($hTreeView, $i, "Item" & $i) For $j = 1 To 5 _GUICtrlTreeView_AddChild($hTreeView, $hItem, "SubItem" & $j) Next Next GUISetState(@SW_SHOW, $hGUI) $position = WinGetPos($hGUI) $client = WinGetClientSize($hGUI) $light_border = ($position[2]-$client[0])/2 $thick_border = $position[3]-$client[1]-$light_border $x_coord = $position[0]+$light_border $y_coord = $position[1]+$thick_border Global $gw = 16 Global $gh = 16 $drag_gui = GUICreate("Drag", $gw, $gh, $x_coord, $y_coord, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST), $hGUI) $cursor_icon = GUICtrlCreateIcon("Shell32.dll", -147, 0, 0, 16, 16) GUISetState(@SW_SHOW, $drag_gui) setTrans() GUISetState(@SW_HIDE, $drag_gui) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $wProcHandle = DllCallbackRegister("_WindowProc", "int", "hwnd;uint;wparam;lparam") $wProcOld = _WinAPI_SetWindowLong($hTreeView, $GWL_WNDPROC, DllCallbackGetPtr($wProcHandle)) Func setTrans() $aM_Mask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", 0, "long", 0, "long", 460, "long", 460) $rct = DllStructCreate("int;int;int;inr", $aM_Mask[0]) $TestCol = PixelGetColor(0, 0) $Startx = -1 $Starty = -1 $Endx = 0 $Endy = 0 For $i = 0 To $gw For $j = 0 To $gh If PixelGetColor($i, $j) = $TestCol And $j < $gh Then If $Startx = -1 Then $Startx = $i $Starty = $j $Endx = $i $Endy = $j Else $Endx = $i $Endy = $j EndIf Else If $Startx <> -1 Then addRegion() $Startx = -1 $Starty = -1 EndIf Next Next DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $drag_gui, "long", $aM_Mask[0], "int", 1) EndFunc Func addRegion() $aMask = DllCall("gdi32.dll", "long", "CreateRectRgn", "long", $Startx, "long", $Starty, "long", $Endx + 1, "long", $Endy + 1) $nc += 1 DllCall("gdi32.dll", "long", "CombineRgn", "long", $aM_Mask[0], "long", $aMask[0], "long", $aM_Mask[0], "int", 3) EndFunc While 1 if $fDragging = True then chase() if $just_edited = True Then $just_edited = False ConsoleWrite("New txt: " & _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetSelection($hTreeView)) & @CRLF) EndIf $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE _WinAPI_SetWindowLong($hTreeView, $GWL_WNDPROC, $wProcOld) DllCallbackFree($wProcHandle) Exit case $GUI_EVENT_MOUSEMOVE If $fDragging = False Then ContinueCase $hItemHover = TreeItemFromPoint($hTreeView) If $hItemHover <> 0 Then $aRect = _GUICtrlTreeView_DisplayRect($hTreeView, $hItemHover) $iTreeY = _WinAPI_GetMousePosY(True, $hTreeView) Switch $iTreeY Case $aRect[1] To $aRect[1]+Int(($aRect[3]-$aRect[1])/4) if $fWhere <> -1 Then _GUICtrlTreeView_SetInsertMark($hTreeView, $hItemHover, False) $fWhere = -1 EndIf Case 1+$aRect[1]+Int(($aRect[3]-$aRect[1])/3) To $aRect[1]+Int(($aRect[3]-$aRect[1])*2/3) if $fWhere <> 0 Then _SendMessage($hTreeView, $TVM_SETINSERTMARK, 0, 0) $fWhere = 0 EndIf Case 1+$aRect[1]+Int(($aRect[3]-$aRect[1])*2/3) To $aRect[3] if $fWhere <> 1 Then _GUICtrlTreeView_SetInsertMark($hTreeView, $hItemHover) $fWhere = 1 EndIf EndSwitch EndIf Case $GUI_EVENT_PRIMARYUP If $fDragging Then ToolTip("") _WinAPI_InvalidateRect($hTreeView) $fDragging = False GUISetState(@SW_HIDE, $drag_gui) _WinAPI_ShowCursor(True) _SendMessage($hTreeView, $TVM_SETINSERTMARK, 0, 0) If (TreeItemFromPoint($hTreeView) = $hDragItem) Then ContinueCase if TreeItemFromPoint($hTreeView) = $item_above_drag AND $fWhere = 1 then ContinueCase if TreeItemFromPoint($hTreeView) = $item_below_drag AND $fWhere = -1 then ContinueCase if $fWhere <> 0 then $hItem = TreeItemCopy($hTreeView, $hDragItem, TreeItemFromPoint($hTreeView), $fWhere) If $hItem <> 0 Then _GUICtrlTreeView_SelectItem($hTreeView, $hItem) _GUICtrlTreeView_Delete($hTreeView, $hDragItem) EndIf EndIf EndIf EndSwitch WEnd Func TreeItemCopy($hWnd, $hItemSource, $hItemTarget, $fDirection) $hTest = $hItemTarget Do $hTest = _GUICtrlTreeView_GetParentHandle($hWnd, $hTest) If $hTest = $hItemSource Then Return 0 Until $hTest = 0 $sText = _GUICtrlTreeView_GetText($hWnd, $hItemSource) $hParent = _GUICtrlTreeView_GetParentHandle($hWnd, $hItemTarget) Switch $fDirection Case -1 $hPrev = _GUICtrlTreeView_GetPrevSibling($hWnd, $hItemTarget) If $hPrev = 0 Then $hNew = _GUICtrlTreeView_AddFirst($hWnd, $hItemTarget, $sText) Else $hNew = _GUICtrlTreeView_InsertItem($hWnd, $sText, $hParent, $hPrev) EndIf Case 0 $hNew = _GUICtrlTreeView_InsertItem($hWnd, $sText, $hItemTarget) Case 1 $hNew = _GUICtrlTreeView_InsertItem($hWnd, $sText, $hParent, $hItemTarget) Case Else Return 0 EndSwitch _GUICtrlTreeView_SetState($hWnd, $hNew, _GUICtrlTreeView_GetState($hWnd, $hItemSource)) If _GUICtrlTreeView_GetStateImageList($hWnd) <> 0 Then _GUICtrlTreeView_SetStateImageIndex($hWnd, $hNew, _GUICtrlTreeView_GetStateImageIndex($hWnd, $hItemSource)) EndIf If _GUICtrlTreeView_GetNormalImageList($hWnd) <> 0 Then _GUICtrlTreeView_SetImageIndex($hWnd, $hNew, _GUICtrlTreeView_GetImageIndex($hWnd, $hItemSource)) _GUICtrlTreeView_SetSelectedImageIndex($hWnd, $hNew, _GUICtrlTreeView_GetSelectedImageIndex($hWnd, $hItemSource)) EndIf $iChildCount = _GUICtrlTreeView_GetChildCount($hWnd, $hItemSource) If $iChildCount > 0 Then For $i = 0 To $iChildCount-1 $hRecSource = _GUICtrlTreeView_GetItemByIndex($hWnd, $hItemSource, $i) TreeItemCopy($hWnd, $hRecSource, $hNew, 0) Next EndIf Return $hNew EndFunc Func TreeItemFromPoint($hWnd) Local $tMPos = _WinAPI_GetMousePos(True, $hWnd) Return _GUICtrlTreeView_HitTestItem($hWnd, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) EndFunc func GetNeighbourItem($hWnd, $hItemTarget, $above = True) if $above = True Then Local $hPrev = _GUICtrlTreeView_GetPrevSibling($hWnd, $hItemTarget) Return $hPrev Else Local $hNext = _GUICtrlTreeView_GetNextSibling($hWnd, $hItemTarget) Return $hNext EndIf EndFunc Func chase() $mp = MouseGetPos() WinMove($drag_gui, "", $mp[0] + 1, $mp[1] + 0) tooltip($moving_txt, $mp[0]+18, $mp[1]) EndFunc Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tNMHDR, $HwndFrom, $iCode, $tInfo $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $HwndFrom = DllStructGetData($tNMHDR, "HwndFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $HwndFrom Case $hTreeView Switch $iCode Case $TVN_BEGINDRAG, $TVN_BEGINDRAGW Local $tInfo = DllStructCreate($tagNMTREEVIEW, $lParam) Local $hNewItem = DllStructGetData($tInfo, "NewhItem") _GUICtrlTreeView_SelectItem($hTreeView, $hNewItem) $fDragging = True $moving_txt = "Moving: " & _GUICtrlTreeView_GetText($hTreeView, $hNewItem) _WinAPI_ShowCursor(False) GUISetState(@SW_SHOW, $drag_gui) HotKeySet("{Esc}", "_cancel_dragging2") tooltip($moving_txt, MouseGetPos(0)+18, MouseGetPos(1)) $hDragItem = TreeItemFromPoint($hTreeView) $item_above_drag = GetNeighbourItem($hTreeView, $hDragItem) $item_below_drag = GetNeighbourItem($hTreeView, $hDragItem, false) Case $NM_RCLICK if $fDragging = True Then _cancel_dragging() Else Local $tInfo = DllStructCreate($tagNMTREEVIEW, $lParam) Local $hNewItem = DllStructGetData($tInfo, "NewParam") ConsoleWrite(_GUICtrlTreeView_GetText($hTreeView, $hNewItem) & ", ") _GUICtrlTreeView_SelectItem($hTreeView, $hNewItem) EndIf Case $TVN_ENDLABELEDIT, $TVN_ENDLABELEDITW HotKeySet("{Enter}") HotKeySet("{Esc}") If $iEditFlag Then $iEditFlag = 0 Local $tInfo = DllStructCreate($tagNMTVDISPINFO, $lParam) Local $sBuffer = DllStructCreate("wchar Text[" & DllStructGetData($tInfo, "TextMax") & "]") If Not _GUICtrlTreeView_GetUnicodeFormat($HwndFrom) Then $sBuffer = StringTrimLeft($sBuffer, 1) DllStructSetData($sBuffer, "Text", DllStructGetData($tInfo, "Text")) If StringLen(DllStructGetData($sBuffer, "Text")) Then $just_edited = true Return 1 EndIf EndIf Case $TVN_BEGINLABELEDIT, $TVN_BEGINLABELEDITW HotKeySet("{Enter}", "_TextSet") HotKeySet("{Esc}", "_EditClose") EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _cancel_dragging2() if $fDragging = True then _cancel_dragging() EndFunc Func _WindowProc($hWnd, $Msg, $wParam, $lParam) Switch $hWnd Case $hTreeView Switch $Msg Case $WM_GETDLGCODE Switch $wParam case $VK_F2 _TextEdit() EndSwitch EndSwitch EndSwitch Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $Msg, $wParam, $lParam) EndFunc func _cancel_dragging() HotKeySet("{Esc}") $fDragging = False GUISetState(@SW_HIDE, $drag_gui) _WinAPI_ShowCursor(True) ToolTip("") _WinAPI_InvalidateRect($hTreeView) _SendMessage($hTreeView, $TVM_SETINSERTMARK, 0, 0) EndFunc Func _TextEdit() Local $hItem = _GUICtrlTreeView_GetSelection($hTreeView) If $hItem Then _GUICtrlTreeView_EditText($hTreeView, $hItem) EndFunc Func _TextSet() $iEditFlag = 1 _GUICtrlTreeView_EndEdit($hTreeView) EndFunc Func _EditClose() $iEditFlag = 0 _GUICtrlTreeView_EndEdit($hTreeView) EndFunc Edited December 14, 2008 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
sandin Posted December 12, 2008 Author Share Posted December 12, 2008 I guess I'm allowed to *bump* topic after 24h ;/ Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
sandin Posted December 12, 2008 Author Share Posted December 12, 2008 (edited) 1st question solved using:Case $NM_RCLICK Local $tInfo = DllStructCreate($tagNMTREEVIEW, $lParam) Local $hNewItem = DllStructGetData($tInfo, "NewParam") ConsoleWrite(_GUICtrlTreeView_GetText($hTreeView, $hNewItem) & ", ") _GUICtrlTreeView_SelectItem($hTreeView, $hNewItem)(1st post example edited) Edited December 13, 2008 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
sandin Posted December 12, 2008 Author Share Posted December 12, 2008 1st post edited2nd question solved using changeable $var in the While1 part (crappy solution, but it works )only thing remain is how to drag and drop items with inside of treeview, can someone show example please? Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
sandin Posted December 13, 2008 Author Share Posted December 13, 2008 3rd question resolved, though script is kinda long, and slow, so is there a faster way to do this (cause the last 2 solutions were workarounds) Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
sandin Posted December 13, 2008 Author Share Posted December 13, 2008 I have one more question, how to set any of the shell32.dll icon as mouse cursor? (added in the 1st post) Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Zedna Posted December 13, 2008 Share Posted December 13, 2008 Good progress without any help man :-) I have no special tip for you just Try to use Search on this forum there are many usefull/educative examples. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
sandin Posted December 13, 2008 Author Share Posted December 13, 2008 (edited) Thank you, I found similar example and used it, everything works! =) Edited December 13, 2008 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
jennico Posted January 14, 2009 Share Posted January 14, 2009 (edited) very nice. there is a better way to change cursors. Func _SetCursor($s_file,$i_cursor) $newhcurs=DllCall("user32.dll","int","LoadCursorFromFile","str",$s_file) If Not @error Then DllCall("user32.dll","int","SetSystemCursor","int",$newhcurs[0],"int",$i_cursor) EndFunc hope this helps you out instead of using a 2nd gui. j. Edited January 14, 2009 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
sandin Posted January 15, 2009 Author Share Posted January 15, 2009 tnx for info, but I can not load icon that way and set it as cursor, I can only use already defined cursors in their own format (*.ani, *.cur,...) in my case I wanted to use icon from shell32.dll file, I found no other way, if you know something more simple than using new gui, please share it Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
jennico Posted January 15, 2009 Share Posted January 15, 2009 (edited) well, not sure, why don't you try to simply rename the xy.ico to xy.cur ? the two formats are identical. edit: ah, this might not work for icons that bear more than one group. i'm not sure about that. the other way (.cur to .ico) it definitely works. edit2: ok, now i understand. you want to take it directly from shell32.dll. that seems more complicated.... Edited January 15, 2009 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
jennico Posted January 15, 2009 Share Posted January 15, 2009 mybe search msdn: LoadCursorFromFile LoadCursor as far as i understand, LoadCursor allows other files than .cur or .ani. maybe you need a handle to the iconfile.j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
jennico Posted January 15, 2009 Share Posted January 15, 2009 (edited) We can use LoadImage instead of LoadCursorFromFile to load non-standard size icons and cursors. I used this method to load a 48x48 icon when my system is set to 32x32. I also tried this with multi icon and it seems to always load the largest icon.from here.must be working ! j.same source:Loading from a DLL or EXE It may also be possible to load a cursor or icon from a DLL or EXE file. Here we need GetModuleHandle to get a handle for LoadImage, and MAKEINTRESOURCE to load a resource by ordinal. If anyone knows how to use MAKEINTRESOURCE macro within DllCall do post. Code (Expand - Copy): ; uType: IMAGE_BITMAP := 0x0 IMAGE_CURSOR := 0x2 IMAGE_ICON := 0x1 ; Size: cx := 48, cy := cx ; fuLoad: LR_COLOR := 0x2 LR_CREATEDIBSECTION := 0x2000 LR_DEFAULTSIZE := 0x40 LR_LOADFROMFILE := 0x10 LR_LOADMAP3DCOLORS := 0x1000 Module = %A_WinDir%\SYSTEM32\SHELL32.DLL ModuleHandle := DllCall("GetModuleHandleA", Str,Module) CursorHandle := DllCall( "LoadImageA", Uint,ModuleHandle, Str,Cursor, Uint,IMAGE_ICON, Int,cx, Int,cy, UInt,0x10 ) Replacing the cursors Now that we've loaded a cursor, the next step is to loop through a list of system cursors to replace all of them: Code (Copy): Cursors = 32512,32513,32514,32515,32516,32640,32641,32642,32643,32644,32645,32646,32648,32649,32650,32651 Loop, Parse, Cursors, `, { DllCall( "SetSystemCursor", Uint,CursorHandle, Int,A_Loopfield ) }LoadCursor(GetModuleHandle(modulename), Cursorname)1. make a module from dll and ordinal value.2. get the module handle.3. use LoadCurser with the desired CursorID.cheers j. Edited January 15, 2009 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
jennico Posted January 15, 2009 Share Posted January 15, 2009 okay, tried to make it. it does NOT work, but it is very close. maybe anyone else can correct it. expandcollapse popup#Include <WinAPI.au3> Global Const $LR_LOADFROMFILE = 0x0010 Global Const $IMAGE_CURSOR = 0x02 Global Const $IDC_ARROW = 32512 Global Const $IDC_IBEAM = 32513 Global Const $IDC_WAIT = 32514 Global Const $IDC_CROSS = 32515 Global Const $IDC_UPARROW = 32516 Global Const $IDC_SIZE = 32640 Global Const $IDC_ICON = 32641 Global Const $IDC_SIZENWSE = 32642 Global Const $IDC_SIZENESW = 32643 Global Const $IDC_SIZEWE = 32644 Global Const $IDC_SIZENS = 32645 Global Const $IDC_SIZEALL = 32646 Global Const $IDC_NO = 32648 Global Const $IDC_HAND = 32649 Global Const $IDC_APPSTARTING = 32650 Global Const $IDC_HELP = 32651 Global Const $SPI_SETCURSORS = 87 ;Module = %A_WinDir%\SYSTEM32\SHELL32.DLL $module = "shell32.dll" $sImage = 24 $i_cursor = $IDC_ARROW ;ModuleHandle := DllCall("GetModuleHandleA", Str,Module) $modulehandle = _WinAPI_GetModuleHandle ($module) ;CursorHandle := DllCall( "LoadImageA", Uint,ModuleHandle, Str,Cursor, Uint,IMAGE_ICON, Int,cx, Int,cy, UInt,0x10 ) $cursorhandle = _WinAPI_LoadImage ($modulehandle, $sImage, $IMAGE_CURSOR, 0, 0, $LR_LOADFROMFILE) ;DllCall( "SetSystemCursor", Uint,CursorHandle) DllCall("user32.dll", "int", "SetSystemCursor", "int", $cursorhandle, "int", $i_cursor) Sleep(10000) _WinAPI_SystemParametersInfo($SPI_SETCURSORS) ; Reload the system cursors at the end of script !!! j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
Zedna Posted January 15, 2009 Share Posted January 15, 2009 okay, tried to make it. it does NOT work, but it is very close. maybe anyone else can correct it. j.Look at this example for SetSystemCursor API http://www.autoitscript.com/forum/index.ph...st&p=335858Maybe you will have inspiration in some way. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
jennico Posted January 15, 2009 Share Posted January 15, 2009 (edited) hi zedna, that topic was mine ! maybe you overread the issue here: the problem is: set a dll icon resource as cursor. it's a bit more ambitious.j. Edited January 15, 2009 by jennico Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
Zedna Posted January 15, 2009 Share Posted January 15, 2009 hi zedna, that topic was mine ! maybe you overread the issue here: the problem is: set a dll icon resource as cursor. it's a bit more ambitious.j.Sorry I didn't notice that. Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
jennico Posted January 16, 2009 Share Posted January 16, 2009 Sorry I didn't notice that.same happened to me. on first glance i thought it was easy. the approach i made should be nearly correct. one mistake is you have to use $IMAGE_ICON instead of $IMAGE_CURSOR. the other problem is, i'm not sure how to use $sImage. it should supply the iconname in the dll, but i can't figure it out.j. Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â Link to comment Share on other sites More sharing options...
Zedna Posted January 16, 2009 Share Posted January 16, 2009 same happened to me. on first glance i thought it was easy. the approach i made should be nearly correct. one mistake is you have to use $IMAGE_ICON instead of $IMAGE_CURSOR. the other problem is, i'm not sure how to use $sImage. it should supply the iconname in the dll, but i can't figure it out.j.Try$sImage = '#24' Resources UDF Â ResourcesEx UDF Â AutoIt Forum Search Link to comment Share on other sites More sharing options...
jennico Posted January 16, 2009 Share Posted January 16, 2009 i give it up expandcollapse popup#Include <WinAPI.au3> Global Const $LR_LOADFROMFILE = 0x0010 Global Const $IMAGE_CURSOR = 0x02 Global Const $IMAGE_ICON = 0x01 Global Const $IDC_ARROW = 32512 Global Const $IDC_IBEAM = 32513 Global Const $IDC_WAIT = 32514 Global Const $IDC_CROSS = 32515 Global Const $IDC_UPARROW = 32516 Global Const $IDC_SIZE = 32640 Global Const $IDC_ICON = 32641 Global Const $IDC_SIZENWSE = 32642 Global Const $IDC_SIZENESW = 32643 Global Const $IDC_SIZEWE = 32644 Global Const $IDC_SIZENS = 32645 Global Const $IDC_SIZEALL = 32646 Global Const $IDC_NO = 32648 Global Const $IDC_HAND = 32649 Global Const $IDC_APPSTARTING = 32650 Global Const $IDC_HELP = 32651 Global Const $SPI_SETCURSORS = 87 ;Module = %A_WinDir%\SYSTEM32\SHELL32.DLL $module = @SystemDir&"\shell32.dll" $sImage = "#24" $i_cursor = $IDC_ARROW ;ModuleHandle := DllCall("GetModuleHandleA", Str,Module) ;$modulehandle = _WinAPI_GetModuleHandle ($module) $modulehandle = DllCall("Kernel32.dll", "hwnd", "GetModuleHandle", "ptr", DllStructGetPtr($module)) ;CursorHandle := DllCall( "LoadImageA", Uint,ModuleHandle, Str,Cursor, Uint,IMAGE_ICON, Int,cx, Int,cy, UInt,0x10 ) ;$cursorhandle = _WinAPI_LoadImage ($modulehandle, $sImage, $IMAGE_CURSOR, 0, 0, $LR_LOADFROMFILE) $cursorhandle = DllCall("User32.dll", "hwnd", "LoadImage", "hwnd", $modulehandle[0], "str", $sImage, "int", $IMAGE_ICON, "int", 0, "int", 0, "int", $LR_LOADFROMFILE) ;DllCall( "SetSystemCursor", Uint,CursorHandle) DllCall("user32.dll", "int", "SetSystemCursor", "int", $cursorhandle[0], "int", $i_cursor) Sleep(10000) _WinAPI_SystemParametersInfo($SPI_SETCURSORS) ; Reload the system cursors at the end of script !!! Spoiler I actively support Wikileaks | Freedom for Julian Assange ! | Defend freedom of speech ! | Fight censorship ! | I will not silence.Don't forget this IP: 213.251.145.96 Â 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