Subject |
Re: Closing an image on a form |
From |
royprice <royprice@royprice.name> |
Date |
Wed, 07 Apr 2021 16:34:41 -0400 |
Newsgroups |
dbase.getting-started |
Mervyn Bick Wrote:
> On 2021/04/07 11:39, royprice wrote:
>
> > Hello Akshat,
> > This is the code that currently displays the images in three areas...
> > this.IMAGEPHOTO01 = new IMAGE(this)
> > with (this.IMAGEPHOTO01)
> > onOpen = class::IMAGEPHOTO01_ONOPEN
> > onClose = class::IMAGEPHOTO01_ONCLOSE
> > height = 21.5
> > left = 89.0
> > top = 16.5
> > width = 87.0
> > dataSource = form.cactusaadatamodule1.photos01_dbf1.rowset.fields["photo"]
> > alignment = 3 // Keep Aspect Stretch
> > endwith
> >
> > this.IMAGEPHOTO02 = new IMAGE(this)
> > with (this.IMAGEPHOTO02)
> > height = 17.5
> > left = 176.0
> > top = 0.5
> > width = 82.0
> > dataSource = form.cactusaadatamodule1.photos02_dbf1.rowset.fields["photo"]
> > alignment = 3 // Keep Aspect Stretch
> > endwith
> >
> > this.IMAGEPHOTO03 = new IMAGE(this)
> > with (this.IMAGEPHOTO03)
> > height = 19.5
> > left = 176.0
> > top = 18.0
> > width = 82.0
> > dataSource = form.cactusaadatamodule1.photos03_dbf1.rowset.fields["photo"]
> > endwith
>
> Another of my assumptions when I put together that little example was
> that you only had one image control on your form. Having three image
> controls seems, on the face of it, to be a waste of space on the form.
> On the other hand if your application really calls for three image
> controls then so be it.
>
>
> > Straightforward.....
> > And this is my attempt to deal with the problem (which doesn't work).
> > Also tried the same with OnClose()
> >
> > function IMAGEPHOTO01_onOpen()
> > do case
> > case form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]='02'
> > dataSource = form.cactusaadatamodule1.photos02_dbf1.rowset.fields["photo"]
> >
> > case form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]='03'
> > dataSource = form.cactusaadatamodule1.photos03_dbf1.rowset.fields["photo"]
> >
> > case form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]='01'
> > dataSource = form.cactusaadatamodule1.photos01_dbf1.rowset.fields["photo"]
> > otherwise
> > dataSource = form.cactusaadatamodule1.photos02_dbf1.rowset.fields["photo"]
> > endcase
> >
> > return
>
> This would take care of displaying the correct photo for the first
> record in your main table. The syntax is, however, not quite correct.
> In addition the approach is wrong if you actually have three separate
> image controls on your form. Try the following.
>
>
> function IMAGEPHOTO01_onOpen()
> if
> form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]='01'
> this.dataSource =
> form.cactusaadatamodule1.photos01_dbf1.rowset.fields["photo"]
> else
> this.datasource = []
> endif
> return.
>
>
> You will need a similar onOpen event handler, with the necessary
> changes, for each image control. This will leave one image control
> displaying an image with the other two blank.
>
> If you decide to use only one image control so as to save space on the
> form with the added bonus of not have two empty image controls then the
> following onOpen event handler will do the job.
>
> function IMAGEPHOTO01_onOpen()
> if
> form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]='01'
> this.dataSource =
> form.cactusaadatamodule1.photos01_dbf1.rowset.fields["photo"]
> elseif
> form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]='02'
> this.dataSource =
> form.cactusaadatamodule1.photos02_dbf1.rowset.fields["photo"]
> elseif
> form.cactusaadatamodule1.cactusaa_dbf1.rowset.fields["photoyesfile"]='03'
> this.dataSource =
> form.cactusaadatamodule1.photos03_dbf1.rowset.fields["photo"]
> endif
> return.
>
> As an aside the if...elseif...else...endif contruct has exactly the same
> effect as a do case...case...otherwise...endcase construct. I prefer it
> as it requires less typing and I'm a lazy typist. :-) If you are
> happier with do case then by all means stick with it.
>
> The next step is to deal with updating the image controls as you
> navigate through the main table.
>
> The way to do this is to use the main rowset's onNavigate event handler.
> If you are using three image controls set the datasource property for
> the appropriate image control and null the other two by assigning [] to
> their datasource properties. If you are using one image control simply
> set the datasource as appropriate for the value in the photoyesfile field.
>
> Any rowset event handler doesn't understand the concept of "form" so one
> needs to use this this.parent.... instead. This is made trickier as
> using a datamodule adds an extra parent into the mix.
>
> I'm taking a break now to watch the rest of the ODI cricket match
> between Pakistan and South Africa but I'll give you some code tomorrow.
> Unless someone else does so first. :-)
>
> Mervyn.
>
> Hello Mervyn,
My inexperience is showing......
I only have three image controls because I didn't even consider that only one would do the job.
In retrospect what seems obvious now, wasn't before.
So here I go again
>
>
>
>
>
>
>
>
>
>
>
>
>
|
|