Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Change Set System Cursor WAIT ARROW ICO Hourglass
#DefineFunction udfSetSystemCursor( cursor, cx, cy) ;*************************************************************************** ;** Change the System Cursor ;** ;** SYNTAX: ;** udfSetSystemCursor( cursor, cx, cy) ;** PARAMETERS: ;** (s) cursor : ;** Name of the cursor you would like to load. i.e IDC_ARROW, IDC_WAIT ;** File name. i.e .ICO .CUR or .ANI ;** (i) cx : x coordinate ;** (i) cy : y coordinate ;** ;*************************************************************************** SystemCursors = '32512IDC_ARROW,32513IDC_IBEAM,32514IDC_WAIT,32515IDC_CROSS,32516IDC_UPARROW,32640IDC_SIZE,32641IDC_ICON,32642IDC_SIZENWSE,32643IDC_SIZENESW,32644IDC_SIZEWE,32645IDC_SIZENS,32646IDC_SIZEALL,32648IDC_NO,32649IDC_HAND,32650IDC_APPSTARTING,32651IDC_HELP' CursorHandle = '' BlankCursor = 0 SystemCursor = 0 FileCursor = 0 If cursor == ''; empty, so create blank cursor ;VarSetCapacity( AndMask, 32*4, 0xFF ), VarSetCapacity( XorMask, 32*4, 0 ) AndMask = BinaryAlloc(4) BinaryPokeHex( AndMask, 0, "FF" ) XorMask = BinaryAlloc(4) BinaryPoke( XorMask, 0, 0) BlankCursor = 1 ; flag for later Else If StrSub( Cursor,1,4 ) == 'IDC_' ; load system cursor For xx = 1 To ItemCount( SystemCursors, ',') dacursor = ItemExtract( xx, SystemCursors, ',' ) CursorName = StrSub( dacursor, 6, 15 ) ; get the cursor name, no trailing space with substr CursorID = StrSub( dacursor, 1, 5 ) ; get the cursor id SystemCursor = 1 If ( CursorName == Cursor ) CursorHandle = DllCall( DirWindows(1):"USER32.DLL", long:"LoadCursorA" , long: 0, long:CursorID) Break EndIf Next If CursorHandle == ''; invalid cursor name given Pause('Error', 'udfSetSystemCursor(LoadCursorA) Error: Invalid cursor name') CursorHandle = 'Error' EndIf Else If FileExist( Cursor ) ext = FileExtension( Cursor ); auto-detect type If StrUpper(ext) == 'ICO' uType = 1 Else If StrUpper(ext) == 'CUR' || StrUpper(ext) == 'ANI' uType = 2 Else ; invalid file ext Pause('Error', 'udfSetSystemCursor Error: Invalid file type') CursorHandle = 'Error' EndIf EndIf FileCursor = 1 Else Pause('Error', 'udfSetSystemCursor Error: Invalid file path or cursor name') CursorHandle = 'Error' ; raise for later EndIf EndIf EndIf If CursorHandle != 'Error' For index = 1 To ItemCount( SystemCursors, ',') dacursor = ItemExtract( index, SystemCursors, ',' ) If BlankCursor == 1 Type = 'BlankCursor' %Type%%index% = DllCall( DirWindows(1):"USER32.DLL",long:"CreateCursor", long:0, long:0, long:0, long:32, long:32, lpbinary:AndMask, lpbinary:XorMask ) CursorHandle = DllCall( DirWindows(1):"USER32.DLL", long:"CopyImage", long:%Type%%index%, long:2, long:0, long:0, long:0 ) retval = DllCall( DirWindows(1):"USER32.DLL", long:"SetSystemCursor" , long:CursorHandle, long:StrSub( dacursor, 1, 5 )) EndIf If SystemCursor == 1 Type = 'SystemCursor' CursorHandle = DllCall( DirWindows(1):"USER32.DLL", long:"LoadCursorA" , long:0, long:CursorID) %Type%%index% = DllCall( DirWindows(1):"USER32.DLL", long:"CopyImage", long:CursorHandle, long:2, long:cx, long:cy, long:0 ) CursorHandle = DllCall( DirWindows(1):"USER32.DLL", long:"CopyImage", long:%Type%%index%, long:2, long:0, long:0, long:0 ) retval = DllCall( DirWindows(1):"USER32.DLL", long:"SetSystemCursor" , long:CursorHandle, long:StrSub( dacursor, 1, 5 )) EndIf If FileCursor == 1 Type = 'FileCursor' %Type%%index% = DllCall( DirWindows(1):"USER32.DLL", long: "LoadImageA" , long:0, lpstr:Cursor, long:uType, long:cx, long:cy, long:16 ) retval = DllCall( DirWindows(1):"USER32.DLL", long:"SetSystemCursor" , long:%Type%%index%, long:StrSub( dacursor, 1, 5 )) EndIf Next If IsDefined(AndMask) Then BinaryFree(AndMask) If IsDefined(XorMask) Then BinaryFree(XorMask) Return 1 EndIf BinaryFree(AndMask) BinaryFree(XorMask) Return 0 #EndFunction #DefineFunction udfRestoreCursors() ;*************************************************************************** ;** Restore System Cursor ;** ;** SYNTAX: ;** udfRestoreCursors() ;** PARAMETERS: ;** NONE ;** ;*************************************************************************** SPI_SETCURSORS = 87 ; 0x57 SysParamInfo( SPI_SETCURSORS, 0, 0) #EndFunction BoxOpen('Setting System Cursor','IDC_WAIT') udfSetSystemCursor( 'IDC_WAIT', 0, 0); Test IDC_WAIT cursor TimeDelay(5) BoxText('C:\Program Files\WinBatch\Icons\artowl3.ico') udfSetSystemCursor( 'C:\Program Files\WinBatch\Icons\artowl3.ico', 0, 0); Test file cursor TimeDelay(5) BoxText('Default System Cursor') udfRestoreCursors () TimeDelay(5) Exit
Article ID: W17413
File Created: 2009:08:26:10:56:28
Last Updated: 2009:08:26:10:56:28