Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

control button graphic from paradox script?

Status
Not open for further replies.

cmose

Technical User
Aug 4, 2003
14
US
Hello all,
Does anyone know if it is possible to control the grapic displayed on a form button (for example, a bitmap) through a paradox script? What I would like to do is to be able to change the graphic that is displayed on a button object through a script and "randomize" the image displayed on the button.
Thanks much!
 
You assign a graphic on a pushbutton the same as anywhere else.

Use the name of the pushbutton, and assign the graphic.

You would normally retrieve the graphic from a file with a graphic variable, then assign the graphic on the pushbutton as that graphic var.

If you need more specifics, please post the specifics of your button and image thereon.

Tony McGuire
 
Tony,
thanks Very much, I appreciate that, is there any chance you could provide an example chunk of code? I don't have access to the code right this second (at home). What I am interested in doing is the following: I have a script that opens up a form, this form has several "tabs" which contain buttons. I want to select a graphic from a directory in that script and assign it to the button. I'm just not familiar with the specific methods of assigning a graphic in pushbutton?

thanks much!
 
Tony,
thanks much and yeah I did a little cross posting, since the various paradox forums are not quite constantly frequented it seems like there may well be some who only check out one or two. I appreciate it any help you can provide!
 
var
f form
g graphic
endvar

g.readfromfile("path\filename.jpg")
f.open(":alias:formname.fsl")
f.container.container.objectname=g

I haven't tested the above, but I believe that is the gist of it.

Substitute path, alias, container and objectname for your acutal situation.

To be honest, though, you might consider having the graphic on that pushbutton ASSIGN ITSELF, say on form open.

Then you just put the code in the graphic object of each form. The next logical step, if you've worked with libraries, is to have a library method that handles multiple forms and multiple pushbuttons; this way there is just ONE location to adjust code - the library custom method, for ALL pushbuttons on ALL forms.

Tony McGuire
 
In my initial message, I said 'use the name of the pushbutton'.

In reality, you need to use the name of the graphic on the pushbutton.

And, of course, if there are any named containers to get to the graphic you need to use those when assigning the new graphic. Which is why I used container.container.objectname in my third post.

Tony McGuire
 
Tony,
thanks very much - I'll take a crack at that when I get in to work tomorrow. You mention using the name of the graphic on the pushbutton - would that be the name of the graphic container or the img file itself? If so, I assume there is a way to query the name of the current image from a button so that I can change it (if I want to quasi randomize which image will be assigned I'll need to either create an array of file names from the directory and try each one or just pull the current image and use that).

thanks again, really apprecaite it!
 
Tony,
thanks again, I have another question now - and mind you this is really basic and I feel rather foolish asking...but, I'm not quite sure exactly what the "graphic object" is in terms of what I'm trying to do. is a link to a screen shot of the object explorer for the form I am trying to alter, I was going to put the code into the pushbutton event just to test it out and get things going but I'm not quite sure what to set the f.container.container.objectname=g line to? If/when I get this done, let me know if you have a paypal account as I ought to at least buy you a beer ;)
 
You can also create a button using the expert and select the default graphic. Right-click the graphic on the new button and choose 'Paste From', then browse to the image you want.

Mac :)

"There are only 10 kinds of people in this world... those who understand binary and those who don't"

langley_mckelvy@cd4.co.harris.tx.us
 
Langley,
thanks much for the info, I've actually got that part down as I've had to do that in the past ;) what I'm trying to do is randomly assign a graphic to a button via a script or method on that button, e.g., this is something that would be happening once the form has been delivered (now I think I forgot to mention that earlier but is it possible to, using code, change the graphic on a form button once the form has been delievered???).

Thanks again!
 
You can change the graphic on a delivered form 'for this session'.

Meaning, only while the form is loaded. Next time you run it, it will revert back to the one it was delivered with unless you again change it. Again, depending on how you decide to do this, it may be easiest to have the code in the button object (#BitMap50) open() event - where it would run and 'randomize' the image every time the form is opened.

You'll want to 'name' that graphic (#BitMap50) to something you can use to refer to it by (theImage ?).

Then, it would be something like

theform.thepage.theimage=g

Now, if the method you are using to assign the graphic is at the page level, then you could use just

theImage=g



Tony McGuire
 
Tony,
thanks much, some more questions: If this button is nested in several differnt "boxes" on the page, is it necessary to specify each one of those from the form down to the graphic object to assign the image? e.g., form.box1.box2.box3.box3.menu.button.graphic=g ?
or, if the code will be executing in the graphic objects open method, is there anyway to just use this=g or something similar or f.this=g ? I want to avoid providing specific path information as I would like to be able to use this on several other buttons if possible. Thanks again for all the help!
 
I meant to say the open event of the button graphic - however, after trying to employ that methodology I keep getting a stack overflow when trying to open the main form, something about an event being nested too deeply?
 
If you use open() on the graphic, you can just use

self.value=g

As to using the name of each box, it isn't necessary when referring to 'self'.

Nor is it necessary if you have left the names of those boxes as their 'noise names' (#....) as assigned by Paradox when they are created.



Tony McGuire
 
Tony,
thanks! I think I've got that part down now. Just have to get the randomizing logic in and I think I'm good! Many thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top