Jump to content

Creating Edit Controls...


Recommended Posts

  • Moderators

Nothing2Lose,

Like this perhaps? :graduated:

#include <GUIConstantsEx.au3>

Global $hGUI_Child = 9999 ; You need this to prevent an error in the GUIGetMsg loop when the child does not exist

; Create parent
$hGUI_Parent = GUICreate("Parent", 500, 500)

; Create paretn menu
$mFilemenu_Parent = GUICtrlCreateMenu("File")
    $mEditItem_Parent  = GUICtrlCreateMenuitem ("Edit",$mFilemenu_Parent)
    GUICtrlCreateMenuitem ("",$mFilemenu_Parent)
    $mExitItem_Parent  = GUICtrlCreateMenuitem ("Exit",$mFilemenu_Parent)
; Check remaining client size
$aSize = WinGetClientSize($hGUI_Parent)
; And create edit to fill
$hEdit_Parent = GUICtrlCreateEdit("Parent Edit Control", 0, 0, $aSize[0], $aSize[1])

GUISetState()

While 1

    ; Use advanced parameter to distinguish between GUIs
    $aMsg = GUIGetMsg(1)
    Switch $aMsg[1]
        Case $hGUI_Parent
            Switch $aMsg[0]
                Case $GUI_EVENT_CLOSE, $mExitItem_Parent
                    ; Parent wants to exit so exit script
                    Exit
                Case $mEditItem_Parent
                    ; Disable menu item
                    GUICtrlSetState($mEditItem_Parent, $GUI_DISABLE)
                    ; Create child GUI
                    $hGUI_Child = GUICreate("Child", 200, 200, -1, -1, -1, -1, $hGUI_Parent)
                    $mFilemenu_Child = GUICtrlCreateMenu("File")
                        $mInsertItem_Child  = GUICtrlCreateMenuitem ("Insert",$mFilemenu_Child)
                        GUICtrlCreateMenuitem ("",$mFilemenu_Child)
                        $mExitItem_Child  = GUICtrlCreateMenuitem ("Exit",$mFilemenu_Child)
                    $hEdit_Child = GUICtrlCreateEdit("Child Edit Control", 0, 0, 200, 200)
                    GUISetState()
            EndSwitch
        Case $hGUI_Child
            Switch $aMsg[0]
                Case $mInsertItem_Child
                    ; Insert current child text into parent and close child
                    $sText = GUICtrlRead($hEdit_Child)
                    GUICtrlSetData($hEdit_Parent, $sText, " ")
                    ContinueCase ; Carry on into next Case
                Case $GUI_EVENT_CLOSE, $mExitItem_Child
                    ; Child wants to exit so close child
                    GUIDelete($hGUI_Child)
                    GUICtrlSetState($mEditItem_Parent, $GUI_ENABLE)
            EndSwitch
    EndSwitch

WEnd

If the GUIGetMsg loop seems overcomplicated, look at the Managing Multiple GUIs tutorial in the Wiki to understand why. :(

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

Nothing2Lose,

Do you not think that it would have helped to have included that picture in your original post? :(

Writing code for people who ask a clear question and then change the goalposts when given a valid solution is not how I prefer to spend my time here. :graduated:

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

Those characters require Unicode. You could do this, for example:

#include <GuiConstantsEx.au3>

; Change encoding of script file to UTF-8
$hGUI = GUICreate("Unicode Text Test", 400, 300)
$sString = "This is UTF-8 Unicode:" & @CRLF & "Where n ≠ 0; a ± n ≠ a" & @CRLF & "2³ = 8"
$idLabel = GUICtrlCreateLabel($sString, 20, 20, 360, 100)
GUISetState()

Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE

There is no magic inside AutoIt that makes that work, it simply supports the use of Unicode. What matters is that the Windows APIs used, or the app you are working with, can display the Unicode you want to use. For example, that code will not display properly in SciTE4AutoIt3 unless you change the script file encoding to UTF.

:graduated:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...