For Programmers: Free Programming Magazines  


Home > Archive > Clarion > July 2006 > determine field equate number or label of CREATEd control









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author determine field equate number or label of CREATEd control
DanW

2006-07-08, 6:55 pm


I am trying to change the font color of a (variable) string at runtime.
the problem is that since the control was CREATEd along with hundreds
of other controls after the window was opened, i don't know what the
field equate number or label of the control. therefore i can't
reference it to change the font when its value changes later in the
program.

i thought prop:feq would work but it only seems to return a number when
you already know the label.

any help would be greatly appreciated!

Olivier Cretey

2006-07-08, 6:55 pm

Dan,

Look at the Create() function...

!Data
?MyControl Signed

!Code
?MyControl = Create(0,Create:String)
?MyControl{Prop:FontColor}=Color:Red
?MyControl{Prop:text}='Hello World!'
UnHide(?MyControl)

Regards

--
Olivier Cretey
o.cretey@cia-informatique.com
www.cia-informatique.com
Verneuil sur Seine (78), France


DanW

2006-07-08, 6:55 pm

Olivier, I am not having trouble creating the controls, I am having
trouble referencing them after they are created. I create several
hundred controls at runtime, but i need to change the font of some of
them later, based on certain conditions. Thanks!


Olivier Cretey wrote:
> Dan,
>
> Look at the Create() function...
>
> !Data
> ?MyControl Signed
>
> !Code
> ?MyControl = Create(0,Create:String)
> ?MyControl{Prop:FontColor}=Color:Red
> ?MyControl{Prop:text}='Hello World!'
> UnHide(?MyControl)
>
> Regards
>
> --
> Olivier Cretey
> o.cretey@cia-informatique.com
> www.cia-informatique.com
> Verneuil sur Seine (78), France


Olivier Cretey

2006-07-08, 6:55 pm

Dan,

> I am having trouble referencing them after they are created.


I do not understand why, the code I gave you does exactly this...

Assuming you've declared ?MyControl as a Signed in your data section,

?MyControl = Create(0,Create:String)

Create(0,Create:xxxxx) returns the feq in ?MyControl so we can use
?MyControl to change the properties, for example:

?MyControl{Prop:FontColor}=Color:Red

changes the font color of the newly created control (?MyControl)

If I was dealing with many controls, I would use a queue...
Something like this:

Program
Map
End

CtrlQ Queue
Feq Long
Type Long
xPos Long
yPos Long
Width Long
Height Long
FldVal String(255)
End

