Jump to content

Controlling data input with tabs


Recommended Posts

I have this form that after you fill the form you can submit or create a new tab which is a clean copy of the form and you can keep adding tabs until you finally submit. This works fine.

After each input field is inputed (I use Barcoded data) it does whatever it needs to do and moves to the next input field.

I use

ControlFocus("Inventory", "", $nMsg + 1)

$cursor = ControlGetFocus("Inventory")

to move.

Well if I start the first tab, Create a second tab it works on both tabs, but if I go back to the first tab to Scan more data. The input never quite finishes. If I hit enter or tab everthing works, but for some reason it doesn't work on earlier tabs. If I go back to Tab 2 then everything works on that tab. If I create a Third tab then things only work right on tab 3.

I'm very confused.

Link to comment
Share on other sites

If you dynamically create controls on tabs, don't forget what's written in the help-file:

1. GUISwitch($hWin,$tabitem)

2. GUICtrlCreateInput()

3. GUICtrlCreateTabItem("")

If this doesn't solve you problem... post example code :P...

Edited by KaFu
Link to comment
Share on other sites

If you dynamically create controls on tabs, don't forget what's written in the help-file:

1. GUISwitch($hWin,$tabitem)

2. GUICtrlCreateInput()

3. GUICtrlCreateTabItem("")

If this doesn't solve you problem... post example code :P...

Before I stripout the code that doesn't work right. Since it is 1500 lines of code with most of it not related.

I don't believe I'm Dynamically Creating Controls on Tabs, But I could be wrong

My Flowchart is:

Createtab

Setup Screen

Loop testing input

if Next page then Createtab (which would setup screen)

Here is a taste of the code... I believe I took the important stuff nothing else should matter.

$Form1 = GUICreate("Inventory", $Pos2, $pos3, -1, -1)

GUISetBkColor(0xFFFFFF)

GUICtrlCreateLabel("Inventory Tracking Cover sheet", 176 + $xx, 0, 252, 20)

GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")

#Region ### START Koda GUI section ### Form=

$tab[0] = GUICtrlCreateTab(5, 20, $Pos2 - 5, $pos3 - 10)

GUICtrlCreateTabItem("Sheet 1")

....

setupscreen(1) ; setup first Screen

....

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

_WinAPI_EnableWindow($Form1, True)

$Ntabs = _GUICtrlTab_GetItemCount($tab[0])

$x = _GUICtrlTab_GetCurSel($tab[0]) + 1

;consolewrite($x&@lf)

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $B1[$x]

$ok = readtab($x)

Exit

Case $b2[$x]

$ok = readtab($x)

If $ok Then createtab()

Case $input[$x][37], $input[$x][39]

$temp = StringStripWS(GUICtrlRead($nMsg), 8)

$temp = StringReplace($temp, "*", "", 2)

GUICtrlSetData($nMsg, $temp)

ControlFocus("Inventory", "", $nMsg + 1)

$cursor = ControlGetFocus("Inventory")

....

EndSwitch

WEnd

Func createtab()

$x = _GUICtrlTab_GetItemCount($tab[0])

_ArrayAdd($tab, GUICtrlCreateTabItem("Sheet " & $x + 1))

ReDim $input[$x + 1 + 1][60], $radio[$x + 1 + 1][13], $ntype[$x + 1 + 1][10], $info[$x + 1 + 1][60], $dropbox[$x + 1 + 1][2]

_ArrayAdd($B1, "")

_ArrayAdd($b2, "")

setupscreen($x + 1)

EndFunc ;==>createtab

SetupScreen($t)

.....

$B1[$t] = GUICtrlCreateButton("Submit", 150 + $xx, 665, 50, 24)

$b2[$t] = GUICtrlCreateButton("Next Sheet", 348 + $xx, 665, 100, 24)

$labcnt = 8

For $Lloop = 1 To 7

$labcnt = $labcnt + 2

$input[$t][$labcnt] = GUICtrlCreateInput("", 72 + $xx, $labloc[$Lloop], 41, 21);Colunm1

$input[$t][$labcnt + 27] = GUICtrlCreateInput("", 190 + $xx, $labloc[$Lloop], 100, 21);Colunm2

$input[$t][$labcnt + 28] = GUICtrlCreateInput("", 340 + $xx, $labloc[$Lloop], 100, 21);Colunm3

