• Welcome to Valhalla Legends Archive.
 

Menu Enabled/Disabled

Started by ChR0NiC, February 15, 2004, 09:07 PM

Previous topic - Next topic

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??

effect

Quote from: Mangix on March 22, 2005, 03:03 AM
i am an expert Stealthbot VBScript. Recognize Bitch.

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.
- Stealth
Author of StealthBot

ChR0NiC

#3
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

Stealth

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
- Stealth
Author of StealthBot

Adron

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?

o.OV

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.
If the facts don't fit the theory, change the facts. - Albert Einstein

Stealth

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.
- Stealth
Author of StealthBot

Adron

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?

Stealth

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. ;)
- Stealth
Author of StealthBot