Welcome! Log In Create A New Profile

Advanced

[WD12] Global Procedure to manipulate window objects

Posted by DarrenF 
Hi guys,

I have a window created from a template, and as such, I have lots of "standard" push buttons that I thought I would disable/enable using a Global Procedure with a couple of parameters and some indirection, but I seem to have failed :sneg:

I've come up with the following code; the TableCount code seems okay but the code in the IF statement doesn't seem to recognise the "{WinName}." saying "operator forbidden" - any ideas?

PROCEDURE DisableTemplateButtons(WinName,TabName)

// Count the rows in the table
NumOfRows is int = TableCount({TabName,indControl})

// If table is empty then...
IF NumOfRows = 0 THEN
	// Disable standard/common buttons
	{WinName}.WPB_Delete..State = Grayed
	{WinName}.WPB_Save..State = Grayed
	{WinName}.WPB_First..State = Grayed
	{WinName}.WPB_Last..State = Grayed
	{WinName}.WPB_Next..State = Grayed
	{WinName}.WPB_Previous..State = Grayed
	{WinName}.WPB_Print..State = Grayed
ELSE
	// Enable standard/common buttons
	{WinName}.WPB_Delete..State = Active
	{WinName}.WPB_Save..State = Active
	{WinName}.WPB_First..State = Active
	{WinName}.WPB_Last..State = Active
	{WinName}.WPB_Next..State = Active
	{WinName}.WPB_Previous..State = Active
	{WinName}.WPB_Print..State = Active	
END
Al
Re: [WD12] Global Procedure to manipulate window objects
March 12, 2009 01:10AM
Hello Darren

We do something similar but our buttons are members of a group so instead of setting the attributes of individual buttons we set the group attributes. You can test for the existance of a group in the same way as a control



IF NumOfRows = 0 THEN
IF FieldExist("ButtonGroup")
ButtonGroup..state = grayed
End
Else
IF FieldExist("ButtonGroup")
ButtonGroup..state = active
End
End

Regards
Al
Darren
Try changing the indirection to

{WinName+".WPB_Delete",indControl}..State = Grayed

Regards

DerekT
Al,

Many thanks - that's a great Idea... :spos:
Derek,

Ah, I see - I need to build up the string. That explains why the TableCount worked.

Cheers :spos:
Thanks guys,

I've tried your suggestions - the indirection is now working and I've now "seen the light" and I'm using grouping for my window objects/controls :spos:

Cheers...
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: