[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

F*CK

8/29/2010 2:15:00 AM

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


anyone experienced the same behavior?


24 Answers

F*CK

8/29/2010 2:23:00 AM

0

forgot to mention. i am also changing the BackColor of all those
radiobuttons at form_load

Dim I As Integer
For i = 0 To optFormat.Count - 1
optFormat(i).BackColor = Point(0, optFormat(i).Top)
Next


Randem

8/29/2010 2:34:00 AM

0

It would probably be better to place all the radio buttons on a frame or
picturebox then disable the container (frame or picturebox). In this way you
do not have to do each button separately. frmButton.Enable = False would
disable all buttons on the frame.

--
The Top Script Generator for Jordan Russell's Inno Setup -
http://www.randem.com/innos...
Free Utilities and Code - http://www.randem.com/freesof...
"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
>
>
> anyone experienced the same behavior?
>
>


(nobody)

8/29/2010 9:15:00 AM

0

"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


Randem

8/29/2010 10:08:00 AM

0

Ok, but if you disable the frame there is no need to disable the options too

--
The Top Script Generator for Jordan Russell's Inno Setup -
http://www.randem.com/innos...
Free Utilities and Code - http://www.randem.com/freesof...
"Nobody" <nobody@nobody.com> wrote in message
news:i5d8fi$j0g$1@speranza.aioe.org...
> "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
>


DanS

8/29/2010 3:19:00 PM

0

"Abhishek" <user@server.com> wrote in
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
>
>
> anyone experienced the same behavior?

Don't disable the selected one ?

(nobody)

8/29/2010 3:54:00 PM

0

"Randem" <newsgroups@randem.com> wrote in message
news:OOMGFI2RLHA.2104@TK2MSFTNGP04.phx.gbl...
> Ok, but if you disable the frame there is no need to disable the options
> too

When I disable the frame, the options look enabled, not grayed out like
expected, however, they don't respond to user input in either case.


Bob Butler

8/29/2010 3:57:00 PM

0


"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

If the option buttons are the last thing to be disabled then when you get
down to the last one it gets the focus. When an option button gets focus
and none in the group are already selected it gets selected by default. Try
re-arranging the order you disable things and make sure you do the option
buttons before at least 1 other control that can get focus. Either that or
set a flag that you are in the disabling routine and de-select the option
button when it happens.

Henning

8/29/2010 5:49:00 PM

0


"Abhishek" <user@server.com> skrev i meddelandet
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
>
>
> anyone experienced the same behavior?
>
>

I always add one more than needed, and make (0) invisible.

/Henning


Randem

8/29/2010 8:28:00 PM

0

That is exactly what it should do and I believe is exactly what you want to
happen, the user not being able to select anything.

--
The Top Script Generator for Jordan Russell's Inno Setup -
http://www.randem.com/innos...
Free Utilities and Code - http://www.randem.com/freesof...
"Nobody" <nobody@nobody.com> wrote in message
news:i5dvrc$93s$1@speranza.aioe.org...
> "Randem" <newsgroups@randem.com> wrote in message
> news:OOMGFI2RLHA.2104@TK2MSFTNGP04.phx.gbl...
>> Ok, but if you disable the frame there is no need to disable the options
>> too
>
> When I disable the frame, the options look enabled, not grayed out like
> expected, however, they don't respond to user input in either case.
>


F*CK

8/30/2010 10:32:00 AM

0

Thanks,

i fixed it by using a flag.


"Bob Butler" <bob_butler@cox.invalid> wrote in message
news:i5e03s$ppl$1@news.eternal-september.org...
|
| "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
|
| If the option buttons are the last thing to be disabled then when you get
| down to the last one it gets the focus. When an option button gets focus
| and none in the group are already selected it gets selected by default.
Try
| re-arranging the order you disable things and make sure you do the option
| buttons before at least 1 other control that can get focus. Either that
or
| set a flag that you are in the disabling routine and de-select the option
| button when it happens.
|