Jump to content

GUICtrlRead from object - possible ?


Recommended Posts

Hello,

I needed a multi-line input box (like the one that i've used to write this message) and i've found the following example in the Help file

$obj = ObjCreate("RICHTEXT.RichtextCtrl.1")
    With $obj; Object tag pool
        .OLEDrag()
        .Font 

$input_one=GUICtrlCreateObj($obj, 10, 100,10,10)

Now, whenever i use GuiCtrlRead($input_one) i will receive two blank lines (@CR).

Does anyone know if that could ever work, or if i can use anything else except a object ?

Thank you for your time and patience :P

Link to comment
Share on other sites

The GUI functions GUICtrlRead and GUICtrlSet have no effect on this control. The object can only be controlled using 'methods' or 'properties' on the $ObjectVar.

This is off of the help on GuiCtrlCreateObj

Contact via MSN: [email=terarink_msn@hotmail.com]terarink_msn@hotmail.com[/email], yahoo: terarink_yah

Link to comment
Share on other sites

Hello,

I needed a multi-line input box (like the one that i've used to write this message) and i've found the following example in the Help file

$obj = ObjCreate("RICHTEXT.RichtextCtrl.1")
    With $obj; Object tag pool
        .OLEDrag()
        .Font 

$input_one=GUICtrlCreateObj($obj, 10, 100,10,10)

Now, whenever i use GuiCtrlRead($input_one) i will receive two blank lines (@CR).

Does anyone know if that could ever work, or if i can use anything else except a object ?

Thank you for your time and patience :P

This script would be called a multi-line input box with auto-vertical scroll.

Modified "Help Example" for GUICtrlCreateInput ().

#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

Opt('MustDeclareVars', 1)

Example()

Func Example()
    Local $file, $btn, $msg,$InputMultiLine,$aOutput,$res
    
    GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES
    $file = GUICtrlCreateInput("", 10, 5, 300, 20)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    $InputMultiLine = GUICtrlCreateInput("Line1" & @CRLF & "Line 2" & @CRLF & "Line 3", 10, 35, 300, 60,BitOR($ES_MULTILINE,$ES_AUTOVSCROLL)) 
    $btn = GUICtrlCreateButton("Ok", 40, 100, 60, 20)
    GUICtrlSetData ($InputMultiLine,GUICtrlRead ($InputMultiLine) & @CRLF & "Line 4" & @CRLF & "Line 5")

    GUISetState()

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        Select
            Case $msg = $btn
                ExitLoop
        EndSelect
    WEnd
    
    ;A method of collection the inputed data
    $aOutput = StringSplit(GUICtrlRead($InputMultiLine),@CRLF)
    for $x = 1 to $aOutput[0]
        $res &= $aOutput[$x] & @CRLF
    next
    
    MsgBox(4096, "Multi-line Output", $res)
EndFunc   ;==>Example

Hope this helps.

Link to comment
Share on other sites

Hi again,

The example would be OK, but i'm not allowed to insert a new line, plus the vertical scroll does not appear :P

I've tought using _IsPressed (ENTER) --> insert @CR , but i'll try it later

Thanks

Try pressing Ctrl + Enter on key board.

I my PC that seems to allow "insert new line". in the input control.

And yes, no scroll bar, just auto-vertical scroll. If the GUI Control Style, $ES_AUTOVSCROLL, is removed from the GUICtrlCreateInput statement, the height of the input control governs the number of lines you can see - no scroll.

Edit: If you really want a scroll bar you could look at the help file example under GUICtrlCreateEdit. This Edit control could be an alternate solution.

Edited by Malkey
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...