Page 1 of 1

PureBasic Gadget Tab Order

Posted: Wed Jun 08, 2022 7:56 pm
by VB6_to_PBx
PureBasic Gadget Tab Order :
Note : i'm using #PB_Any , and it creates random large Gadget numbers
trying just to get each Gadget's Tab Order
should probably be something like simple 1,2,3,4,5,6 .... number sequence ??? i don't really know
any help appreciated !

the Gadget Tab order must be somewhere stored in the created .EXE program
how can i access or get the Gadget's TAB Order ??

i'm trying to access this Tab Order inside my source code
and after i create the .EXE

i can't find any documentation on this ?
or is it not possible to access this Tab Order thru source code

Re: PureBasic Gadget Tab Order

Posted: Wed Jun 08, 2022 8:16 pm
by RASHAD
Hi
You can use SetGadgetData(Gadget,n+1)
Then use GetGadgetData(Gadget) to get the Creation Order

Re: PureBasic Gadget Tab Order

Posted: Wed Jun 08, 2022 9:47 pm
by VB6_to_PBx
RASHAD wrote: Wed Jun 08, 2022 8:16 pm Hi
You can use SetGadgetData(Gadget,n+1)
Then use GetGadgetData(Gadget) to get the Creation Order
thank you RASHAD ,

i had just discovered SetGadgetData and GetGadgetData a few Days ago
but i was getting some weird results :
like if i saved my .pb code without any changes that worked perfect ,
then re-opened it and ran it , it was not working correctly anymore
and Debugger is not catching any errors

if i create an EXE with the code not working perfect,
the EXE always works perfect as expected
... so the EXE always works perfect whether i create the EXE "with or without" the exact same Code working
perfect or not working perfect , the EXE always works correctly, its just in the PureBasic IDE i get weird results

2 more things i've discovered :
1]= if i delete the temporary .EXE made in source directory ... then most times my Code works correctly again in the IDE

2]= if i click on my Code .pb in the File Folder to startup PureBasic (associated File to PureBasic),
... then most times it does not work correctly
if i end the program , and just run it again it works correctly

its like a random error .. but Debugger can't find it
if i turn-off Debugger , i still get the random error/problem

this all started with me converting all my programs StringGadget hard-coded numbers to #PB_Any
with StringGadget hard-coded numbers ... never no problems with all the different PureBasic versions

that's why i asked if there's anyway to get the Tab Order from PureBasic ??
i'd like to make #PB_Any work 100% in every part of my Code

===========================

this is just a modified PureBasic example i did a few Days ago
"SetGadgetData and GetGadgetData" ... gave me much Hope i would be able to use #PB_Any everywhere in my Program