Window WINDOW('Caption'),AT(,,395,224),FONT('MS
Sans
Serif',8,,FONT:regular),GRAY
BUTTON('&Close'),AT(345,201,42,14),USE(?ButtonClose),LEFT
END

Code
Open(Window)

Clear(CtrlQ)
CtrlQ.Feq = LastField() + 1
CtrlQ.Type = Create:String
CtrlQ.xPos = 10
CtrlQ.yPos = 10
CtrlQ.Width = 100
CtrlQ.Height = 10
CtrlQ.FldVal = 'String 1'
Add(CtrlQ)

CtrlQ.Feq = LastField() + 2
CtrlQ.Type = Create:String
CtrlQ.xPos = 10
CtrlQ.yPos = 20
CtrlQ.Width = 100
CtrlQ.Height = 10
CtrlQ.FldVal = '100'
Add(CtrlQ)

Loop i# = 1 To Records(CtrlQ)
Get(CtrlQ,i#)
If Create(CtrlQ.Feq,CtrlQ.Type)
CtrlQ.Feq{Prop:xPos} = CtrlQ.xPos
CtrlQ.Feq{Prop:yPos} = CtrlQ.yPos
CtrlQ.Feq{Prop:Width} = CtrlQ.Width
CtrlQ.Feq{Prop:Height} = CtrlQ.Height
CtrlQ.Feq{Prop:Text} = CtrlQ.FldVal
UnHide(CtrlQ.Feq)
End
End

Accept
if Accepted() = ?ButtonClose
Post(Event:CloseWindow)
End
End

Close(Window)
Free(CtrlQ)

Of course this is a dumb example, but you've got the idea...

Regards

--
Olivier Cretey
o.cretey@cia-informatique.com
www.cia-informatique.com
Verneuil sur Seine (78), France


DanW

2006-07-08, 6:55 pm

Olivier,

Unfortunately the first idea will not work since I am not assigning the
font color at the time the control is created, but later in the program
based on user input. So yes, at the time i create the control I can
(and do) set many of it's properties, including position, font,
picture, etc. I do this for about 600 controls on the screen. But
then later I have to come back and change the font color of any of
these 600 controls based on user input. It's the "later" that is the
problem because now there seems to be no way to find out what field
equate number was assigned to a particular control.

The queue idea might work, it would be a very large queue though and i
am trying to find another way around it. I am starting to think that
there may be no other choice though.

Thanks again for taking the time to respond, it is greatly appreciated.

Dan



Olivier Cretey wrote:
> Dan,
>
>
> I do not understand why, the code I gave you does exactly this...
>
> Assuming you've declared ?MyControl as a Signed in your data section,
>
> ?MyControl = Create(0,Create:String)
>
> Create(0,Create:xxxxx) returns the feq in ?MyControl so we can use
> ?MyControl to change the properties, for example:
>
> ?MyControl{Prop:FontColor}=Color:Red
>
> changes the font color of the newly created control (?MyControl)
>
> If I was dealing with many controls, I would use a queue...
> Something like this:
>
> Program
> Map
> End
>
> CtrlQ Queue
> Feq Long
> Type Long
> xPos Long
> yPos Long
> Width Long
> Height Long
> FldVal String(255)
> End
>
> Window WINDOW('Caption'),AT(,,395,224),FONT('MS
Sans
> Serif',8,,FONT:regular),GRAY
> BUTTON('&Close'),AT(345,201,42,14),USE(?ButtonClose),LEFT
> END
>
> Code
> Open(Window)
>
> Clear(CtrlQ)
> CtrlQ.Feq = LastField() + 1
> CtrlQ.Type = Create:String
> CtrlQ.xPos = 10
> CtrlQ.yPos = 10
> CtrlQ.Width = 100
> CtrlQ.Height = 10
> CtrlQ.FldVal = 'String 1'
> Add(CtrlQ)
>
> CtrlQ.Feq = LastField() + 2
> CtrlQ.Type = Create:String
> CtrlQ.xPos = 10
> CtrlQ.yPos = 20
> CtrlQ.Width = 100
> CtrlQ.Height = 10
> CtrlQ.FldVal = '100'
> Add(CtrlQ)
>
> Loop i# = 1 To Records(CtrlQ)
> Get(CtrlQ,i#)
> If Create(CtrlQ.Feq,CtrlQ.Type)
> CtrlQ.Feq{Prop:xPos} = CtrlQ.xPos
> CtrlQ.Feq{Prop:yPos} = CtrlQ.yPos
> CtrlQ.Feq{Prop:Width} = CtrlQ.Width
> CtrlQ.Feq{Prop:Height} = CtrlQ.Height
> CtrlQ.Feq{Prop:Text} = CtrlQ.FldVal
> UnHide(CtrlQ.Feq)
> End
> End
>
> Accept
> if Accepted() = ?ButtonClose
> Post(Event:CloseWindow)
> End
> End
>
> Close(Window)
> Free(CtrlQ)
>
> Of course this is a dumb example, but you've got the idea...
>
> Regards
>
> --
> Olivier Cretey
> o.cretey@cia-informatique.com
> www.cia-informatique.com
> Verneuil sur Seine (78), France


DanW

2006-07-08, 6:55 pm

Maybe it would help if I post the code I am using to create the
controls. It is a simple loop and code4entry is the variable that
holds (temporarily) the equate of the control being created at that
moment. The code works beautifully, it populates the screen very
nicely and displays all the correct values. There are about 20 of
these loops but they are all similiar

loop i#= 1 to 16 !upper xmobility
code4entry=lastfield()+1
create(code4entry,create:sstring);
code4entry{PROP:use} = loc:xmobility[i#];
code4entry{prop:trn}=1
code4entry{prop:text}='@n1B'
loc:xmobility[i#]=PER:Mobility[i#]
setposition(code4entry,(i#-1)*26+44,20,21,7)
unhide(code4entry)
Olivier Cretey

2006-07-09, 7:55 am

Dan,

I still don't understand why you don't want to keep the feq assignment.
Please look at the sample below...

Program
Map
End

W WINDOW('Dummy'),AT(,,500,84),FONT('MS Sans
Serif',,,,CHARSET:ANSI),GRAY
BUTTON('OK'),AT(450,65,45,14),USE(?ButtonOK)
END

Loc:xmobility String(255),Dim(16)
PER:Mobility String(255),Dim(16)

Code4Entry Signed,Dim(16)

i Long

Code
loop i= 1 to 16
Per:Mobility[i] = i
End

Open(w)

loop i= 1 to 16 !upper xmobility
code4entry[i] = create(0,create:sstring)
code4entry[i]{prop:use} = loc:xmobility[i]
code4entry[i]{prop:trn}=1
code4entry[i]{prop:text}='@n2'
loc:xmobility[i]=PER:Mobility[i]
setposition(code4entry[i],(i-1)*26+44,20,21,7)
unhide(code4entry[i])
end

Accept
if Accepted() = ?ButtonOk
loop i = 1 to 16
if loc:xmobility[i] % 2 = 0
code4entry[i]{prop:fontcolor}=color:red
end
end
end
End

Close(W)


Regards

--
Olivier Cretey
o.cretey@cia-informatique.com
www.cia-informatique.com
Verneuil sur Seine (78), France


Olivier Cretey

2006-07-09, 7:55 am

Dan,

Of course you could use something like:
Feq:xmobility Signed,Dim(16)
instead of
code4entry Signed,Dim(16)
to store the feq of the newly created control for more readibility...

so you could write
if loc:xmobility[i] = 'something'
feq:xmobility[i]{prop:fontcolor}=color:w
hatever
end

regards

--
Olivier Cretey
o.cretey@cia-informatique.com
www.cia-informatique.com
Verneuil sur Seine (78), France


sandinzz@yahoo.com

2006-07-10, 7:55 am

Hi.
I had similar problem. I had to change some control's properties based
on position of the mouse and position of controls on the window.
Besides user's input what is your basic criteria for changeing
control's properties??? Sandin

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com