Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
very
Jan 25, 2005

I err on the side of handsome.

YardKGnome posted:

3 is 0011 in binary. & is the bit-wise and operator. Basically, its giving you a random number between 0 and 3 (inclusive). It is equivalent to "% 4"

That seems like a bad idea. Somebody is going to want to add another case, change the 3 to a 4, and now you have a bug.

Adbot
ADBOT LOVES YOU

very
Jan 25, 2005

I err on the side of handsome.

karuna posted:

::Visual Basic::

Thanks in advance.

If you want something to take a certain amount of time, you can use a timer. Timers have a tick function that gets called every specific amount of time, and you can turn them on and off and specify the amount of time etc.

In order to be able to refer to your controls by number, you need to make a control array.

I don't know the specifics of how to implement these in VB, and it probably depends on what version of VB you are using, but at least you know what to google for now.

very
Jan 25, 2005

I err on the side of handsome.
I'm trying to add a dynamic number of items to a Windows CMenu. The only example of doing this in our codebase is this horrible hack:

Every menu item has to have a unique resource ID, so what this person did was to reserve a range of IDs in the resource.h file like this:
code:
#define ID_ASSET_ATTACHTAG              18700
#define ID_ASSET_REMOVETAG              18950
And then define command ranges in the message map:
code:
ON_COMMAND_RANGE(ID_ASSET_ATTACHTAG, ID_ASSET_ATTACHTAG+249, &CGLMaterialTreeItem::OnAssetAttachTag)
ON_COMMAND_RANGE(ID_ASSET_REMOVETAG, ID_ASSET_REMOVETAG+249, &CGLMaterialTreeItem::OnAssetRemoveTag)
We just assume that nobody was going to use any IDs within the range 18700 to 19200. This is retarded because you have to hack the resource.h manually to do this, you can't put it into the .rc file. Also, if there are more than 250 tags, this solution breaks. And lastly, the tags are a hierarchy so we have to go through the mess of finding a unique ID for each tag to build the menu, and then turn around and find a tag from an ID when the user selects a menu item.

This is obviously a lovely solution, and I was pissed when one of our Sr. developers told me that it was the only way to do this.

Surely there must be a way to set up a message map that can take a parameter of some sort, and make a menu item that passes the parameter along? I couldn't find anything that would tell me how to do this, or if it were even possible, but really I don't know what to search for.

very
Jan 25, 2005

I err on the side of handsome.

csammis posted:

You shouldn't be creating static IDs for dynamic menus. Does this help?
I had accomplished what I was trying to do without dynamic menu items, but I will keep this in mind. Thanks.

very
Jan 25, 2005

I err on the side of handsome.
So I hear that unit testing is a thing that real grown-up programmers do...

How can I start unit testing in an environment that is seemingly hostile towards testing? I don't really have time to finish what I'm working on in the first place. Secondly, most of the classes that I want to test can only be instantiated through a de-serialization process that takes input from a hugely complicated asset build system. Needless to say, nobody really tests anything here.

We've got xunit with some stuff plugged into it, but if you invoke the existing tests, everything simply explodes because nobody has run them for years. The leads don't really care about this.

I'm positive that I've never written a single piece of code here that is testable, let alone tested.

Do I just ignore all of the code that I've already written and try to test new stuff? The problem with that is that I usually have no idea what I'm writing until I've written it (two or three times). How can I test the unknown?

Adbot
ADBOT LOVES YOU

very
Jan 25, 2005

I err on the side of handsome.

Sneftel posted:

This book was specifically written to address your problem.

Thanks. This book looks great.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply