Conditional buttons

Started by dcrouter, June 14, 2019, 07:14:19 AM

Previous topic - Next topic

dcrouter

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 .

td

Are your buttons part of a WIL dialog?
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

dcrouter

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

td

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:

  • Load the script containing your dialog into WinBatch Studio.
  • Usinig your mouse select your dialog template.
  • Once selected display the studio context menu by right-clicking somewhere in your script.
  • From the context menu, you select the "Code Blocks" item.
  • Next select the "Create Dialog Callbacks in Clipboard" item. You will see several submenu items.
  • Select "Subroutine Only" for now.
  • WBS will generate a dialog callback in the clipboard and all you need to do is paste it into your script above your dialog template by moving the insertion cursor above the template and pressing the ctrl+v key combination.

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

dcrouter

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.


td

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.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

dcrouter

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.