Sign in to follow this  
Followers 0
ttleser

Gui - Tabs and Menus

6 posts in this topic

I've got a program that has 2 Tabs and 2 menu items (each menu with 2 items). Not sure why it's doing this but if you goto Tab1 you can access all the menu items but if you goto Tab2 you can't click on the menu items. It's almost like each Tab is it's own GUI.

Any thoughts?

Share this post


Link to post
Share on other sites



did you put the GUICtrlCreateMenu before the tabcreate?

Could you post your code?

Share this post


Link to post
Share on other sites

That's exactly it! I put the Menu stuff after the the first Tab section but before the 2nd tab section. I added the 2nd tab later.

Ok, so stupid question about Tabs then. In my script I've got everything to go in the first tab under the 1st instance of GUICtrlCreateTab and everything to go under the second tab after the 2nd instance of GUICtrlCreateTab. Is that how it's supposed to work?

Give me a little explaination about how the tabs work.

Thanks much!

Partial code as it's pretty big! You've got everything up to the functions. BTW, I'm pretty new to programming and I know the code is probably sloppy but I'm learning and hopefully my skills will improve. :D

#include <array.au3>
#include <ExcelCOM_UDF.au3>
#include <Date.au3>
#include <String.au3>
#include <GuiStatusBar.au3>
#include <GUIConstantsEx.au3>
#include <GuiListView.au3>
#include <GuiImageList.au3>
#include <EditConstants.au3>

;#include <TEST_GuiSimpleSort.au3>

Dim $hGUI
Global $aListViewSortInfo
Opt("GuiResizeMode", $GUI_DOCKALL)
Local $listviewA, $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE)
Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES)

$sDate = StringTrimRight(StringReplace(_Nowdate(),"/","-"),4)&StringRight(_NowDate(),2)
;If Month is single digit, add zero to beginning.
If StringInStr($sDate,"-") = 2 Then
    $sDate = _StringInsert($sDate,"0",0)
EndIf

$yDate = StringRight(_NowDate(),2)
$mDate = _DateToMonth(@MON)
$Font = "Arial"
$Font_Bold = "Arial Bold"

