-
Combining constants
I am using a CommonDialog control to open files, with some flags set. I noticed
that if I use:
CommonDialog1.Flags = cdlOFNHelpButton Or cdlOFNHideReadOnly
I have the same result that:
CommonDialog1.Flags = cdlOFNHelpButton + cdlOFNHideReadOnly
Are there some important differences between the two approaches? How can
they have the same effect?
Thanks.
Chris
-
Re: Combining constants
"Chris Leffer" <chrisl@wank.com> wrote:
>I am using a CommonDialog control to open files, with some flags set. I noticed
>that if I use:
>CommonDialog1.Flags = cdlOFNHelpButton Or cdlOFNHideReadOnly
>
>I have the same result that:
>CommonDialog1.Flags = cdlOFNHelpButton + cdlOFNHideReadOnly
>
>Are there some important differences between the two approaches? How can
>they have the same effect?
In cases such as this, you are dealing with specific bits, and under normal
circumstances they aren't going to be the same bit. So, if you have
0001 and
0010
If you add them or Or them, you will get 0011. But let's suppose for some
reason you have used two different constant names for the same actual value,
such as
0001 and
0001
Or'ing them will still be 0001, but adding them will be 0010 for an incorrect
result.
--
Don Bradner
don@arcatapet.com
www.arcatapet.net (software)
www.arcatapet.com (pet shop)
-
Re: Combining constants
For the most part, the result is identical. However, logically, you are
ORing bits together and so that's the method I stick with. There are
mistakes you can make that will cause + to produce a wrong result (such as
specifying the same bit twice in your expression).
--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com
"Chris Leffer" <chrisl@wank.com> wrote in message
news:3b75f55a$1@news.devx.com...
>
> I am using a CommonDialog control to open files, with some flags set. I
noticed
> that if I use:
> CommonDialog1.Flags = cdlOFNHelpButton Or cdlOFNHideReadOnly
>
> I have the same result that:
> CommonDialog1.Flags = cdlOFNHelpButton + cdlOFNHideReadOnly
>
> Are there some important differences between the two approaches? How can
> they have the same effect?
>
> Thanks.
>
> Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks