(nobody)
8/29/2010 9:15:00 AM
"Abhishek" <user@server.com> wrote in message
news:i5cfqm$dl5$1@speranza.aioe.org...
> Hi,
>
> I have 6 radio buttons (control array) on a form, the user selects the
> option and click the OK button and there are two procedures in my code to
> enable and disable all controls until the process is complete. but when I
> disable all the radio buttons the last radio button gets automatically
> selected. I dont know why its happening. there is no other code for the
> radio buttons except in the DisableControls procedure.
>
> Private Sub DisableControls()
> Dim i As Integer
>
> For i = 0 To optFormat.Count - 1
> optFormat(i).Enabled = False
> Next
> End Sub
I was able to duplicate the problem with VB6+SP5, with SP6 runtime, even if
I put them on a frame. However, if I disable the frame first, then the
options, then the problem disappears. It's interesting to note that only the
last option Click event fires, not while other options are disabled.
Another solution that I found is to use EnableWindow() API function. This
works fine whether the options are on a frame or not.
Private Declare Function EnableWindow Lib "user32" (ByVal hwnd As Long, _
ByVal fEnable As Long) As Long
Private Sub DisableControls()
Dim i As Integer
For i = 0 To optFormat.Count - 1
'optFormat(i).Enabled = False
EnableWindow optFormat(i).hwnd, 0
Next
End Sub