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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enable buttons thru pageframe?

Status
Not open for further replies.

august

MIS
Aug 24, 2000
150
PH
How can i enabled buttons on a pageframe?

sample prog.:

if thisform.pageframe1.activepage = 1
thisform.cmdSAVE.enabled = .F.
thisform.cmdEDIT.enabled = .F.
else
thisform.cmdSAVE.enabled = .T.
thisform.cmdEDIT.enabled = .T.
endif

is this a good sample prog.? i used it, but seems to be
there nothing happend on the prog. i been workin. if it is be then where can i place this? what part at form or at the
pageframe code? what property will i'll be workin?

thanks!

august
[sig][/sig]
 
As far as I can see your code is right, however it will work only if you put it on a user-defined method and you call it from the Activate Event of every Page in your PageFrame or if you copy the portion of your code that you consider necesary into the Activate Envent of the appropriate page on your PageFrame.

I mean somewhat like this...

Sample 01

Procedure EnableButtons
*!*User-defined method
If thisform.pageframe1.activepage = 1
thisform.cmdSAVE.enabled = .F.
thisform.cmdEDIT.enabled = .F.
else
thisform.cmdSAVE.enabled = .T.
thisform.cmdEDIT.enabled = .T.
endif
EndProc

Procedure Activate
*!*This is the activate event of Page1
Thisform.EnableButtons()
EndProc

Procedure Activate
*!*This is the activate event of Page1
Thisform.EnableButtons()
EndProc

Or I could do this...

Sample 02

Procedure Activate
*!*This is the activate event of Page1
thisform.cmdSAVE.enabled = .F.
thisform.cmdEDIT.enabled = .F.
EndProc

Procedure Activate
*!*This is the activate event of Page2
thisform.cmdSAVE.enabled = .T.
thisform.cmdEDIT.enabled = .T.
EndProc
[sig]<p>Edwin Dalorzo<br><a href=mailto:edalorzo@hotmail.com>edalorzo@hotmail.com</a><br><a href= > </a><br> [/sig]
 
if thisform.pageframe1.activepage = 1
thisform.cmdSAVE.enabled = .F.
thisform.cmdEDIT.enabled = .F.
else
thisform.cmdSAVE.enabled = .T.
thisform.cmdEDIT.enabled = .T.
endif

may be replaced by 2 commands:

thisform.cmdSAVE.enabled = !(thisform.pageframe1.activepage = 1)
thisform.cmdEDIT.enabled = thisform.cmdSAVE.enabled

[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
You could add an assign method to the activepage variable of the pageframe. Then place your if/else there. That way each time the page frame is changed it will activate/deactivate the buttons. [sig]<p> Pete<br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>What your mother told you is true! You will go blind! (from moonshine anyway)[/sig]
 
I doubt about this. Assign method fired ONLY when you assign something in YOUR code. For example,

thisform.pageframe1.ActivePage = 2

When property value set by VFP internal ways (say, when you click to switch to another page), assign method will not fire. Verified for many VFP standard properties.
[sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Vlad is right

VFP help system &quot;Note Access and Assign methods can also be created for all native Visual FoxPro properties. For example, you can create an Access method for the Left property of a form, allowing you to execute code whenever the form's Left property is queried. You can create an Assign method for a native Visual FoxPro property that is read-only (for example, the ParentClass property), but the method will never be executed.&quot;

Seems silly to me but it is true. I guess I had never tried it before on native properties.

Anyhow sorry for false info... Edwin's examples above are probably the easiest way to do it. Make use of the ACTIVATE and DEACTIVATE event for the affected pages in the page frame. [sig]<p> Pete<br><a href=mailto:blindpete@mail.com>blindpete@mail.com</a><br><a href= > </a><br>What your mother told you is true! You will go blind! (from moonshine anyway)[/sig]
 
My .02

PROCEDURE cmdSave.Refresh()
THIS.Enabled=!(THISFORM.pageframe1.activepage = 1)
ENDPROC
PROCEDURE cmdEdit.Refresh()
THIS.Enabled=!(THISFORM.pageframe1.activepage = 1)
ENDPROC
PROCEDURE frmForm.pageframe1.page1.Activate()
THISFORM.Refresh()
ENDPROC
PROCEDURE frmForm.pageframe1.page1.Deactivate()
THISFORM.Refresh()
ENDPROC
PROCEDURE frmForm.Refresh()
THIS.cmdSave.Refresh()
THIS.cmdEdit.Refresh()
ENDPROC [sig]<p>Jon Hawkins<br><a href=mailto: jonscott8@yahoo.com> jonscott8@yahoo.com</a><br><a href= > </a><br>Carpe Diem! - Seize the Day![/sig]
 
I agree that thisform.Refresh s the best starting potint to refresh something. However, sometimes thisform.Refresh() works quite slowly. Specially slowly when you have pageframes and many other controls on it. [sig]<p>Vlad Grynchyshyn<br><a href=mailto:vgryn@softserve.lviv.ua>vgryn@softserve.lviv.ua</a><br>[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top