Jump to content
qwert

What is proper way to manage RichEdit on tab panel?

Recommended Posts

qwert

I've built a button-driven tab panel (based on a forum example) and placed an edit control on each tab — the second being a RichEdit control.  (screen capture is below)

Since a RichEdit is essentially a GUI of its own, what is the proper way to manage a rich edit control to at least give the appearance of it being on a tab panel?

Thanks in advance for any help.

;
;       Example of button-driven tab panel
;
#include <GUIConstants.au3>
#include <GuiRichEdit.au3>
Dim $TabSwitcher[2]

$hGui = GUICreate("Button-driven tab panel", 360, 400)
$TabSwitcher[0] = GUICtrlCreateLabel("Regular Edit", 10, 10, 100, 20, $SS_SUNKEN +$SS_CENTER+ $SS_CENTERIMAGE)
GUICtrlSetBkColor($TabSwitcher[0], 0xABCDEF)

$TabSwitcher[1] = GUICtrlCreateLabel("Rich Edit", 120, 10, 90, 20, $SS_SUNKEN +$SS_CENTER+ $SS_CENTERIMAGE)

$tab = GUICtrlCreateTab(10, 40, 340, 340)

$tab1 = GUICtrlCreateTabItem("tab1")
$Input = GUICtrlCreateEdit("Regular text", 20, 80, 200, 200, $WS_VSCROLL)

$tab2 = GUICtrlCreateTabItem("tab2")
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 100, 160, 200, 200, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_AppendText($hRichEdit, "This is rich text")

GUICtrlSetState($tab, $GUI_HIDE)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = -3
            Exit
        Case $msg = $TabSwitcher[0]
            If GUICtrlRead($tab) <> 0 Then GUICtrlSetState($tab1, $GUI_SHOW)
                 GUICtrlSetBkColor($TabSwitcher[0], 0xABCDEF)
                 GUICtrlSetBkColor($TabSwitcher[1], 0xf0f0f0)
        Case $msg = $TabSwitcher[1]
            If GUICtrlRead($tab) <> 1 Then GUICtrlSetState($tab2, $GUI_SHOW)
                 GUICtrlSetBkColor($TabSwitcher[0], 0xf0f0f0)
                 GUICtrlSetBkColor($TabSwitcher[1], 0xABCDEF)
    EndSelect
WEnd

5ae142afa1dbf_RichOnTab.PNG.5fcd0b88be194f6d8c41faf90da7dd34.PNG

Share this post


Link to post
Share on other sites
Melba23

qwert,

The Tabs tutorial in the Wiki shows how to deal with this problem.

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
qwert

Melba23, thanks for the nudge!

I had searched help and these forums, but didn't think about the Wiki.  Although it took me a moment to see the forest, the operative statement is:

Quote

Before going further, it is important to understand the differences between controls created using the built-in AutoIt commands (GUICtrlCreate*) and those created with the UDFs.

I've never used Control Hide and Control Show statements, but I'm glad to see how they address a whole realm of possibilities.  For anyone following this topic, I've updated my example, accordingly.  Although the use of a tab control becomes almost an aside, I've left it in because it can support all the non-UDF controls.

;
;       Example of button-driven tab panel
;
#include <GUIConstants.au3>
#include <GuiRichEdit.au3>
Dim $TabSwitcher[2]

$hGui = GUICreate("Button-driven tab panel", 360, 400)
$TabSwitcher[0] = GUICtrlCreateLabel("Regular Edit", 10, 10, 100, 20, $SS_SUNKEN +$SS_CENTER+ $SS_CENTERIMAGE)
GUICtrlSetBkColor($TabSwitcher[0], 0xABCDEF)

$TabSwitcher[1] = GUICtrlCreateLabel("Rich Edit", 120, 10, 90, 20, $SS_SUNKEN +$SS_CENTER+ $SS_CENTERIMAGE)

$tab = GUICtrlCreateTab(10, 40, 340, 340)

$tab1 = GUICtrlCreateTabItem("tab1")
$Input = GUICtrlCreateEdit("Regular text", 20, 80, 200, 200, $WS_VSCROLL)

$tab2 = GUICtrlCreateTabItem("tab2")
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "", 100, 160, 200, 200, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
_GUICtrlRichEdit_AppendText($hRichEdit, "This is rich text")

GUICtrlSetState($tab, $GUI_HIDE)
ControlHide($hGUI, "", $hRichEdit)

GUISetState()

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = -3
            Exit
        Case $msg = $TabSwitcher[0]
;            If GUICtrlRead($tab) <> 0 Then GUICtrlSetState($tab1, $GUI_SHOW)
                GUICtrlSetBkColor($TabSwitcher[0], 0xABCDEF)
                GUICtrlSetBkColor($TabSwitcher[1], 0xf0f0f0)
                ControlHide($hGUI, "", $hRichEdit)
                ControlShow($hGUI, "", $Input)
    Case $msg = $TabSwitcher[1]
;       If GUICtrlRead($tab) <> 1 Then GUICtrlSetState($tab2, $GUI_SHOW)
                GUICtrlSetBkColor($TabSwitcher[0], 0xf0f0f0)
                GUICtrlSetBkColor($TabSwitcher[1], 0xABCDEF)
                ControlHide($hGUI, "", $Input)
                ControlShow($hGUI, "", $hRichEdit)
    EndSelect
WEnd

 

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

×