Jump to content

Recommended Posts

Posted

Hi,

I have written an AutoIt application which displays a window, reads lots of files in directories and sub-directories, and outputs occurrences of a particular string in the files to the window's edit control. Althought the edit control is readonly, if the user clicks it, say, in the middle, the text output by the application appears where the user clicked, not at the bottom of the edit control anymore. Is there a way to prevent users from clicking inside an edit control?

Many thanks.

pr1

Posted

Hi,

I have written an AutoIt application which displays a window, reads lots of files in directories and sub-directories, and outputs occurrences of a particular string in the files to the window's edit control. Althought the edit control is readonly, if the user clicks it, say, in the middle, the text output by the application appears where the user clicked, not at the bottom of the edit control anymore. Is there a way to prevent users from clicking inside an edit control?

Many thanks.

pr1

With ControlDisable() function.
Posted

With ControlDisable() function.

Many thanks. The only problem is that it dims the text in the edit control, but I guess, I can't have it all.

Posted

Hi,

I have written an AutoIt application which displays a window, reads lots of files in directories and sub-directories, and outputs occurrences of a particular string in the files to the window's edit control. Althought the edit control is readonly, if the user clicks it, say, in the middle, the text output by the application appears where the user clicked, not at the bottom of the edit control anymore. Is there a way to prevent users from clicking inside an edit control?

Many thanks.

pr1

@pr1

subclass the edit control and block WM_SETFOCUS messages

#AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiEdit.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <GUIConstantsEX.au3>
#include <Constants.au3>

Opt('MustDeclareVars', 1)

Global $hEdit, $wProcOld, $wProcNew
Global $hGUI, $Edit, $msg

; Create GUI
$hGUI = GUICreate("Edit Create", 400, 300)
$Edit = GUICtrlCreateEdit("This is a test" & @CRLF & "Another Line", 2, 2, 394, 268, $ES_READONLY)
GUICtrlSetBkColor(-1, 0xFFFFFF)

; Subclass edit control
$hEdit = GUICtrlGetHandle($Edit) ; if using _GUICtrlEdit_Create() then omit this line
$wProcNew = DllCallbackRegister("_EditWindowProc", "ptr", "hwnd;uint;wparam;lparam")
$wProcOld = _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, DllCallbackGetPtr($wProcNew))

GUISetState()

_GUICtrlEdit_AppendText($hEdit, @CRLF & "Append to the end?")
_GUICtrlEdit_AppendText($hEdit, @CRLF & "Append to the end?")

Do
    $msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE


; required on exit if subclassing
; reset window procedure for edit control
If $wProcOld Then
    _WinAPI_SetWindowLong($hEdit, $GWL_WNDPROC, $wProcOld)
EndIf

; Delete callback function
If $wProcNew Then DllCallbackFree($wProcNew)

GUIDelete()
Exit

; subclass function
Func _EditWindowProc($hWnd, $iMsg, $wParam, $lParam)
    #forceref $hWnd, $iMsg, $wParam, $lParam
    Switch $iMsg
        Case $WM_SETFOCUS;, $WM_NCHITTEST
            Return 0
    EndSwitch
    ;pass the unhandled messages to default WindowProc
    Return _WinAPI_CallWindowProc($wProcOld, $hWnd, $iMsg, $wParam, $lParam)
EndFunc   ;==>_EditWindowProc

I see fascists...

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...