Jump to content

Recommended Posts

  • 3 weeks later...
Posted

Try GUISetCursor

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

I certainly tried this function! But thanks for wanting to help!

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")
    GUISetState(@SW_SHOW)
    GUISetCursor(1,1,$hRichEdit)
    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example

 

Posted

AndreyS,

Yes, there is no built-in AutoIt function to change a rich edit cursor.  However, I have only rudimentary experience with this.

kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Posted

:)

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>
#include <winapiex.au3>
#include <WinAPIRes.au3>

$crazy = @tempdir & "\1.cur"
InetGet("http://www.rw-designer.com/cursor-download.php?id=103021", $crazy)

Global $Flag
$hold_cursor = _WinAPI_CopyCursor(_WinAPI_LoadCursor (0, $OCR_IBEAM))
$hnew_Cursor = _WinApi_LoadCursorFromFile($crazy)

    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")
    GUISetState(@SW_SHOW)

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
            _WinAPI_SetSystemCursor($hold_Cursor, $OCR_IBEAM)
            _WinAPI_DestroyCursor($hnew_Cursor)
            _WinAPI_DestroyCursor($hold_cursor )
                Exit
        EndSelect

   If (_CheckMouseOver() = True) and $Flag Then
            _WinAPI_SetSystemCursor($hnew_Cursor, $OCR_IBEAM, 1)
            $Flag = False
    ElseIf (_CheckMouseOver() = False) and not $Flag Then
            _WinAPI_SetSystemCursor($hold_Cursor, $OCR_IBEAM, 1)
            $Flag = True
    EndIf
    WEnd


Func _CheckMouseOver()
    Local $RET = False
    If WinActive($hGui) Then
        Local $aMousePos = MouseGetPos()
        Local $aGuiPos = WinGetPos($hRichEdit)
        If ($aMousePos[0] > $aGuiPos[0]) And ($aMousePos[0] < ($aGuiPos[0] + $aGuiPos[2])) And _
                ($aMousePos[1] > $aGuiPos[1]) And ($aMousePos[1] < ($aGuiPos[1] + $aGuiPos[3])) Then
            $RET = True
        EndIf
    EndIf
    Return $RET
EndFunc   ;==>_CheckMouseOver

 

Posted (edited)

Thank you, mikell, for solving the problem and the idea!

Now it is even easier to organize.

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <WindowsConstants.au3>


Dim $hGui, $hRichEdit, $iMsg, $Flag
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "This is more text")
GUISetState(@SW_SHOW)

While True
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
            ; GUIDelete()   ; is OK too
            Exit
    EndSelect
    If (_CheckMouseOver() = True) and $Flag Then
        GUISetCursor(0,1) 
        $Flag = False
    ElseIf (_CheckMouseOver() = False) and not $Flag Then
        GUISetCursor() 
        $Flag = True
    EndIf
WEnd

Func _CheckMouseOver()
    Local $RET = False
    If WinActive($hGui) Then
        Local $aMousePos = MouseGetPos()
        Local $aGuiPos = WinGetPos($hRichEdit)
        If ($aMousePos[0] > $aGuiPos[0]) And ($aMousePos[0] < ($aGuiPos[0] + $aGuiPos[2])) And _
                ($aMousePos[1] > $aGuiPos[1]) And ($aMousePos[1] < ($aGuiPos[1] + $aGuiPos[3])) Then
            $RET = True
        EndIf
    EndIf
    Return $RET
EndFunc   ;==>_CheckMouseOver

 

Edited by AndreyS

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...