Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: ChR0NiC on February 15, 2004, 09:07 PM

Title: Menu Enabled/Disabled
Post by: ChR0NiC on February 15, 2004, 09:07 PM
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??
Title: Re:Menu Enabled/Disabled
Post by: effect on February 16, 2004, 01:32 AM
OBJECTNAME.Enabled = False
Title: Re:Menu Enabled/Disabled
Post by: Stealth on February 16, 2004, 02:39 PM
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.
Title: Re:Menu Enabled/Disabled
Post by: ChR0NiC on February 18, 2004, 07:42 PM
Quote from: Stealth on February 16, 2004, 02:39 PM
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.

So I would be like....

If Winsock1.State = sckConnected and varProduct = "3RAW" or varProduct = "PX3W" Then
mnuW3ClanList.Enabled = True
Else
mnuW3ClanList.Enabled = False
End If


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

Edit: Fixed Spelling Error
Title: Re:Menu Enabled/Disabled
Post by: Stealth on February 18, 2004, 11:37 PM
Quote from: ChR0NiC on February 18, 2004, 07:42 PM
So I would be like....

If Winsock1.State = sckConnected and varProduct = "3RAW" or varProduct = "PX3W" Then
mnuW3ClanList.Enabled = True
Else
mnuW3ClanList.Enabled = False
End If


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


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
Title: Re:Menu Enabled/Disabled
Post by: Adron on February 20, 2004, 01:53 PM
Quote from: Stealth on February 18, 2004, 11:37 PM
Yes, that would work; but, I'd reorganize it so it's a little clearer, and use StrComp for accuracy:

Why StrComp? Are you changing Option Compare?
Title: Re:Menu Enabled/Disabled
Post by: o.OV on February 20, 2004, 04:41 PM
Quote from: Adron on February 20, 2004, 01:53 PM
Quote from: Stealth on February 18, 2004, 11:37 PM
Yes, that would work; but, I'd reorganize it so it's a little clearer, and use StrComp for accuracy:

Why StrComp? Are you changing Option Compare?

Well..
StrComp to my knowledge is an eensy weensy bit faster
then the "=" operator for strings.
Title: Re:Menu Enabled/Disabled
Post by: Stealth on February 20, 2004, 11:30 PM
Quote from: Adron on February 20, 2004, 01:53 PM
Quote from: Stealth on February 18, 2004, 11:37 PM
Yes, that would work; but, I'd reorganize it so it's a little clearer, and use StrComp for accuracy:

Why StrComp? Are you changing Option Compare?

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.
Title: Re:Menu Enabled/Disabled
Post by: Adron on February 21, 2004, 05:06 AM
Quote from: Stealth on February 20, 2004, 11:30 PM
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.

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?
Title: Re:Menu Enabled/Disabled
Post by: Stealth on February 22, 2004, 03:30 AM
Quote from: Adron on February 21, 2004, 05:06 AM
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?

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. ;)