Jump to content

hiding a rich edit control


ivan
 Share

Recommended Posts

I need to hide a control created with the GuiRichEdit.au3 library, but I really can't come up with a neat solution. I searched the forums and could not find anything. I would much appreciate any help you may provide on this.

I've tried the obvious, hiding or moving the control out of the form, but this doesn't work. My last attempt was setting stryles, which although creates an initially invisible control, I can't control its visibility at will. My worse solution is destroying the control and creating it again when I need it.

My tests are here:

#AutoIt3Wrapper_Au3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

TestHide()
TestMove()
TestVisibility()

Func TestHide()
    Local $hGui, $hRichEdit, $iMsg
    Local $btn_hide
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $btn_hide = GUICtrlCreateButton('hide edit ctrl', 8, 280, 100, 30)
    GUISetState()

    While 1
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit)
                GUIDelete()
                ExitLoop
            Case $iMsg = $btn_hide
                GUICtrlSetState($hRichEdit, $GUI_HIDE)
        EndSelect
    WEnd
    _GUICtrlRichEdit_Destroy($hRichEdit)
    GUIDelete()
EndFunc   ;==>Main

Func TestMove()
    Local $hGui, $hRichEdit, $iMsg
    Local $btn_hide, $btn_show
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "test moving", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    $btn_hide = GUICtrlCreateButton('hide edit ctrl', 8, 280, 100, 30)
    $btn_show = GUICtrlCreateButton('show edit ctrl', 150, 280, 100, 30)
    GUISetState()

    While 1
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit)
                GUIDelete()
                ExitLoop
            Case $iMsg = $btn_hide
                GUICtrlSetPos($hRichEdit, -1000, -1000,300, 220)
            Case $iMsg = $btn_show
                GUICtrlSetPos($hRichEdit, 10, 10,300, 220)
        EndSelect
    WEnd
    _GUICtrlRichEdit_Destroy($hRichEdit)
    GUIDelete()
EndFunc   ;==>Main

Func TestVisibility()
    Local $hGui, $hRichEdit, $iMsg
    Local $btn_show
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL,-$WS_VISIBLE))
    $btn_show = GUICtrlCreateButton('SHOW edit ctrl', 8, 280, 100, 30)
    GUISetState()

    While 1
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit)
                GUIDelete()
                ExitLoop
            Case $iMsg = $btn_show
                GUICtrlSetStyle($hRichEdit, $WS_VISIBLE)
        EndSelect
    WEnd
    _GUICtrlRichEdit_Destroy($hRichEdit)
    GUIDelete()
Link to comment
Share on other sites

The RichEdit cannot be controlled with the native GUICtrl-functions. You have to use WinSetState, WinMove etc. Sometimes, Control... works, too.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

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