No announcement yet.

Where does startup event come from?

  • Filter
  • Time
  • Show
Clear All
new posts

    Where does startup event come from?

    I was playing with this option control sample app. To my surprise, when I compile and run the app, the MsgBox pops up - without me clicking on the option control.

    Not only that, but the app windows closes down but the app is still running and I have to use Ctl-Alt-Del to remove the app.

    Is this normal? I assumed some events take place on startup, but not the %BN_CLICK.

    This same code, using a checkbox or check3state instead of an option, does not automatically pop up the MsgBox.

       #Compile Exe
       Global hDlg As Dword
       Function PBMain() As Long
          Dialog New Pixels, 0, "Option Test",300,300,200,200, _
                                 %WS_OverlappedWindow, 0 To hDlg
          Control Add Option, hDlg, 100,"Click Me!", 50,50,100,20
          Dialog Show Modal hDlg Call DlgProc To Result&
       End Function
       CallBack Function DlgProc() As Long
          If Cb.Msg = %WM_Command And Cb.Ctl = 100 And Cb.CtlMsg = %BN_Clicked Then
             MsgBox "Clicked!"
             Dialog End hDlg
          End If
       End Function

    Radio buttons generate a BN_CLICKED notification message ("event") when one is selected either by clicking on it or pressing the spacebar when it is focused.

    It "may" also get that notifcation if selected programmatically ( CheckDlgButton if SDK style, CONTROL SET OPTION of DDT style). I am just not sure about that.

    In your example there is only one button in the group, so I'm guessing DDT is selecting it for you, but I'm not a DDT guy. I do know that using SDK style coding, you can get a whole group (WS_GROUP style on first control) of auto radio buttons to come up unchecked, but "DDT" might be "helping" you out here.

    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]


      Michael, thanks for the response. It seems like you're correct about DDT helping out somehow.

      I added a couple of extra option buttons to the test and changed the callback to refer to a control other than the first one created. That stopped the msgbox response. If I put code in the Callback referring to the 1st created control, I still get the extra event.

      So it would appear that the first control created gets an automatic bn_click event, although I'd have expected something like a focus event, rather than a bn_click.

      When I remove the MsgBox statement, the Option control is not checked, so it appears to be a bn_click event without a state change. I don't know what that is.

      I'm surprised there is such a default. Everyone before me uses some method of using a "dummy" option control so that their Callback doesn't see the DDT helper event?

      Somethings not right about that.

      Anyway, thanks for the good idea. At least I know the issue is there.


        I suppose that if you read and followed the documentation in a slaveish manner you would avoid these concerns (this is V8 documentation):

        Option buttons are used for presenting a list of choices, only one of which may be selected. So, there is no point in having just a single option button. If what you want is to allow turning a single item on or off, use a Checkbox instead.

        When a group of option buttons are created, you should explicitly set the "selected" and "unselected" state of all option buttons, using the CONTROL SET OPTION statement to set the Check State of all the buttons in the group.


          Hi Chris,

          Hold that thought. I'm off to go play tennis but I have some other code that does what v9 Help says to do, and I still get that trouble.

          I'll be back in a couple of hours!

          In a strict reading of Help content, I'm afraid I always interpret the "should" as how they want me to do it. I'm not always very good about following someone else's style.

          I prefer a "must" as an alert that it won't work right unless I do it their way. I'll know better in the future.

          I'll post the other code when I get back.



            Well, the code I thought wasn't working works fine now.

            I kept interpreting the separate Help file topics to mean one thing when it really meant something else. But after reading more closely and looking at the example, it was
            easy enough to make my code work with groups of options.

            Also, I played with it a bit more and discovered that I could avoid the unexpected messages, even when using only one Option control, by using the Control Set Options. None of the styles made any difference.

            I can't say I really intend to use one Option control by itself, but now I know I can.

            Michael & Chris, thanks again for the comments.


              > can't say I really intend to use one Option control by itself, but now I know I can.

              I think your users will understand and appreciate a checkbox much more than a radio button if there is but one yes/no choice.
              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]


                Originally posted by Gary Beene View Post
                I kept interpreting the separate Help file topics to mean one thing when it really meant something else.
                You are not alone in this. If one could make a constructive suggestion concerning the Help system, it might be that when writing Help topics, the target audience should be the remedial, not the expert, class.

                On the other hand, if the Help was better, maybe the Forums would be less lively?