Accueil → WINDEV 22 → enum problems with dynamic Tabs
enum problems with dynamic Tabs
Débuté par Tor-Bjarne, 15 mai 2017 10:49 - 5 réponses
Posté le 15 mai 2017 - 10:49

WinDev 21

I Decided to write my own groupware class as I want full control and have another approach to User and Passwords in my project.

A small example is when starting the application users are auto-logged on as "User" (or whatever) and require a Logon with a user with Admin rights to set attributes of a window and it`s controls.

BUT I have a couple of problems/challenges.:

1. I use a dynamic tab and I cant enum the controls on this TAB easy, the error suggest I use an ALIAS, but if I use a alias i get a error "unknown control".

2. Why is not menus and pop-up menus showing up, when I enum a window for all controls.

Do anybody have code to share for enum a dynamic tab`s controls (as this is the most important task) I`m willing to pay for this as I`m now pretty tired of trying different enum variations (that fail with dynamic tabs)

Posté le 15 mai 2017 - 13:12
Hi Tor,

Why would you want to DIRECTLY enum the controls of a dynamic tab ?
Since dynamic tabs are constructed with Internal Windows, you just need to enum controls of the Internal Windows.

1. Create an associative array (or any array that suits your needs) and in this array keep:
a. the Alias of the created tab pane (returned from TabOpen)
b. the Name of the internal window used in TabOpen

2. Now to control user access in a dynamic tab control, you can use the alias and retrieve the Name of its Internal window.

Steven Sitas
Posté le 15 mai 2017 - 22:52
Hi Steven, thank you for your reply.

Steven Sitas

Why would you want to DIRECTLY enum the controls of a dynamic tab ?

My wet dream is a class I can drop in any project, that activates my groupware without any hassle.

Now if I need to start dealing with what alias is returned from tabopen I need to edit the "Drop-class-to-project" code, if I want to give the class to someone (say this forum) - I need to explain that they need to use my method "this and that" to save the alias for a dynamic tab so my other method which they have to execute/code can enum the internal window.

Actually I`ve solved the enum of dynamic tabs and are now able to enum the controls on a dynamic TAB directly from the class, now I`m struggling hard with reading the dashboard`s that resides on 3 of my dynamic tabs (also containing alias and internal windows).

My idea of this class is to read the controls visible right now, and check if a disabled or invisible state is saved on these controls (only saving disabled controls).

I also made 2 Hot keys (F11 and F12 - that can be changed with a class proerty) defined in the class.

F11 = Logon screen
F12 = User/Groups management and setting the rights of groups for the window being watched/opened in the moment.

User can change level to Admin without having to start/re-start the application just by Pressing F11 and enter his credentials.

that`s why :)

Posté le 17 mai 2017 - 10:39
Hi Tor-Bjarne,

User rights and passwords are a "nightmare" in every Business Application.
Great news, if you have solved it with one class !!!

By the way, PCSofts implementation is way to complicated ....

Steven Sitas
Posté le 18 mai 2017 - 07:14
Hi Tor-Bjarne,

just a hint: look into the enums in PC Soft's Groupware. They enum everything, even components. I don't know about dyn. Tabs but just for fun I'd copy the project as a test project, try to add PC Soft's Groupware and look whether and how they enum them.
Posté le 18 mai 2017 - 20:55

@Steven - Yes,I`ve tried PCSoft`s approach, as an example if a superuser(not me) disallows a window from being opened and a user try to open it the app gives an exception - No luck when trying to catch the exception and continue with only a "Not allowed" message.

I my more simplistic approach a "User" can change to "Admin" for a short while removing or giving access to a control, without re-starting the app.
(also planning a timeout, logon as std user again if nothing happens on the keyboard/mouse for minutes)

@Guenter - Yes i do :) - now I found that it seems in some instances the gpwEnumcontrol do not work:

fld is string =EnumControl(Formname, ncontrolcounter) //fld contains a control dd is string = gpwEnumControl(FormName, nControlCounter) // dd contains ""
But what has tricked me is that the ReadTabs (of a dynamic tab or a dashboard) probably needs to be recursive, as the "TAB 1" can contain a new tab, but I very fast lost track of what level I was in the recursive code.

Then I popped and pushed an integer variable to use in the trace to tell me in what level I was but felt that it was getting to complicated to follow and if I`m to give away the class (if anybody wants it) I made a different approach simulating recursive reads of sub-elements/childs.

An example: (The controls are temp stored in a array of STControl structures)

The code adds controls to the array, and if it hits a container it just set a flag (Container = 1), the code below runs until all containers bContainer_read = True, since it`s a Loop DO While the check on nCounter1 is at the end (runs 1 time minimum)

PROCEDURE PRIVATE GLOBAL ReadContainers() nCounter1 is int LOOP nCounter1 = 0 FOR EACH DS OF ::Controls IF DS.sControlName = "" THEN CONTINUE END IF DS.bIS_container AND DS.bContainer_read = False THEN MyTrace("Reading unhandled container '"+DS.sControlName+"'") nCounter1++ SWITCH DS.nType CASE 9 // Table ::read_table_childs(DS.sControlName) CASE 87 //Ribbon ::Read_Ribbon(DS.sParentName,DS.sControlName) CASE 16 //Tab - dynamic or not ::ReadTabs(DS.sParentName,DS.sParentName+"."+DS.sControlName) CASE 29,40 //Container ::Read_Childs(DS.sParentName,DS.sControlName,DS.nType) CASE 31 //Internal window Read_internal_window(DS.sControlName,True) CASE 111 //DashBoard ReadDASH(DS.sParentName,DS.sControlName) OTHER CASE MyTrace(DS.sControlName,::GetControlType(DS.nType),"is this a container ? (anyway not handled.)") END DS.bContainer_read = True ELSE MyTrace("Skipping: ",DS.sControlName,DS.sCaption) END END DO WHILE nCounter1 > 0
Well still work in progress - I need this for a couple of projects of my own. :-)