Jump to content
  • Advertisement
Sign in to follow this  

DWORD and usages for passing params

This topic is 3991 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok i hope this comes as a simple question i am writing my own GUI Still .... anyways i wanted to use a DWORD varable to pass paramaters through as to shorten and make the setup calls to make a button edit box and so on easyer. Example.
#define GUI_SHOW 0x809 //Used as a flag to the Gui's show state true
#define GUI_DISABLED 0x810 //Used as a flag to the Gui's Enabled State

void SetOption(DWORD Options)
//To do 

Now the real problem here and what i can not figure out is if you were to pass in more then one parameter through SetOption() how could i separate them and how would i check for each one individually ! This is a very simple version of a much grander schema but for the most part using the DWORD to pass in an number of predefined sets would be very usefull and shorten setup protoypes greatly. Thanks for your time Regards Jouei.

Share this post

Link to post
Share on other sites
To check if one of your flags is specified in the "Options" parameter, you use a bit-wise AND operator. Like this:

if ( options & GUI_SHOW )
// Do stuff
else if ( options & GUI_DISABLED )
// Do other stuff

Share this post

Link to post
Share on other sites
ahh thank you i did not think it would be complicated but for the life of me i could not get it lol.

Thanks and regards Jouei.

Share this post

Link to post
Share on other sites

a DWORD has a size of 32-bit.
maybe take a look at a 4 bit broad variable:


you have 4 bits, and each of them can represent a boolean state.
with 32 bit you can now represent 32 different boolean state variables.

now you need to know how to "define" states, set states and check
if a state is set.
therefore there exist bitwise operations: AND, OR, XOR, SHIFT LEFT (SHL).

a good introduction is here:

have phun, shrooms

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!