Sign in to follow this  
Followers 0
Nothing2Lose

Creating Edit Controls...

6 posts in this topic

Hi all,

How can i create (a) edit control in the other (like MathType)??? :|

Thanks!

Share this post


Link to post
Share on other sites



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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Thank you! But i want to talk about this (see attachment :-) ).

post-59565-12885187962185_thumb.gif

Edited by Nothing2Lose

Share this post


Link to post
Share on other sites

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


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______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

 

Share this post


Link to post
Share on other sites

Ah. One more question! How can i display maths symbols (square root, sum,...) in a GUI?

Share this post


Link to post
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

Share this post


Link to post
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
Sign in to follow this  
Followers 0