Holger Posted June 16, 2004 Posted June 16, 2004 (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 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 Edited June 16, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
Valik Posted June 17, 2004 Posted June 17, 2004 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.
Holger Posted June 17, 2004 Author Posted June 17, 2004 (edited) Thanks Valik and Larry for the information Hmmm...I see... the changed BitOr-function returns the right value:BitOr(1 ,2, 8, 32, 64)returns 107 Good night Edited June 17, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
Administrators Jon Posted June 17, 2004 Administrators Posted June 17, 2004 Also adding them together only works if each style is a new "binary" number like 1, 2,4,8,16 etc. Some styles are already combinations of other styles and therefore break when you simply add them together. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
jpm Posted June 17, 2004 Posted June 17, 2004 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
Holger Posted June 17, 2004 Author Posted June 17, 2004 Ok, you're are all right.. I see 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 And that should be enough Like: BitOr($WS_BORDER,$WS_CAPTION,$WS_GROUP,...) Thanks all for the samples an information Regards Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
Administrators Jon Posted June 18, 2004 Administrators Posted June 18, 2004 Ok, you're are all right.. I see 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 And that should be enough Like: BitOr($WS_BORDER,$WS_CAPTION,$WS_GROUP,...) Thanks all for the samples an information Regards HolgerI'm going to add that too, in addition to the new operators. Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now