Valhalla Legends Forums Archive | Visual Basic Programming | Menu Enabled/Disabled

AuthorMessageTime
ChR0NiC
I noticed that, on Eternal Chat, in the W3 Clan view, some of the menus selections on the popup menu are blocked out. Depending on the rank, and how long they have been in the clan. So how can I do something along those lines??
February 16, 2004, 3:07 AM
Null
OBJECTNAME.Enabled = False
February 16, 2004, 7:32 AM
Stealth
As menu items are technically GUI controls, you can enable/disable them as you would anything else. Just enable/disable the submenus based on current conditions when your user clicks the main menu.

For example, StealthBot's File menu will enable or disable the option "Get Warcraft III Clan List" on demand when you click File based on the bot's current status -- if it's online, on WAR3 or W3XP, and a member of a clan, the menu item is activated.
February 16, 2004, 8:39 PM
ChR0NiC
[quote author=Stealth link=board=31;threadid=5314;start=0#msg44624 date=1076963983]
As menu items are technically GUI controls, you can enable/disable them as you would anything else. Just enable/disable the submenus based on current conditions when your user clicks the main menu.

For example, StealthBot's File menu will enable or disable the option "Get Warcraft III Clan List" on demand when you click File based on the bot's current status -- if it's online, on WAR3 or W3XP, and a member of a clan, the menu item is activated.
[/quote]

So I would be like....
[code]
If Winsock1.State = sckConnected and varProduct = "3RAW" or varProduct = "PX3W" Then
mnuW3ClanList.Enabled = True
Else
mnuW3ClanList.Enabled = False
End If
[/code]

If I am still wrong, plz correct me.....

Edit: Fixed Spelling Error
February 19, 2004, 1:42 AM
Stealth
[quote author=ChR0NiC link=board=31;threadid=5314;start=0#msg44964 date=1077154977]
So I would be like....
[code]
If Winsock1.State = sckConnected and varProduct = "3RAW" or varProduct = "PX3W" Then
mnuW3ClanList.Enabled = True
Else
mnuW3ClanList.Enabled = False
End If
[/code]
[/quote]

Yes, that would work; but, I'd reorganize it so it's a little clearer, and use StrComp for accuracy:

[code]
If Winsock1.State = sckConnected Then
If (StrComp(varProduct, "3RAW") = 0 or StrComp(varProduct, "PX3W") = 0) Then
mnuW3ClanList.Enabled = True
Else
mnuW3ClanList.Enabled = False
End If
End If
[/code]
February 19, 2004, 5:37 AM
Adron
[quote author=Stealth link=board=31;threadid=5314;start=0#msg45000 date=1077169048]
Yes, that would work; but, I'd reorganize it so it's a little clearer, and use StrComp for accuracy:
[/quote]

Why StrComp? Are you changing Option Compare?
February 20, 2004, 7:53 PM
o.OV
[quote author=Adron link=board=31;threadid=5314;start=0#msg45193 date=1077306817]
[quote author=Stealth link=board=31;threadid=5314;start=0#msg45000 date=1077169048]
Yes, that would work; but, I'd reorganize it so it's a little clearer, and use StrComp for accuracy:
[/quote]

Why StrComp? Are you changing Option Compare?
[/quote]

Well..
StrComp to my knowledge is an eensy weensy bit faster
then the "=" operator for strings.
February 20, 2004, 10:41 PM
Stealth
[quote author=Adron link=board=31;threadid=5314;start=0#msg45193 date=1077306817]
[quote author=Stealth link=board=31;threadid=5314;start=0#msg45000 date=1077169048]
Yes, that would work; but, I'd reorganize it so it's a little clearer, and use StrComp for accuracy:
[/quote]

Why StrComp? Are you changing Option Compare?
[/quote]

Quite some time ago, during early development of StealthBot, comparing two strings with the = operator didn't work correctly for me. I've been using StrComp since then to ensure that the strings will be exactly alike. Perhaps it was just a fluke, but better safe than sorry.

Additionally, if you need to use StrComp() such that it ignores case, pass it vbTextCompare as a third parameter.
February 21, 2004, 5:30 AM
Adron
[quote author=Stealth link=board=31;threadid=5314;start=0#msg45298 date=1077341450]
Quite some time ago, during early development of StealthBot, comparing two strings with the = operator didn't work correctly for me. I've been using StrComp since then to ensure that the strings will be exactly alike. Perhaps it was just a fluke, but better safe than sorry.

Additionally, if you need to use StrComp() such that it ignores case, pass it vbTextCompare as a third parameter.
[/quote]

Ah. I've never had any problem with the = operator matching strings that weren't equal. The only thing I do use StrComp for is matching strings that differ in case. Hmm, maybe you were matching strings containing numbers, and it decided to compare them numerically for some reason?
February 21, 2004, 11:06 AM
Stealth
[quote author=Adron link=board=31;threadid=5314;start=0#msg45320 date=1077361595]
Ah. I've never had any problem with the = operator matching strings that weren't equal. The only thing I do use StrComp for is matching strings that differ in case. Hmm, maybe you were matching strings containing numbers, and it decided to compare them numerically for some reason?
[/quote]

That could have happened coincidentally, although I don't think it was the case. Either way, a habit has formed, and it's not necessarily a bad one. ;)
February 22, 2004, 9:30 AM

Search