Welcome! Log In Create A New Profile

Advanced

[WD12] How to get EnumControl() to work with a Tab

Posted by Al 
Al
[WD12] How to get EnumControl() to work with a Tab
October 19, 2009 09:11AM
Hello All

I have been battling with the EnumControl() function in relation to returning controls on a tab with no success.

The command line Fld=EnumControl(FormName, LnCtrlCount) where FormName is a parameter with a window name in it works fine for most controls, but will not return controls on a tab in that window. You need to code it specifically for the Tab control on the window and that is where I am stuck.

Fld=EnumControl(MainTab[1],LnCtrlCount) works fine but I can't hard code it every time I need to use the function.

The command line Fld=EnumControl(TabName, LnCtrlCount) where TabName is a parameter with the name of a tab and pane number "MainTab[1]" does not work.

Tabname = "MainTab[1]"
Fld=EnumControl(Tabname ,LnCtrlCount) does not work
Fld=EnumControl({Tabname} ,LnCtrlCount) does not work

I have tried the code locally and as a global proc, with and without the window name as a prefix but just cannot get the syntax to work.

The Windev help states:
Name of the "parent" object (containing the control). This parameter corresponds to the name of a window, looper, looper break, group, tab, supercontrol or report.
If the "parent" object is a tab, the following notation must be used: <Tab Name>[<Pane Number>]. For example: Tab1[2].

Has anyone got a working example of EnumControl() with a Tabname[PaneNo] as an example ?

Regards
Al




Stefan Bentvelsen
Re: [WD12] How to get EnumControl() to work with a Tab
October 19, 2009 09:24AM
Hi Al,

I use the following procedure to change the font of any control (except statics) from bold (is standard in our software) to normal font. It works for any window, including windows with tab-controls, even with memorytables on the tabs. I hope it can help you. We use WD12 on the moment.

PROCEDURE DataToNormalfont()

iHlp	is int=1
iHl2	is int
iNbPane is int
iIdxPane is int
iIdxPan2 is int
iNbPan2	is int
sHlp	is string
sTabc	is string
sTCol	is string

sHlp=EnumControl(MyWindow..Name,iHlp,byZOrder)
WHILE sHlp<>""
	SWITCH {sHlp,indControl}..Type
	CASE typTab
		iNbPane={sHlp,indControl}..Occurrence
		FOR iIdxPane=1 TO iNbPane
			iHl2=1
			sTabc=EnumControl({sHlp,indControl}[iIdxPane],iHl2,byZOrder)
			WHILE sTabc<>""
				IF	{sTabc,indControl}..Type=typTable THEN
					iNbPan2=TableCount({sTabc,indControl},toColumn)
					FOR iIdxPan2=1 TO iNbPan2
						sTCol=TableEnumColumn({sTabc,indControl},iIdxPan2)
						IF	{sTCol,indControl}..Type IN (typComboNE,typComboWE,typDate,typTime,typText,typNum,typList,typCurrency) THEN
							{sTCol,indControl}..FontBold=False
						END
					END
				ELSE
					IF	{sTabc,indControl}..Type IN (typComboNE,typComboWE,typDate,typTime,typTable,typText,typTreeView,typNum,typList,typCurrency,typStatic) THEN
						{sTabc,indControl}..FontBold=False
					END
				END
				iHl2++
				sTabc=EnumControl({sHlp,indControl}[iIdxPane],iHl2,byZOrder)
			END	
		END
	CASE typTable
		iNbPane=TableCount({sHlp,indControl},toColumn)
		FOR iIdxPane=1 TO iNbPane
			sTabc=TableEnumColumn({sHlp,indControl},iIdxPane)
			IF	{sHlp+"."+sTabc,indControl}..Type IN (typComboNE,typComboWE,typDate,typTime,typText,typNum,typList,typCurrency) THEN
				{sHlp+"."+sTabc,indControl}..FontBold=False
			END
		END
	OTHER CASE
		IF	{sHlp,indControl}..Type IN (typComboNE,typComboWE,typDate,typTime,typTable,typText,typTreeView,typNum,typList,typCurrency,typStatic) THEN
			{sHlp,indControl}..FontBold=False
		END
	END
	iHlp++
	sHlp=EnumControl(MyWindow..Name,iHlp,byZOrder)
END
Al
Re: [WD12] How to get EnumControl() to work with a Tab
October 19, 2009 10:20AM
Hello Stefan

Thanks very much for your quick reply.
Your code gave me the answer.

The secret was to split the components of the parameter.
I was sending "MainTab[1]" as the parameter. This was after I had tried a variety of other constructions: {Tabname}+"["+TabQty+"]" was the closest I got to your example.

But now I send the tab name and the number of tab panes separately and code accordingly as per your example.

Fld=EnumControl({LTabName}[LTabQty],LnCtrlCount)

I would never have thought to use the [ ] brackets as is, without wrapping them in quotes as I assumed I had to build a complete string.

As always I lament the poor doco from PCSoft that leads to lost time trying to work out their syntax. Perhaps the next release can have 500 updated Help texts smiling smiley

Thanks again
Regards
Al

Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: