Jump to content

GUICtrl Richedit choose tab


Recommended Posts

#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <GuiRichEdit.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
#include <Constants.au3>

$Form1 = GUICreate("Main", 400, 400)
$idTab = GUICtrlCreateTab(2, 2, 396, 396)
$hTab = GUICtrlGetHandle($idTab)
$TabSheet1 = GUICtrlCreateTabItem("Main")
GUICtrlCreateLabel("Main tab 0...", 20, 50, 360, 20)
$TabSheet2 = GUICtrlCreateTabItem("History")
GUICtrlCreateLabel("History tab 1...", 20, 50, 360, 20)
$hRichEdit = _GUICtrlRichEdit_Create($Form1, "", 20, 80, 360, 200, BitOR($ES_MULTILINE, $ES_READONLY, $WS_VSCROLL))
For $n = 1 To 50
    _GUICtrlRichEdit_AppendText($hRichEdit, $n & ": Test a very long line of text in a RichEdit box." & @CRLF)
Next
ControlDisable($Form1, "", $hRichEdit)
ControlHide($Form1, "", $hRichEdit)
$TabSheet3 = GUICtrlCreateTabItem("blah")
GUICtrlCreateLabel("blah tab 2...", 20, 50, 360, 20)
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($hRichEdit)
            Exit
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab, $iTab
    $hWndTab = $hTab

    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTab
            Switch $iCode
                Case $TCN_SELCHANGE ; selection changed
                    $iTab = _GUICtrlTab_GetCurSel($hTab)
                    Switch $iTab
                        Case 1
                            ControlEnable($Form1, "", $hRichEdit)
                            ControlShow($Form1, "", $hRichEdit)
                        Case Else
                            ControlDisable($Form1, "", $hRichEdit)
                            ControlHide($Form1, "", $hRichEdit)
                    EndSwitch
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

hello I need some help here.
I have this example to select which tab the GUICtrlRichEdit will appear, however this example appears in tab 2, I need that appears on the tab 1.
tried many ways not obitive success.
if anyone can help me I thank.

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