Code: Select all

  Dim Messages.s(2)
  Messages(0) = "Good morning"
  Messages(1) = "Hello World"
  Messages(2) = "Nothing to say"
  If OpenWindow(0, 0, 0, 190, 100, "SetGadgetData", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    B1=ButtonGadget(#PB_Any,  10, 10, 80, 20, "Button 1"): SetGadgetData(B1, 1)
    B2=ButtonGadget(#PB_Any,  10, 40, 80, 20, "Button 2"): SetGadgetData(B2, 2)
    B3=ButtonGadget(#PB_Any,  10, 70, 80, 20, "Button 3"): SetGadgetData(B3, 1)
    B4=ButtonGadget(#PB_Any, 100, 10, 80, 20, "Button 4"): SetGadgetData(B4, 2)
    B5=ButtonGadget(#PB_Any, 100, 40, 80, 20, "Button 5"): SetGadgetData(B5, 0)
    B6=ButtonGadget(#PB_Any, 100, 70, 80, 20, "Button 6"): SetGadgetData(B6, 0)
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Gadget
        Value = GetGadgetData(EventGadget())
        MessageRequester("Message", Messages(Value))
      EndIf
    Until Event = #PB_Event_CloseWindow
  EndIf


Re: PureBasic Gadget Tab Order

Posted: Thu Jun 09, 2022 12:23 am
by kpeters58
Not sure I follow you...

Your sample works just fine in every incantation (initially in IDE, reloaded in IDE, standalone binary ...) just as I expected.

Re: PureBasic Gadget Tab Order

Posted: Thu Jun 09, 2022 5:49 am
by VB6_to_PBx
kpeters58 wrote: Thu Jun 09, 2022 12:23 am Not sure I follow you...

Your sample works just fine in every incantation (initially in IDE, reloaded in IDE, standalone binary ...) just as I expected.
i wish but no , not as expected :(

initially in IDE .... about half the time it does not work correctly , the other half correctly

reloaded in IDE .... same thing : about half the time it does not work correctly , the other half correctly

as an .EXE .... 100% it works correctly, and it does not matter if i created the EXE when it worked incorrectly , or when it worked correctly
only the .EXE comes out perfect everytime OK

it does not matter if its working correctly or incorrectly in the IDE ,
my Program never hangs, its always responding to Inputs or Choices or Button or Menu choice clicks
the Debugger never finds an Error
does not matter if Debugger is On or Off
EnableExplicit is always in beginning of my Code

maybe clearer description :
i'm already in PureBasic IDE , i Open my .pb File ,
i run it , it does not calculate Data ,
because its not getting or seeing GetGadgetData's value correctly ,
and when its seeing not GetGadgetData's value correctly , the StringGadget values are not being updated,
the equation calculations in a Procedure are not correct or accessed,
so i end my program .

so i do absolutely nothing but immediately Run it again , this time everything works correctly or perfectly
and i've made no changes to Code , never Saved it , never quit the IDE ,
all i did was Run it again and it works .... so i end my Program again ,
i immediately Run it again , and sometimes it works correctly , sometimes it does not ... its like a random cycle

one important thing i forgot to mention is :
i can immediatetly tell when my Program is not going to work correctly
when all my User's StringGadget and ComboBoxGadgets values and choices are not selected/highlighted
each in turn as i Tab thru Gadgets

Half of the time this part of my Procedure Code does not work anymore , the other half it works ,
its random chance everytime i restart my .pb file in the IDE

Code: Select all

SendMessage_(GadgetID(EventGadget()),#EM_SETSEL,0,-1)
i've reduced my Code to one quarter of its size
i'm still not able to discover the random error or problem yet in using my Code in the IDE,
i thought i'd tryout redoing one of my small Programs to entirely using #PB_Any + SetGadgetData and GetGadgetData

hopefully someone here can solve it or give more insight ?,
in meantime i'll give it 2 more Days of trying .... if i can't solve it , i'll try again a few Months from now .

the reason i'm trying to make my entire Program's various Gadgets use #PB_Any + SetGadgetData and GetGadgetData
it would surely make a very much larger Commercial Program i'm trying to release in 2 weeks or surely before end of June ,
much easier version to Code with #PB_Any -vs- hard coding StringGadget and ComboBoxGadget numbers .

as of now , hard coding StringGadget and ComboBoxGadget numbers in my Commercial Program
works 100.0% correctly everytime in the IDE or as an EXE , even it latest PureBasic 6.0 Beta 32 and 64 bit versions .

i'd estimate 80+% of my large Commercial Program is using #PB_Any ( without any : SetGadgetData and GetGadgetData )
about 20% is hard coded numbered StringGadgets and ComboBoxGadgets
i'd like it instead to use 100% #PB_Any if possible :D

Re: PureBasic Gadget Tab Order

Posted: Thu Jun 09, 2022 7:53 am
by Marc56us
Hi,

I didn't read all the last post (my English is not very good and I'm not sure about the automatic translator)
VB6_to_PBx wrote: Wed Jun 08, 2022 7:56 pm PureBasic Gadget Tab Order :
Note : i'm using #PB_Any , and it creates random large Gadget numbers
trying just to get each Gadget's Tab Order
should probably be something like simple 1,2,3,4,5,6 .... number sequence ??? i don't really know
any help appreciated !
Two things to check

1. #PB_Any does not create n+1 sequential numbers, just sequential number. If you want to have n + 1 numbers, use Enumeration / EndEnumeration

2. A common error with programs that work in IDE and not in EXE or vice versa is to have put a function that change data after a Debug command. So ignored when compiling and does no generate error.
:wink:

Re: PureBasic Gadget Tab Order

Posted: Thu Jun 09, 2022 10:25 pm
by VB6_to_PBx
Marc56us wrote: Thu Jun 09, 2022 7:53 am Hi,

I didn't read all the last post (my English is not very good and I'm not sure about the automatic translator)
VB6_to_PBx wrote: Wed Jun 08, 2022 7:56 pm PureBasic Gadget Tab Order :
Note : i'm using #PB_Any , and it creates random large Gadget numbers
trying just to get each Gadget's Tab Order
should probably be something like simple 1,2,3,4,5,6 .... number sequence ??? i don't really know
any help appreciated !
Two things to check

1. #PB_Any does not create n+1 sequential numbers, just sequential number. If you want to have n + 1 numbers, use Enumeration / EndEnumeration

2. A common error with programs that work in IDE and not in EXE or vice versa is to have put a function that change data after a Debug command. So ignored when compiling and does no generate error.
:wink:
Marc56us , thanks very much for your suggestions !

i found my stupid ERROR :oops:

Code: Select all

  G6 = StringGadget(#PB_Any,368,68,60,20,"",#PB_Text_Center | #PB_String_ReadOnly)
       SetGadgetColor(G6,#PB_Gadget_FrontColor,RGB(0,0,0))
       SetGadgetColor(G6,#PB_Gadget_BackColor,RGB(255,255,0))
       SetGadgetFont(G6,FontID(#Verdana9b))
       SetGadgetData(G6, 6)
i used the G6 StringGadget to display Calculation Data results
however, i was "polling" that same Gadget in my Input Procedure
and that was causing the weird issues . :oops:

Fix was : remove that one G6 StringGadget out of my Input Procedure
now everything works perfectly .

now i can use #PB_Any + GetGadgetData + SetGadgetData
GetGadgetData + SetGadgetData ... to set and get Gadget's Tab Order
100% thru out my Program and future Softwares :D