Lookup Command Button-Anchor-Properly resize

The place where ProMatrix users can post coding tips and utilities they create.

Lookup Command Button-Anchor-Properly resize

Postby JessicaLawson » Sun Jun 13, 2010 4:14 pm

For those that haven't already made this change.

Often, when creating "re-sizeable" forms, and using the new VFP 9 "Anchor"
properties - you find that your lookup command buttons are not "Anchoring"
where the "vpmctrls.vcx" "textbox_" ( or someother objects) have resized and
anchored...

There are a number of ways to do this, from the "ProCtrls" or the "DevCtrls"
class libraries, but to keep this simple I will reference the code in
"VPMCtrls.vcx". One could then move over to one of the other subclassed
class libraries very easy.

1. Open VPMCtrls.vcx and open the object called "textbox_".

2. Examine the Init() event of the "textbox_"

3. Search for the following code, about 3/4 ways down in Init code:

* Change the properties of the new lookup CommandButton.
This.Parent.&slcCmdName..TabStop = .F.
This.Parent.&slcCmdName..TabIndex = This.TabIndex
This.Parent.&slcCmdName..cName_DDD = This.cName_DDD
This.Parent.&slcCmdName..cName_DDTV = This.cName_DDTV
This.Parent.&slcCmdName..cName_DDF = This.cName_DDF
This.Parent.&slcCmdName..lLookupCommandButton = .T.
This.Parent.&slcCmdName..cLookupFor = This.Name
This.Parent.&slcCmdName..Height = 20
This.Parent.&slcCmdName..Width = 17
This.Parent.&slcCmdName..Left = This.Left+This.Width+2
This.Parent.&slcCmdName..Top = This.Top+INT((This.Height-20)/2)


4. Add the following line (you will probably do this in "ProCtrls" or
"DevCtrls").

This.Parent.&slcCmdName..Anchor = This.Anchor


That's it - now, when you resize your form, and you have indicated that you
want a lookup command button to show up, it will resize the same as the
object it is tied to. You can repeat this for any other object that has the
ability in VPME to dynamically add a "Lookup Command Button".

( easier to do this at object creation - then to dynamically search for the
object and alter it at runtime for each and every case... ).

Regards,


John C. Gunvaldson
www.fox-net.com
http://foxnetwest.spaces.live.com/
San Diego, CA
JessicaLawson
 
Posts: 79
Joined: Sun Jun 13, 2010 1:23 pm

Re: Lookup Command Button-Anchor-Properly resize

Postby JessicaLawson » Sun Jun 13, 2010 4:15 pm

Hi John,

This is an interesting solution, but I'm thinking, it may not be exactly what
I want. Say, if I set my textbox anchor to be 10 (resize horisontally), then I
only want the button to follow along, but not become too wide/narrow.

Perhaps the solution would be to set top/left properties of the button in the
textbox resize method?

Currently I was using the technique suggested by Richard, but I just changed
the name of the textbox and now my form broke - I don't know what the name
should be, so I would prefer to set this at the class level instead.

The other thing I would probably change - why do we need all these macros
accessing this button? There are lots of other ways to do this instead.

Just wondering if it's OK to fix the framework code directly?

Thanks again.
JessicaLawson
 
Posts: 79
Joined: Sun Jun 13, 2010 1:23 pm

Re: Lookup Command Button-Anchor-Properly resize

Postby JessicaLawson » Sun Jun 13, 2010 4:15 pm

Well, the problem is - the textbox doesn't have a resize method :)

So, now it's an interesting question - how should we move the button ?
JessicaLawson
 
Posts: 79
Joined: Sun Jun 13, 2010 1:23 pm

Re: Lookup Command Button-Anchor-Properly resize

Postby JessicaLawson » Sun Jun 13, 2010 4:16 pm

Here is the code I put:

* Determine the name of the new lookup CommandButton.
slcCmdName = Alltrim(This.Name)
If Upper(Left(slcCmdName,3)) = 'TXT'
slcCmdName = 'cmdLookup'+Substr(slcCmdName,4)
Else
slcCmdName = 'cmdLookup'+slcCmdName
Endif
* Create the new lookup CommandButton.
This.Parent.AddObject(slcCmdName,slcControlsClassLibrary +'.commandbutton_')
* Change the properties of the new lookup CommandButton.

With Evaluate('this.Parent.' + slcCmdName)
.TabStop = .F.
.TabIndex = This.TabIndex
.cName_DDD = This.cName_DDD
.cName_DDTV = This.cName_DDTV
.cName_DDF = This.cName_DDF
.lLookupCommandButton = .T.
.cLookupFor = This.Name
.Height = 20
.Width = 17
.Left = This.Left+This.Width+6
.Top = This.Top+Int((This.Height-20)/2)

