Jump to content

Creating and adding tabs to gui?


flxfxp
 Share

Recommended Posts

Hi!

I would like to create a email app designed for my work. It requires techsupport to report any problematic cases that have been handled that day. This is ofcourse variable, some days 20 cases, sometimes 14 for example. I created a form that holds the case number, the way it came in (by phone, internet, email) and a description field.

However, this is just for 1 case. I would like to have tabs on the top of the app so people can add cases (tabs) to how much they need. Those tabs need to have the same look as the initial form (case no., how it came in, etc) so that i can eventually use all the data to send it away using a Outlook.Application object.

For people who don't like to read all: how do i create a "create tab" control and read data from tabs?

Thanks!

Dennis

The Netherlands

Link to comment
Share on other sites

Hey Firefox!

Thanks for your swift reply.

I got the emails handled as a test with:

CreateMailItem()
Func CreateMailItem()
    Local $olMailItem     = 0
    Local $olFormatRichText = 3
    Local $olImportanceLow     = 0
    Local $olImportanceNormal= 1
    Local $olImportanceHigh     = 1

    $oOApp = ObjCreate("Outlook.Application")
    $oOMail = $oOApp.CreateItem($olMailItem)

    With $oOMail
        .To = ("test@example.com")
        .Subject = "email subject"
        .BodyFormat =  $olFormatRichText
        .Importance = $olImportanceHigh
        .Body = "email message"
        .Display
        .Send
    EndWith
EndFunc

However, I want to create tabs in the GUI dynamically, so that the user can click a button (Add Case) so it will create a new tab dynamically and fill it with the fields i previously specified. How do I do that?

Thanks!

Dennis

Link to comment
Share on other sites

I've managed to create tabs in the gui by clicking a button:

GUICtrlCreateTabItem("")
GuiCtrlCreateTab(5,5,50,17)
GUICtrlCreateTabItem("1")
GUISetState(@SW_SHOW)

$CaseID = 1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $NewTabButton
            GuiCtrlCreateTab(5,5,50,17)
            GUICtrlCreateTabItem($CaseID + 1)
            $CaseID = $CaseID + 1
            $CaseNum = GUICtrlCreateInput("blah", 32, 40, 121, 21)
            $CaseDec = GUICtrlCreateEdit("", 32, 104, 465, 217, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
            $CaseFrom = GUICtrlCreateCombo("InfoResponse", 176, 40, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
            GUICtrlSetData(-1, "Premium Case|Phone", "InfoResponse")
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

One question, how can I create a variable that automatically increments. What i want to do:

Pressing a button creates a tab with a text that automatically increments (1,2,3,4,5,etc)

By pressing that button it will also create the controls for in that tab, but with a unique name ($CaseNum1, $CaseNum2, $CaseNum3, etc)

How do i create a variable name that increments? ($CaseNum1, $CaseNum2, $CaseNum3, etc)

Thanks!

Dennis

Link to comment
Share on other sites

@flxfxp

Use Case in While or use OnEvent mode :)

#include <GuiConstants.au3>
Opt("GuiOnEventMode",1);Activate OnEventMode

$GUI=GUICreate("GUI",230,25,-1,-1);Create simple gui
GUISetOnEvent($GUI_EVENT_CLOSE,"_Exit");When user close window then exit script
$TAB=GUICtrlCreateTab(2,2,150,20)
GUICtrlCreateButton("Add Tab",170,2,50,20)
GUICtrlSetOnEvent(-1,"_AddTab");Set button onevent to _AddTab function
GUISetState(@SW_SHOW,$GUI);Show gui

$NB=1;Tab create number = 1

Func _AddTab()
If $NB=4 Then;Check if $NB=4
GUICtrlDelete($TAB);Delete tab
$TAB=GUICtrlCreateTab(2,2,150,20)
$NB=1
EndIf

If $NB=3 Then;Check if $NB=3
GUICtrlCreateTabItem("Tab 3")
$NB=4
EndIf

If $NB=2 Then;Check if $NB=2
GUICtrlCreateTabItem("Tab 2")
$NB=3;update $NB number to 3
EndIf

If $NB=1 Then;Check if $NB=1
GUICtrlCreateTabItem("Tab 1")
$NB=2;update $NB number to 2
EndIf
EndFunc

Func _Exit()
Exit
EndFunc

While 1
    Sleep(250)
WEnd
Link to comment
Share on other sites

Thanks for the help Firefox, I just got it fixed myself :)

However, I do need help on incrementing variable names and reading them all from all tabs tho.

Do you know how to do this?

My current script:

#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 528, 351, 193, 125)
$NewTabButton = GUICtrlCreateButton("+", 475, 10, 50, 20)
$SendButton = GUICtrlCreateButton("SND", 425, 10, 50, 20)
$Tab1 = GUICtrlCreateTab(16, 16, 497, 321)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
GUICtrlCreateTabItem("")
GuiCtrlCreateTab(5,5,50,17)
GUICtrlCreateTabItem("1")
$CaseNum = GUICtrlCreateInput("blah", 32, 40, 121, 21)
$CaseDec = GUICtrlCreateEdit("", 32, 104, 465, 217, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
$CaseFrom = GUICtrlCreateCombo("InfoResponse", 176, 40, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Premium Case|Phone", "InfoResponse")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$CaseID = 1

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $NewTabButton
            GuiCtrlCreateTab(5,5,50,17)
            GUICtrlCreateTabItem($CaseID + 1)
            $CaseNum = GUICtrlCreateInput($CaseID + 1, 32, 40, 121, 21)
            $CaseDec = GUICtrlCreateEdit("", 32, 104, 465, 217, BitOR($ES_AUTOVSCROLL,$ES_AUTOHSCROLL,$ES_WANTRETURN))
            $CaseFrom = GUICtrlCreateCombo("InfoResponse", 176, 40, 145, 25, BitOR($CBS_DROPDOWNLIST,$CBS_AUTOHSCROLL))
            GUICtrlSetData(-1, "Premium Case|Phone", "InfoResponse")
            $CaseID = $CaseID + 1
        Case $SendButton
            $ReadCaseNum = GUICtrlRead($CaseNum)
            MsgBox(0, "test", $ReadCaseNum )
            $ReadCaseFrom = GUICtrlRead($CaseFrom)
            MsgBox(0, "test", $ReadCaseFrom)
            $ReadCaseDec = GUICtrlRead($CaseDec)
            MsgBox(0, "test", $ReadCaseDec)
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Link to comment
Share on other sites

exactly, thats what i need to fix

i need it to give the variables unique names for each control item in each tab.

In the end i can use a loop to retrieve all info from all tabs

The only question is: how do i auto increment the control item variable names? ($CaseNum, $CaseDec, $CaseFrom)

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