Jump to content

Recommended Posts

Posted (edited)

So I often heard that styles should be 'BitOr'ed but I can't see any difference between "+" and "BitOr"!?

Maybe someone of you could explain me why the result is the same :D

Here's my sample:

#include "GUIConstants.au3"
Global $DS_MODALFRAME = 0x80

Msgbox(0,"compare1",$DS_MODALFRAME + $WS_POPUP + $WS_CAPTION + $WS_SYSMENU & @LF & @LF & BitOr($DS_MODALFRAME,BitOr($WS_POPUP,BitOr($WS_CAPTION,$WS_SYSMENU))))

Msgbox(0,"compare2",0x1 + $WS_VSCROLL + $WS_BORDER + $WS_TABSTOP + $WS_GROUP & @LF & @LF & BitOr(0x1,BitOr($WS_VSCROLL,BitOr($WS_BORDER,BitOr($WS_TABSTOP,$WS_GROUP)))))

Msgbox(0,"compare3",$GUI_DISABLE + $GUI_SHOW & @LF & @LF & BitOr($GUI_DISABLE,$GUI_SHOW))

Msgbox(0,"not really an example;-)",$CBS_DROPDOWNLIST +$SS_GRAYRECT & @LF & @LF & BitOr($CBS_DROPDOWNLIST,$SS_GRAYRECT))

The only reason I see is that what Valik said - that they are stored/used then as doubles, and that means they are 'larger'...

Or can somebody give me an example where an error occurs, I mean where styles which should be together has a different result than adding.

And I mean not such a sample like "BitOr(3,5)".

I don't know a control where are the stylenrs. 3 and 5 used the same time...

I know there was a discussion about a new BitOr-function, is it maybe possible to change the existing 'BitOr'-function to something like this?:

///////////////////////////////////////////////////////////////////////////////
// BitOR()
///////////////////////////////////////////////////////////////////////////////

AUT_RESULT AutoIt_Script::F_BitOR(VectorVariant &vParams, Variant &vResult)
{
   int  int i, result = vParams[0].nValue(), iNumParams = vParams.size();
    
   for (i=1; i<iNumParams; i++)
      result |= vParams[i].nValue();
   vResult = result;

   return AUT_OK;

} // BitOR()

and an AND-function like:

///////////////////////////////////////////////////////////////////////////////
// BitAND()
///////////////////////////////////////////////////////////////////////////////

AUT_RESULT AutoIt_Script::F_BitAND(VectorVariant &vParams, Variant &vResult)
{
   int  i, result = vParams[0].nValue(), iNumParams = vParams.size();

   for (i=1; i<iNumParams; i++)
      result &= vParams[i].nValue();
   vResult = result;
   
   return AUT_OK;

} // BitAND()

Maybe I see this a little bit to easy :):huh2:

Edited by Holger
Posted

The styles have to pass through a 32 bit integer internally somewhere. I think that using hex notation also passes the numbers through a 32 bit int so that the variable in AutoIt has the correct bits set. Something that doesn't happen when using the decimal representation since that goes straight into a double. The last time I looked at GuiConstants, I noticed most/all the styles were in hex notation, which should mean it's not necessary to BitOR them. It's just much safer that way.

Posted

In the GuiConstants the value are express in 0x... .

So I you see 0,1,2,4,8 digit you can sum up.

But for instance $WS_CAPTION cannot be added with $WS_BORDER they need to be Ored. In fact in this particular case $WS_BORDER is include in $WS_CAPTION so $WS_CAPTION is enough because it include WS_BORDER :D

Posted

Ok, you're are all right.. I see :D

But I think at the moment I have no problems anymore cause I use the changed BitOr-function so I can BitOr max. 255 different styles :huh2:

And that should be enough :)

Like:

BitOr($WS_BORDER,$WS_CAPTION,$WS_GROUP,...)

Thanks all for the samples an information :lol:

Regards Holger

  • Administrators
Posted

Ok, you're are all right.. I see  :D

But I think at the moment I have no problems anymore cause I use the changed BitOr-function so I can BitOr max. 255 different styles  :huh2: 

And that should be enough  :)

Like:

BitOr($WS_BORDER,$WS_CAPTION,$WS_GROUP,...)

Thanks all for the samples an information  :lol:

Regards Holger

I'm going to add that too, in addition to the new operators.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...