IF this.Anchor <> 0
.Anchor = 8 &&16 + 128 + 256 + 512 - move to the right
ENDIF


If Not This.lEnableDisableControl
.lEnableDisableControl = .F.
Endif
If Empty(This.cLookupPicture)
If File('LOOKUP.BMP')
.Caption = ''
.Picture = 'LOOKUP.BMP'
Else
.Caption = '...'
Endif
Else
slcLookupPic = Defaultext(Alltrim(This.cLookupPicture),'BMP')
.Caption = ''
.Picture = slcLookupPic
Endif
If This.lAddLookupOnFocus Or Not sllVisible
.Visible = .F.
Else
.Visible = .T.
Endif
Endwith

Works great.

Except that now I'm back to the original problem - the Picklist doesn't want
to show up!!!!! I re-did my control using CA added to DE and I used VPM
builder to build this textbox - what may be the problem now?

from nnosonovsky@iotechno.com
JessicaLawson
 
Posts: 79
Joined: Sun Jun 13, 2010 1:23 pm

Re: Lookup Command Button-Anchor-Properly resize

Postby JessicaLawson » Sun Jun 13, 2010 4:16 pm

Hi,

I understand the issue that you represent with concern about allowing
<stretch> attributes to the anchor property. I rarely like to code an
interface where the data entry textbox is allowed to stretch across the
form, but I see your point...

I would probably handle this with a case statement of some sort, for
instance (psuedo code)...

do case
case This.Anchor = <one where textbox has stretch attribute>
This.Parent.&slcCmdName..Anchor = <one with same
direction, but not stretch>
...
...
otherwise
This.Parent.&slcCmdName..Anchor = This.Anchor
endcase


> Except that now I'm back to the original problem - the Picklist doesn't
> want
> to show up!!!!! I re-did my control using CA added to DE and I used VPM
> builder to build this textbox - what may be the problem now?

The logic to display a picklist requires a lot of conditional code to
execute, all dependant on the correct class libraries being used, (testbox,
listbox, other...)...

Are you sure you have examined your subclasses, and parent classes?

John
JessicaLawson
 
Posts: 79
Joined: Sun Jun 13, 2010 1:23 pm

Re: Lookup Command Button-Anchor-Properly resize

Postby JessicaLawson » Sun Jun 13, 2010 4:17 pm

Hi John,

"John C. Gunvaldson" <fox-net@cox.net> wrote in message
news:2bc94fe5$72c29e80$9ef@emach1...
>Hi,
>
>I understand the issue that you represent with concern about allowing
><stretch> attributes to the anchor property. I rarely like to code an
>interface where the data entry textbox is allowed to stretch across the
>form, but I see your point...
>
>I would probably handle this with a case statement of some sort, for
>instance (psuedo code)...
>
>do case
> case This.Anchor = <one where textbox has stretch attribute>
> This.Parent.&slcCmdName..Anchor = <one with same
>direction, but not stretch>
> ...
> ...
> otherwise
> This.Parent.&slcCmdName..Anchor = This.Anchor
>endcase
>
>

I agree, though in my case I just set it to 10 (perhaps I should have done it
conditionally).

>> Except that now I'm back to the original problem - the Picklist doesn't
>> want
>> to show up!!!!! I re-did my control using CA added to DE and I used VPM
>> builder to build this textbox - what may be the problem now?
>
>The logic to display a picklist requires a lot of conditional code to
>execute, all dependant on the correct class libraries being used, (testbox,
>listbox, other...)...
>
>Are you sure you have examined your subclasses, and parent classes?
>
>John

I guess I did something wrong, but since I was unable to make it work using
CA, I switched to a view, which worked.

My question now is - how do you distribute structural updates to the client?

Should I generate a program for the view and send it as a part of main program?
JessicaLawson
 
Posts: 79
Joined: Sun Jun 13, 2010 1:23 pm

Re: Lookup Command Button-Anchor-Properly resize

Postby JessicaLawson » Sun Jun 13, 2010 4:17 pm

>>> My question now is - how do you distribute structural updates to the
>>> client? Should I generate a program for the view and send it as a part
>>> of main program?

Cool, now that is a question about the "VPME Update Builder" (see the help
file...)

Drop this question into the promatrix.public.developers news group and
discuss it there - there are developers responding in that group with a lot
more experience with this feature then me...

Cheers,

John
JessicaLawson
 
Posts: 79
Joined: Sun Jun 13, 2010 1:23 pm


Return to ProMatrix User Library

Who is online

Users browsing this forum: No registered users and 1 guest

cron