; Files
$File = $sDate&".xls"
$UserAccessFile = ("\\s110app3\useraccess$\User Access\"&$yDate&" "&$mDate&"\User Access "&$File)
$TempFile = "\\s110app3\useraccess$\Temp Hires.xls"
$TermFile = "\\s110app3\useraccess$\terminations.xls"
$NewHireFile = "\\s110app3\useraccess$\New Hires.xls"
$FileExist = 0

$xpos = 0;@DesktopWidth - 210
$ypos = 0;@DesktopHeight - 470
$startxpos = 0
$startypos = 20
$startxposB = 0
$startyposB = 20
$startxposA = 0
$startyposA = 60
$xsizeTabBasic = 200
$ysizeTabBasic = 300
$xsizeTabAdvanced = 200
$ysizeTabAdvanced = 330
$xsizeBasic = 207
$ysizeBasic = 393;320
$xsizeAdvanced = 590
$ysizeAdvanced = 460
$xsize = 200
$ysize = 360
$hGUI = GuiCreate("Employee Search",$xsize,$ysize,$xpos,$ypos)
$Filemenu = GUICtrlCreateMenu ("&File")
$m_Fileopen = GUICtrlCreateMenuitem ("Open",$filemenu)
$m_FileExit = GUICtrlCreateMenuitem ("Exit",$filemenu)
$HelpMenu = GUICtrlCreateMenu ("Help")
$m_HelpHelp = GUICtrlCreateMenuitem ("Help",$HelpMenu)
$m_HelpAbout = GUICtrlCreateMenuitem ("About",$HelpMenu)

Local $aParts[2] = [130, -1]
Local $aPartsA[2] = [300, -1]
Local $aText[2] = ["",""]
$hStatus = _GUICtrlStatusBar_Create ($hGUI,$aParts,$aText)

_GUICtrlStatusBar_SetText ($hStatus, $File,1)

$Tab=GUICtrlCreateTab (0,0,$xsizeTabAdvanced,$ysizeTabAdvanced)
$T_Basic=GUICtrlCreateTabitem ("Basic")

GUICtrlSetFont (-1,9, 400, 2, $font)

GuiCtrlCreateLabel("Employee #:",$startxpos+5,$startypos+14,60,20)
$sFindWhat = GUICtrlCreateInput("",$startxpos+70,$startypos+10,50,20)
$b_Find = GUICtrlCreateButton("Find",$startxpos+135,$startypos+10,60,20,$BS_DEFPUSHBUTTON)
$b_Exit = GUICtrlCreateButton("Exit",$startxpos+135,$startypos+35,60,20)

$lFirstName = GUICtrlCreateLabel("First Name:",$startxposB+5,$startyposb+60,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dFirstName = GUICtrlCreateEdit("",$startxposB+85,$startyposb+60,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lLastName = GUICtrlCreateLabel("Last Name:",$startxposB+5,$startyposb+85,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dLastName = GUICtrlCreateEdit("",$startxposB+85,$startyposb+85,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lSoc = GUICtrlCreateLabel("Last 4 Soc#:",$startxposB+5,$startyposb+110,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dSoc = GUICtrlCreateEdit("",$startxposB+85,$startyposb+110,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lDob = GUICtrlCreateLabel("DOB:",$startxposB+5,$startyposb+135,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dDob = GUICtrlCreateEdit("",$startxposB+85,$startyposb+135,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lDoh = GUICtrlCreateLabel("Last DOH:",$startxposB+5,$startyposb+160,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dDoh = GUICtrlCreateEdit("",$startxposB+85,$startyposb+160,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lDot = GUICtrlCreateLabel("Last DOT:",$startxposB+5,$startyposb+185,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dDot = GUICtrlCreateEdit("",$startxposB+85,$startyposb+185,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lCostC = GUICtrlCreateLabel("Cost Center:",$startxposB+5,$startyposb+210,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dCostC = GUICtrlCreateEdit("",$startxposB+85,$startyposb+210,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lstatus = GUICtrlCreateLabel("Status:",$startxposB+5,$startyposb+235,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dstatus = GUICtrlCreateEdit("",$startxposB+85,$startyposb+235,50,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lJobTitle = GUICtrlCreateLabel("Job Title:",$startxposb+5,$startyposb+260,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dJobTitle = GUICtrlCreateEdit("",$startxposb+85,$startyposb+260,100,35,BitOR($ES_MULTILINE,$ES_READONLY));,$ES_READONLY))



$T_Advanced=GUICtrlCreateTabitem ("Advanced")

GuiCtrlCreateLabel("Employee #:",$startxpos+5,$startypos+14,60,20)
$sFindWhatA = GUICtrlCreateInput("",$startxposA+85,$startypos+10,50,20)
GuiCtrlCreateLabel("Cost Center:",$startxpos+5,$startypos+39,60,20)
$sCostCenter = GUICtrlCreateInput("",$startxposA+85,$startypos+35,50,20)
GuiCtrlCreateLabel("Last Name:",$startxpos+5,$startypos+64,60,20)
$sLastName = GUICtrlCreateInput("",$startxposA+85,$startypos+60,100,20)

$b_FindA = GUICtrlCreateButton("Find",$startxposA+198,$startypos+10,70,20);,$BS_DEFPUSHBUTTON)
$b_FindCCA = GUICtrlCreateButton("Find CC",$startxposA+198,$startypos+35,70,20)
$b_FindLastNameA = GUICtrlCreateButton("Find LName",$startxposA+198,$startypos+60,70,20)
$b_ExitA = GUICtrlCreateButton("Exit",$startxposA+273,$startypos+10,70,20)

$lFirstNameA = GUICtrlCreateLabel("First Name:",$startxposA+5,$startyposA+60,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dFirstNameA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+60,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lLastNameA = GUICtrlCreateLabel("Last Name:",$startxposA+5,$startyposA+85,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dLastNameA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+85,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lSocA = GUICtrlCreateLabel("Last 4 Soc#:",$startxposA+5,$startyposA+110,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dSocA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+110,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lDobA = GUICtrlCreateLabel("DOB:",$startxposA+5,$startyposA+135,70,20)
GUICtrlSetFont (-1,9, 400, 2, $font_bold)
$dDobA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+135,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lDohA = GUICtrlCreateLabel("Last DOH:",$startxposA+5,$startyposA+160,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dDohA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+160,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lDotA = GUICtrlCreateLabel("Last DOT:",$startxposA+5,$startyposA+185,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dDotA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+185,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lCostCA = GUICtrlCreateLabel("Cost Center:",$startxposA+5,$startyposA+210,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dCostCA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+210,100,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lstatusA = GUICtrlCreateLabel("Status:",$startxposA+5,$startyposA+235,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dstatusA = GUICtrlCreateEdit("",$startxposA+85,$startyposA+235,50,20,BitOR($ES_MULTILINE,$ES_READONLY))

$lJobTitleA = GUICtrlCreateLabel("Job Title:",$startxposA+5,$startyposA+260,70,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)
$dJobTitleA = GUICtrlCreateedit("",$startxposA+85,$startyposA+260,100,35,BitOR($ES_MULTILINE,$ES_READONLY));,$ES_READONLY))

GUICtrlCreateLabel("Results",$startxposA+360,$startyposA+45,100,20)
GUICtrlSetFont (-1,9, 400,2, $font_bold)

$ListviewA = GUICtrlCreateListView ("Emp#|Job Title|Last Name   |First Name  |CC  ",$startxposA+198,$startyposA+60,380,253,-1,$iExWindowStyle);$LBS_NOINTEGRALHEIGHT);&$LVS_SORTASCENDING)
_GUICtrlListView_SetExtendedListViewStyle($ListviewA, $iExListViewStyle)

;Added next 3 lines to test if sort works with non-array information. It doesn't!
;GUICtrlCreateListViewItem("ABC|000666|10.05.2004", $ListviewA)
;GUICtrlCreateListViewItem("DEF|444|11.05.2005", $ListviewA)
;GUICtrlCreateListViewItem("CDE|555|12.05.2004", $ListviewA)


GUISetState()
GUICtrlSetState($sFindWhat,$GUI_FOCUS)
GUICtrlSetResizing ($Tab,$GUI_DOCKAUTO)
_GUICtrlStatusBar_Resize($hStatus)

_GUICtrlListView_RegisterSimpleSort($listviewA, False)

While 1
    $msg = GUIGetMsg()
        
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $b_Exit
            Exit
        Case $msg = $b_ExitA
            Exit
        Case $msg = $b_Find
            Clear_Data()
            Find()
            Highlight_Text()
        Case $msg = $b_FindA
            Clear_Data()
            FindA()
            Highlight_TextA()
        Case $msg = $b_FindCCA
            ClearCC()
            CostCenter()
            Highlight_TextCCA()
        Case $msg = $b_FindLastNameA
            ClearCC()
            LastNameCostCenter()
        Case $msg = $m_HelpAbout
            About()
        Case $msg = $m_HelpHelp
            Help()
        Case $msg = $m_Fileopen
            BrowseFile()
        Case $msg = $m_FileExit
            Exit
        Case $msg = $Tab
            If GUICtrlRead($Tab) = 0 Then
                Winmove("Employee Search","","","",$xsizeBasic,$ysizeBasic)
                _GUICtrlStatusBar_Resize($hStatus)
                _GUICtrlStatusBar_SetParts ($hStatus, $aParts)
            ElseIf GuiCtrlRead($Tab) = 1 Then
                Winmove("Employee Search","","","",$xsizeAdvanced,$ysizeAdvanced)
                _GUICtrlStatusBar_Resize($hStatus)
                _GUICtrlStatusBar_SetParts ($hStatus, $aPartsA)
            EndIf
            GUICtrlSetState($sFindWhatA,$GUI_FOCUS)
            GUISetState()
        EndSelect
WEnd
        
_GUICtrlListView_UnRegisterSimpleSort($ListViewA)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

:D big code! Lol...well...Yes...It Works That Way...Thats Why In The Helpfile It Encourages You To Do Things A Specific Way So That It Will Turn Out Correctly, Hope That Helped You!

To Make Your:

Case Messages Easyier...Try Using This:

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
;;;;;;;;;;;;==============;;;;;;;;;;;;;
;;;;Cases Here!!;;;;;
;;;;;;;;;;;;;;===============;;;;;;;;;;;;;
    EndSwitch
WEnd

you dont have to use $msg = for every case...

--Swift :P

Edited by Swift

Share this post


Link to post
Share on other sites

You also could have fixed the menu problem by closing the first tab item before creaing the menu.

$Tab = GUICtrlCreateTab(Width, Height)

$Tab0 = GUICtrlCreateTabItem"Tab 0")

<Tab controls go here>

GUICtrlCreateTabIten("")

Menu here

$Tab1 = GUICtrlCreateTabItem("Tab 1")

<Controls for this tab>

GUICtrlCreateTabItem("")


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

Thanks guys. :D

GeoSoft - Ah Thanks.. Didn't read about closing tabs...

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
Sign in to follow this  
Followers 0