WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: dcrouter on June 14, 2019, 07:14:19 AM

Title: Conditional buttons
Post by: dcrouter on June 14, 2019, 07:14:19 AM
Hi, would someone help me with Conditional buttons.  I have two buttons one should be inactive till the first one is clicked then a process will run then the second should be active but the first will deactivate till the second one is pressed with its own process.

Any help would be appreciated .
Title: Re: Conditional buttons
Post by: td on June 14, 2019, 07:47:19 AM
Are your buttons part of a WIL dialog?
Title: Re: Conditional buttons
Post by: dcrouter on June 14, 2019, 08:42:31 AM
Yes they are part of a user log program where the user has to click on one button and type response then can't press the same button till process is finished and then the second button would activate and first deactivates.

I hope i'm explaining myself.

Please note picture attached

thank you for your prompt response
Title: Re: Conditional buttons
Post by: td on June 14, 2019, 11:23:49 AM
If you have not done so already, you need to create a user-defined callback procedure. Inside that procedure, you use the DialogControlState function to either enable or disable buttons as needed.

In case you have not created a callback yet, follow these steps:

Now that you have a call-back procedure in your script you need to uncomment a few lines.  To allow your procedure to handle the button press event uncomment the line in the @deInit case for the button push event.  It will look something like this:
Code (winbatch) Select
DialogProcOptions(MyDialog_Handle,@dePbPush,@TRUE)

You also need to uncomment the @dePbPush case.  That is where you will handle enabling and disabling your buttons as well as performing other tasks in response to a button press.

You can use the DialogControlState function's @dcsAddStyle and @dcsRemStyle request-codes with the @csDisabled style to enable and disable your buttons.  It might look something like this:
Code (winbatch) Select
      case @dePbPush
         if MyDialog_Name == "PushButton_OK"               ; OK
            DialogControlState(MyDialog_Handle, "PushButton_OK, @dcsAddStyle, @csDisabled)
            return(@retNoExit)

You can find much more information about the function and dialog callbacks in the Consolidated WIL Help file.
Title: Re: Conditional buttons
Post by: dcrouter on June 14, 2019, 11:41:35 AM
Thank you for your answer.

Not trying to be lazy but is there a way you could post a small script with your instructions using the picture I sent earlier?  In other words a sample dialogue like mine with the completed script.
I really appreciate it.  If not possible, thank you for your help always.

Title: Re: Conditional buttons
Post by: td on June 14, 2019, 01:26:14 PM
We try to discourage cut&paste programming. All you need to do is to follow the simple instruction given above and do a little reading in the Consolidated WIL Help file.  WIL Dialogs are not that hard to understand if you are willing to invest a very small bit of time learning.  If you are willing, you will have a valuable new tool for use in solving problems and creating solutions.
Title: Re: Conditional buttons
Post by: dcrouter on June 14, 2019, 01:42:33 PM
I understand, I've been using Win-batch since the 95 version all the way through never had any major problems trying to learn and implement by examples.  i'm pressed for time now juggling many projects and i thought this one would be the easiest to get it out of the way.

Again thank you for the prompt response.