$input[$t][$labcnt + 1] = GUICtrlCreateInput("", 496 + $xx, $labloc[$Lloop], 97, 21);Column 4

Next

GUICtrlCreateTabItem("")

EndFunc ;==>setupscreen

Link to comment
Share on other sites

Before I stripout the code that doesn't work right. Since it is 1500 lines of code with most of it not related.

I don't believe I'm Dynamically Creating Controls on Tabs, But I could be wrong

My Flowchart is:

Createtab

Setup Screen

Loop testing input

if Next page then Createtab (which would setup screen)

Here is a taste of the code... I believe I took the important stuff nothing else should matter.

$Form1 = GUICreate("Inventory", $Pos2, $pos3, -1, -1)

GUISetBkColor(0xFFFFFF)

GUICtrlCreateLabel("Inventory Tracking Cover sheet", 176 + $xx, 0, 252, 20)

GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")

#Region ### START Koda GUI section ### Form=

$tab[0] = GUICtrlCreateTab(5, 20, $Pos2 - 5, $pos3 - 10)

GUICtrlCreateTabItem("Sheet 1")

....

setupscreen(1) ; setup first Screen

....

GUISetState(@SW_SHOW)

#EndRegion ### END Koda GUI section ###

While 1

_WinAPI_EnableWindow($Form1, True)

$Ntabs = _GUICtrlTab_GetItemCount($tab[0])

$x = _GUICtrlTab_GetCurSel($tab[0]) + 1

;consolewrite($x&@lf)

$nMsg = GUIGetMsg()

Switch $nMsg

Case $GUI_EVENT_CLOSE

Exit

Case $B1[$x]

$ok = readtab($x)

Exit

Case $b2[$x]

$ok = readtab($x)

If $ok Then createtab()

Case $input[$x][37], $input[$x][39]

$temp = StringStripWS(GUICtrlRead($nMsg), 8)

$temp = StringReplace($temp, "*", "", 2)

GUICtrlSetData($nMsg, $temp)

ControlFocus("Inventory", "", $nMsg + 1)

$cursor = ControlGetFocus("Inventory")

....

EndSwitch

WEnd

Func createtab()

$x = _GUICtrlTab_GetItemCount($tab[0])

_ArrayAdd($tab, GUICtrlCreateTabItem("Sheet " & $x + 1))

ReDim $input[$x + 1 + 1][60], $radio[$x + 1 + 1][13], $ntype[$x + 1 + 1][10], $info[$x + 1 + 1][60], $dropbox[$x + 1 + 1][2]

_ArrayAdd($B1, "")

_ArrayAdd($b2, "")

setupscreen($x + 1)

EndFunc ;==>createtab

SetupScreen($t)

.....

$B1[$t] = GUICtrlCreateButton("Submit", 150 + $xx, 665, 50, 24)

$b2[$t] = GUICtrlCreateButton("Next Sheet", 348 + $xx, 665, 100, 24)

$labcnt = 8

For $Lloop = 1 To 7

$labcnt = $labcnt + 2

$input[$t][$labcnt] = GUICtrlCreateInput("", 72 + $xx, $labloc[$Lloop], 41, 21);Colunm1

$input[$t][$labcnt + 27] = GUICtrlCreateInput("", 190 + $xx, $labloc[$Lloop], 100, 21);Colunm2

$input[$t][$labcnt + 28] = GUICtrlCreateInput("", 340 + $xx, $labloc[$Lloop], 100, 21);Colunm3

$input[$t][$labcnt + 1] = GUICtrlCreateInput("", 496 + $xx, $labloc[$Lloop], 97, 21);Column 4

Next

GUICtrlCreateTabItem("")

EndFunc ;==>setupscreen

In the Loop I tried to see _WinAPI_GetFocus() to see if something was wacky, when I leave one tab for the other, Nothing. the windows handles are fine, What is Weird is that the Scanner ends with a CR but when I write to a previous tab, the CR seems to be ignored. I have to use my keyboard for the return, but it works on the Last tab correctly.

Link to comment
Share on other sites

Maybe this will do:

GUISwitch($Form1,$t)
$B1[$t] = GUICtrlCreateButton("Submit", 150 + $xx, 665, 50, 24)
$b2[$t] = GUICtrlCreateButton("Next Sheet", 348 + $xx, 665, 100, 24)

otherwise you'll have to provide a piece of code which can be run (pm if you want).

Link to comment
Share on other sites

Maybe this will do:

GUISwitch($Form1,$t)
$B1[$t] = GUICtrlCreateButton("Submit", 150 + $xx, 665, 50, 24)
$b2[$t] = GUICtrlCreateButton("Next Sheet", 348 + $xx, 665, 100, 24)

otherwise you'll have to provide a piece of code which can be run (pm if you want).

Well can I Swear &^%$#, I took the code that I posted and filled it in so it would work. Taking code straight from the original. Tested it out to see if I had everything....and it Worked just like it supposed to.

So Now I have to find a needle in a haystack.

Thanks.

PS. Test code that works:

help.au3

Link to comment
Share on other sites

Well... you'll have to provide code that is not working as intended :unsure:... pm me if you don't find the needle :P, I myself for sure don't have a need to deploy any inventory programs :D, will delete it after testing...

Link to comment
Share on other sites

Well... you'll have to provide code that is not working as intended :unsure:... pm me if you don't find the needle :P, I myself for sure don't have a need to deploy any inventory programs :D, will delete it after testing...

What I am finding is that the "ENTER" key is not functioning on previous tabs on the big program. I do not use Hotkeys, and I even tried to use Hotkeyset("{enter}") to reset it and it didn't work. Any Other suggestions on how the CR is being disabled and how to force it.

If I send you the Code, Well you will need a lot of cleaning up just to run it. It's tied to MSSQL with ini file and registry settings. So there will be a lot of remming out code. but I've tried remming out all the cases except the 2 cases like the help.au3 in the loop, but I find the same issue.

I remmed out all code that won't run without the said envirornment. And this code doesn't work.

The test that is repeatable is:

Put anything into Asset # column hit [Enter] (should reply back with Works)

Select [Next Sheet]

optional ( Put Anything into Asset # column and hit [Enter] - show it works there )

Goto TAB 1

Put anything into Asset # column hit [Enter] ([Enter] will not work- Tab does though)

Go Back to Tab 2

Put anything into Asset # column hit [Enter] (should reply back with Works)

Have fun :

itcs_v2.tst.au3

Link to comment
Share on other sites

What I am finding is that the "ENTER" key is not functioning on previous tabs on the big program. I do not use Hotkeys, and I even tried to use Hotkeyset("{enter}") to reset it and it didn't work. Any Other suggestions on how the CR is being disabled and how to force it.

If I send you the Code, Well you will need a lot of cleaning up just to run it. It's tied to MSSQL with ini file and registry settings. So there will be a lot of remming out code. but I've tried remming out all the cases except the 2 cases like the help.au3 in the loop, but I find the same issue.

I remmed out all code that won't run without the said envirornment. And this code doesn't work.

The test that is repeatable is:

Put anything into Asset # column hit [Enter] (should reply back with Works)

Select [Next Sheet]

optional ( Put Anything into Asset # column and hit [Enter] - show it works there )

Goto TAB 1

Put anything into Asset # column hit [Enter] ([Enter] will not work- Tab does though)

Go Back to Tab 2

Put anything into Asset # column hit [Enter] (should reply back with Works)

Have fun :

Never Mind - I solved it. Not sure why, but I created a dummy hidden button on each tab but called ot the same, if I rem out that Dummy Button it all works.

;$button0 = GUICtrlCreateButton("dummy", 248 + $xx, 655, 100, 24)

;GUICtrlSetState(-1, $GUI_DEFBUTTON + $gui_hide)

I tried to create the button the same way as the other 2 buttons, but it does the same thing.

$b3[$t] = GUICtrlCreateButton("dummy", 248 + $xx, 655, 100, 24)

GUICtrlSetState(-1, $GUI_DEFBUTTON + $gui_hide)

If I set GUICtrlSetState($b3[$x], $GUI_DEFBUTTON) after I get currrent Tab it works.

While 1

$Ntabs = _GUICtrlTab_GetItemCount($tab[0])

$x = _GUICtrlTab_GetCurSel($tab[0]) + 1

GUICtrlSetState($b3[$x], $GUI_DEFBUTTON)

$nMsg = GUIGetMsg(1)

Thanks

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