Jump to content

Help with RICH TEXT BOX - READ ONLY?


nikolajp
 Share

Recommended Posts

I have tried making a rich text box become read-only, but without success.

I need the ability to tab out of the Rich Text Box, so if it's ReadOnly, that should fix it right?

Do you have any ideas to accomplish this?

I use this code:

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

$richtextbox = GUICtrlCreateObj($oRP, 3, 50, 600, 475)
GUICtrlSetPos($richtextbox, 3, 42, 964, 475)

$oRP.Font = 'Courier New'

;scrollbar setting
$rt_handle = ControlGetHandle($version, "", "RichTextWndClass1")
_SendMessage($rt_handle, $EM_SHOWSCROLLBAR, $SB_VERT, True)

I found this link on MSDN to make a text-box readonly (rich text and tex should share some attributes:

http://msdn2.microsoft.com/en-us/library/a...585(VS.71).aspx

But I cannot seem to get the ReadOnly attribute working.

I tried this without succes:

$oRP.ReadOnly = True

Link to comment
Share on other sites

Using Beta:

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

$oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")

$oRP = ObjCreate("RICHTEXT.RichtextCtrl.1")

GUICreate("Embedded RICHTEXT control Test", 320, 200, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$TagsPageC = GUICtrlCreateLabel('Visit Tags Page', 5, 180, 100, 15, $SS_CENTER)
GUICtrlSetFont($TagsPageC, 9, 400, 4)
GUICtrlSetColor($TagsPageC, 0x0000ff)
GUICtrlSetCursor($TagsPageC, 0)
$AboutC = GUICtrlCreateButton('About', 105, 177, 70, 20)
$PrefsC = GUICtrlCreateButton('FontSize', 175, 177, 70, 20)
$StatC = GUICtrlCreateButton('Plain Style', 245, 177, 70, 20)

$GUIActiveX = GUICtrlCreateObj($oRP, 10, 10, 400, 260)
GUICtrlSetPos($GUIActiveX, 10, 10, 300, 160)

With $oRP; Object tag pool
    .OLEDrag ()
    .Font = 'Arial'
    .text = "Hello - Au3 supports ActiveX components like the RICHTEXT thanks to SvenP" & @CRLF & 'Try write some text and quit to reload'
    ;.FileName = @ScriptDir & '\RichText.rtf'
    ;.BackColor = 0xff00
EndWith

$rt_handle = ControlGetHandle("Embedded RICHTEXT control Test", "", "RichTextWndClass1")
_GUICtrlEdit_SetReadOnly ($rt_handle, True)

GUISetState();Show GUI

While 1
    $msg = GUIGetMsg()

    Select
        Case $msg = $GUI_EVENT_CLOSE
            $oRP.SaveFile (@ScriptDir & "\RichText.rtf", 0)
            ExitLoop
        Case $msg = $TagsPageC
            Run(@ComSpec & ' /c start http://www.myplugins.info/guids/typeinfo/typeinfo.php?clsid={3B7C8860-D78F-101B-B9B5-04021C009402}', '', @SW_HIDE)
        Case $msg = $AboutC
            $oRP.AboutBox ()
        Case $msg = $PrefsC
            $oRP.SelFontSize = 12
        Case $msg = $StatC
            $oRP.SelBold = False
            $oRP.SelItalic = False
            $oRP.SelUnderline = False
            $oRP.SelFontSize = 8
    EndSelect
WEnd

Exit

Func MyErrFunc()

    MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _
            "err.description is: " & @TAB & $oMyError.description & @CRLF & _
            "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _
            "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _
            "err.source is: " & @TAB & $oMyError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oMyError.helpcontext _
            , 5)
    ; Will automatically continue after 5 seconds

    Local $err = $oMyError.number
    If $err = 0 Then $err = -1

    SetError($err)  ; to check for after this function returns
EndFunc   ;==>MyErrFunc

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

It works by turning the box readonly.

Thank you!

But the tabbing does not work.

If I place the cursor in text (to copy something for example) then I cannot tab out and get focus to the buttons on the GUI.

Is there a way to enable tabbing for the box?

Or perhaps catch a pressed tab if focus is on the window and do something? (like jump to a defined button)

Link to comment
Share on other sites

Anyone?

I don't know if this will help but try adding the style $WS_TABSTOP to the buttons if you haven't already.
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

I don't know if this will help but try adding the style $WS_TABSTOP to the buttons if you haven't already.

I think I perhaps need to add the style you mentioned to the Rich Text Box.

I use the code.

$richtextbox = GUICtrlCreateObj($oRP, 3, 50, 600, 475)
GUICtrlSetPos($richtextbox, 3, 42, 964, 475)

$rt_handle = ControlGetHandle($version, "", "RichTextWndClass1")
_SendMessage($rt_handle, $EM_SHOWSCROLLBAR, $SB_VERT, True)
_GUICtrlEdit_SetReadOnly($rt_handle, True)

I don't know how to apply the style to the control (handle) or if its possible.

I tried (and other variantions):

_SendMessage($rt_handle, $WS_TABSTOP)

but it did not work.

Can I do this? And how?

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...