Jump to content

What's wrong with tab?


Recommended Posts

Whats wrong here? How I can make only "Untitled" show that label (and "Untitled2" should be empty)

If I run that code I will see same label on both tabs, how to I can fix it?

$hTab = _GUICtrlTab_Create($Form1, 0, 0, 640, 120)
_GUICtrlTab_InsertItem($hTab, 0 ,"Untitled")
GUICtrlCreateLabel ( "text",50,50,75,20)
_GUICtrlTab_InsertItem($hTab, 1 ,"Untitled2")

edited

Link to comment
Share on other sites

Hi there if I test it like this

CODE

$myTab = GUICtrlCreateTab(32, 24, 145, 97)

$myTabSheet1 = GUICtrlCreateTabItem("Untitled")

$myTabSheet2 = GUICtrlCreateTabItem("Untitled2")

It works like candy :D

Link to comment
Share on other sites

@E1M1...

Remember that when you use any of the advanced controls like _GuiCtrlCreate*, these controls are not standard controls and currently AutoIt does not play nice with them.

However you can control these yourself by using WM_NOTIFY()

#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>

$Form1 = GUICreate("test",200,200)

$hTab = _GUICtrlTab_Create($Form1, 0, 0, 640, 120)
_GUICtrlTab_InsertItem($hTab, 0 ,"Untitled")

$Label1 = GUICtrlCreateLabel ( "text",50,50,75,20)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)

_GUICtrlTab_InsertItem($hTab, 1 ,"Untitled2")

GUISetState()

GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $msg = GUIGetMsg()

    If $msg = $GUI_EVENT_CLOSE Then ExitLoop

WEnd

GUIDelete()

Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
    Local $hWndTab, $tNMHDR, $HwndFrom, $iCode
   
    $hWndTab = $hTab
    If Not IsHWnd($hWndTab) Then $hWndTab = GUICtrlGetHandle($hTab)
   
    $tNMHDR = DllStructCreate($tagNMHDR, $lParam)
    $HwndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iCode = DllStructGetData($tNMHDR, "Code")
   
    Switch $HwndFrom
        Case $hWndTab
            Switch $iCode
                Case $TCN_SELCHANGE
                    Switch _GUICtrlTab_GetCurSel($hTab)
                        Case 0
                           GUICtrlSetState($Label1,$GUI_SHOW)
                        Case 1
                           GUICtrlSetState($Label1,$GUI_HIDE)
                        Case 2; Third tab...
                        Case 3; Fourth tab...
                    EndSwitch
            EndSwitch
    EndSwitch
   
    Return $GUI_RUNDEFMSG
EndFunc

:D

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