Jump to content

Recommended Posts

Posted

I am trying to write an application to act as an installer front screen.

As the user changes the focus in the screen then the text in a label changes to tell the user what the option does.

I would like to be able to display the contents of a read me file and need an edit box to do so. I have made this read only and can set the mouse to not click within the control ( not shown in this script here) however I cannot stop the selection of all of the text when tabbing through the controls and hiting the edit box. I can reset the the selection as indicated in the example but with a lot of text this can be seen as a flicker. Also the caret becomes visible indicating editing is possible.

Is there any way i can

1 Stop the automatic selection when tabbing to the edit box

2 Not show the I beam caret in the edit control

3 Possibly remove the editbox from the tab order completely and allow the last tab to be a hidden control hence still change the information in the label box to indicate that the text is from the read me

#include <GUIConstants.au3>
#include <GuiEdit.au3>

AutoItSetOption("GUIEventOptions", 1)
;Vars
$x = 802
$y = 590
$readme = "Sample read me"&@crlf&"further lines etc may be many so need scrollable window"
$message = "Take you to the installation notes. (PDF reader required to be installed on your PC)."
;Main Gui
GUICreate("Installer", $x, $y, (@DesktopWidth - $x) / 2, (@DesktopHeight - $y) / 2, BitOR($ws_popup, $ws_caption, $ws_sysmenu) + $DS_SETFOREGROUND + $WS_VISIBLE + $WS_CLIPSIBLINGS)

$Button1 = GUICtrlCreateButton("Install notes", 25, $y - 300, 100, 25)

$Button2 = GUICtrlCreateButton("Update Notes", 25, $y - 250, 100, 25)
$Button3 = GUICtrlCreateButton("Install", 25, $y - 200, 100, 25)
$Button4 = GUICtrlCreateButton("Install 2", 25, $y - 150, 100, 25)
$Button5 = GUICtrlCreateButton("Main Help", 25, $y - 100, 100, 25)
$Button6 = GUICtrlCreateButton("Guide", 25, $y - 50, 100, 25)
$Edit1 = GUICtrlCreateEdit($readme, 150, 10, $x - 150, $y - 200)
GUICtrlSetBkColor($Edit1, 0xffffff);Set background to white for ease of reading
GUICtrlSetStyle($Edit1, $WS_VSCROLL + $WS_HSCROLL + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL + $ES_READONLY);Set scrollbars and read only
GUICtrlSetCursor($Edit1, 2);set cursor to the same as rest of dialog so as not to indicate editbox
GUICtrlCreateLabel("", 145, $y - 155, $x - 160, 140, $SS_sunken)
;GUICtrlSetStyle($label,$SS_ETCHEDFRAME,-1 )
$label = GUICtrlCreateLabel("This button will:-" & @CRLF & @CRLF & $message, 150, $y - 150, $x - 170, 130, -1)
GUICtrlSetFont($label, 10, 500, "", "")
GUICtrlSetData($label, "This button will:-" & @CRLF & @CRLF & $message)
GUISetState(@SW_SHOW)

GUICtrlSetState($Button1, $GUI_FOCUS)
$focusori = "Button1"
;Hnadle dialog after display
While 1
    $msg = GUIGetMsg()
    $focus = ControlGetFocus("Installer")
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
            
        ;Check if user clicked on the "Install notes" button
        Case $focus<>$focusori;Focus has changed so might need to change the label test
            Select
            Case $focus = "Button2"         
            $message = "Take you to the update notes. "
            GUICtrlSetData($label, "This button will:-" & @CRLF & @CRLF & $message)
            $focusori = "Button2"
            Case $focus = "Button3"         
            $message = "Start the normal installer for the program. "
            GUICtrlSetData($label, "This button will:-" & @CRLF & @CRLF & $message)
            $focusori = "Button3"
            Case $focus = "Button4"         
            $message = "Start the WTS installer for the program. "
            GUICtrlSetData($label, "This button will:-" & @CRLF & @CRLF & $message)
            $focusori = "Button4"
            Case $focus = "Button5"         
            $message = "Open the main help file. "
            GUICtrlSetData($label, "This button will:-" & @CRLF & @CRLF & $message)
            $focusori = "Button5"
            Case $focus = "Button6"         
            $message = "Open the guide. "
            GUICtrlSetData($label, "This button will:-" & @CRLF & @CRLF & $message)
            $focusori = "Button6"
            Case $focus = "Edit1"
        ;_GUICtrlEditSetSel ( $edit1, 255, 255 );Reseting the selection from tabbing on control but this gives a flicker
            $message = "Read me file. This gives the version number, release date and also a summary of the features of the release as well as previous releases as well."
            GUICtrlSetData($label, "The read me file:-" & @CRLF & @CRLF & $message)
            $focusori = "Edit1"
            Case $focus = "Button1"         
            $message = "Take you to the installation notes. (PDF reader required to be installed on your PC)"
            GUICtrlSetData($label, "This button will:-" & @CRLF & @CRLF & $message)
            $focusori = "Button1"
            EndSelect
        Case $msg = $Button1
        ;Button 1 event
            
        Case $msg = $Button2;Clicked on the update notes
        ;Button 2 event
            
        Case $msg = $Button3;Clicked on the install button
        ;Button 3 event
            
        Case $msg = $Button4;Clicked on the install button
        ;Button 4 event
            
        Case $msg = $Button5;Clicked on the install button
        ;Button 5 event
            
        Case $msg = $Button6;Clicked on the install button
        ;Button 6 event
            
            
    EndSelect
WEnd

Exit
Posted

Ok, this way you can't tab into it, but you can still select text. Though you have code to prevent that already. And it looks a bit like you can't change styles afterwards or it will start tabbing into it.

Anyways, change this:

$Edit1 = GUICtrlCreateEdit($readme, 150, 10, $x - 150, $y - 200)
GUICtrlSetBkColor($Edit1, 0xffffff);Set background to white for ease of reading
GUICtrlSetStyle($Edit1, $WS_VSCROLL + $WS_HSCROLL + $ES_AUTOVSCROLL + $ES_AUTOHSCROLL + $ES_READONLY);Set scrollbars and read only

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
  • Recently Browsing   0 members

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