Jump to content

Scroll bar and edit box readonly


Recommended Posts

Viva,

Does anyone can help me:

- I have a readonly edit box, which receives data from a program, and when I do a click on it, the data in the edit box, are all changed.

Is there way to prevent this situation, keeping the scroll bar to work?

- On how to disable listview modifications, keeping the scroll bar to work?

If someone can lend a hand thanks.

Along attached an example of what I would have to work

grateful

Nuno

Link to comment
Share on other sites

  • Moderators

NunoBorges,

To prevent changes to the ListView while retaining the working scrollbars, I suggest you use my GUIScrollbarsEx UDF (look in my sig) and create a scrolling child GUI to hold the disabled ListView.

This should give you the idea:

#cs
    _GUICtrlListViewSetItemSelState($ListView1, Change_DISABLE....

    When a process is running,
    what can i do like the above,
    to disable any change on the listview
#ce
#include <ButtonConstants.au3>
#include <Constants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>

#Include <GUIScrollBars_Ex.au3>

#region ### START Koda GUI section ### Form=C:\AutoIt NDB Kit\- 0 Exemplos\Form1.kxf
Global $Form1 = GUICreate("Form1", 223, 449, 192, 114)
Global $Label1 = GUICtrlCreateLabel("Label1", 11, 2, 200, 34, $SS_CENTER)
GUICtrlSetData($Label1, "click on the box down while a process is in progress.")

Global $Edit1 = GUICtrlCreateEdit("", 11, 48, 200, 80, BitOR($GUI_SS_DEFAULT_EDIT,$ES_READONLY))
GUICtrlSetTip(-1, "Click on here when it's running a process")
GUICtrlSetData(-1, "")

Global $Run = GUICtrlCreateButton("run /c ping www.db.pt", 11, 130, 200, 25)
Global $Label2 = GUICtrlCreateLabel("Use the above to run a process and wait until finished", 11, 162, 200, 34, $SS_CENTER)

Global $LVEnable = GUICtrlCreateButton("Enable Scroll", 11, 304, 75, 25)
Global $LVDisable = GUICtrlCreateButton("Disable Scroll", 136, 304, 75, 25)
Global $Stop = GUICtrlCreateButton("Stop", 72, 352, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

$hGUI_ListView = GUICreate("", 200, 100, 11, 204, $WS_POPUP, $WS_EX_MDICHILD, $Form1)
GUISetState(@SW_SHOW)
Global $ListView1 = GUICtrlCreateListView("Col1", 0, 0, 400, 300, BitOR($GUI_SS_DEFAULT_LISTVIEW, $LVS_AUTOARRANGE), $WS_EX_CLIENTEDGE)
_GUICtrlListView_SetExtendedListViewStyle($ListView1, BitOR($LVS_EX_GRIDLINES, $LVS_EX_CHECKBOXES, $LVS_EX_FULLROWSELECT))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 220)
_Add_LV1_Items()
GUICtrlSetState($ListView1, $GUI_DISABLE)

_GUIScrollBars_Generate($hGUI_ListView, 400, 300)

GUISwitch($Form1)

Global $Pid, $line

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

        Case $GUI_EVENT_CLOSE
            #cs
                If ProcessExists($Pid[1][0]) Then _
                ProcessClose($Pid[1][0])
            #ce
            Exit

        Case -100 To 0
            ContinueLoop

        Case $Run
            GUICtrlSetState($ListView1, $GUI_DISABLE)
            _Run_()
            GUICtrlSetState($ListView1, $GUI_ENABLE)

        Case $LVEnable
            MsgBox(528416, "How to?", "How to enable 'Just the Scroll Bar', or prevent changes on the list view" & @CRLF & "When a process is running")

        Case $LVDisable
            MsgBox(528416, "How to?", "How to disable changes on listview items," & @CRLF & "and 'Just enable the Scroll Bar'," & @CRLF & "When a process is running")

    EndSwitch
WEnd

Func _Run_()

    $pid_CMD = Run(@ComSpec & " /c ping www.db.pt", @TempDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Sleep(5)
    $Pid = _WinAPI_EnumChildProcess($pid_CMD)

    While $pid_CMD

        $msg = GUIGetMsg()
        Select
            Case $msg = $Stop
                $Check_Stopped = True
                GUICtrlSetData($Edit1, @CRLF & @CRLF & "Stopped ... ", True)
                If ProcessExists($Pid[1][0]) Then _
                        ProcessClose($Pid[1][0])

            Case $msg = $GUI_EVENT_CLOSE
                If ProcessExists($Pid[1][0]) Then _
                        ProcessClose($Pid[1][0])
                GUIDelete()
                Exit
        EndSelect

        $line = StdoutRead($pid_CMD)
        If @error Then ExitLoop
        ;sleep(5)
        GUICtrlSetData($Edit1, $line, 1)
    WEnd

    While 1
        $line = StderrRead($Pid)
        If @error Then ExitLoop
        MsgBox(0, "STDERR read:", $line)
    WEnd

EndFunc   ;==>_Run_

Func _Add_LV1_Items()
    For $i = 0 To 10
        GUICtrlCreateListViewItem("Run cmd " & $i & "|", $ListView1)
    Next
    _GUICtrlListView_SetItemChecked($ListView1, 1, True)


EndFunc   ;==>_Add_LV1_Items

Func _WinAPI_EnumChildProcess($Pid = 0); good example from UEZ
    If Not $Pid Then
        $Pid = _WinAPI_GetCurrentProcessID()
        If Not $Pid Then Return SetError(1, 0, 0)
    EndIf

    Local $hSnapshot = DllCall('kernel32.dll', 'ptr', 'CreateToolhelp32Snapshot', 'dword', 0x00000002, 'dword', 0)
    If (@error) Or (Not $hSnapshot[0]) Then Return SetError(1, 0, 0)

    Local $tPROCESSENTRY32 = DllStructCreate('dword Size;dword Usage;dword ProcessID;ulong_ptr DefaultHeapID;dword ModuleID;dword Threads;dword ParentProcessID;long PriClassBase;dword Flags;wchar ExeFile[260]')
    Local $pPROCESSENTRY32 = DllStructGetPtr($tPROCESSENTRY32)
    Local $Ret, $Result[101][2] = [[0]]

    $hSnapshot = $hSnapshot[0]
    DllStructSetData($tPROCESSENTRY32, 'Size', DllStructGetSize($tPROCESSENTRY32))
    $Ret = DllCall('kernel32.dll', 'int', 'Process32FirstW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
    While (Not @error) And ($Ret[0])
        If DllStructGetData($tPROCESSENTRY32, 'ParentProcessID') = $Pid Then
            $Result[0][0] += 1
            If $Result[0][0] > UBound($Result) - 1 Then
                ReDim $Result[$Result[0][0] + 100][2]
            EndIf
            $Result[$Result[0][0]][0] = DllStructGetData($tPROCESSENTRY32, 'ProcessID')
            $Result[$Result[0][0]][1] = DllStructGetData($tPROCESSENTRY32, 'ExeFile')
        EndIf
        $Ret = DllCall('kernel32.dll', 'int', 'Process32NextW', 'ptr', $hSnapshot, 'ptr', $pPROCESSENTRY32)
    WEnd
    _WinAPI_CloseHandle($hSnapshot)
    If $Result[0][0] Then
        ReDim $Result[$Result[0][0] + 1][2]
    Else
        Return SetError(1, 0, 0)
    EndIf
    Return $Result
EndFunc   ;==>_WinAPI_EnumChildProcess

I will look at the edit problem later. :)

M23

Edit: Added example. :mellow:

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

NunoBorges,

when I do a click on it, the data in the edit box, are all changed

Can you be more specific about the problem you have with the edit control? When I get input into the control I cannot make it "change" by "clicking" within it. :mellow:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

NunoBorges,

The next text you enter will be interspersed

That is what you are asking AutoIt to do when you use the "default" flag with GUICtrlSetData: :)

"default [optional] [...] Edit, Input: If non-empty (""), the string is inserted at the current insertion point (caret)."

I assume you want to add new text to the end of the existing data - if so then you can use _GUICtrlEdit_AppendText to do this: :mellow:

_GUICtrlEdit_AppendText($Edit1, $line)
;GUICtrlSetData($Edit1, $line, 1)

Do not forget to add #Include <GuiEdit.au3> at the top of your script! :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...