Jump to content

can someone help me understand this?


 Share

Recommended Posts

hi,

I am trying to understand why the guy who wrote this code use the BitOr operation in the GUIcreate, can anyone tell me what good does it bring?

#include <GUIConstants.au3>

$gui=GUICreate("test transparentpic", 200, 100)
$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui); why using BitOr, I managed to that without it.
GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_SHOW,$gui)

HotKeySet("{ESC}", "main")
HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
HotKeySet("{DOWN}", "down")
HotKeySet("{UP}", "up")
$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)

do
    $msg = GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE
Exit

Func main()
    $guiPos = WinGetPos($gui)
    WinMove($gui,"",$guiPos[0]+10,$guiPos[1]+10)
EndFunc

Func left ()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]-10,$picPos[1])
EndFunc

Func right()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]+10,$picPos[1])
EndFunc

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]+10)
EndFunc

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]-10)
EndFunc
Link to comment
Share on other sites

hi,

I am trying to understand why the guy who wrote this code use the BitOr operation in the GUIcreate, can anyone tell me what good does it bring?

#include <GUIConstants.au3>

$gui=GUICreate("test transparentpic", 200, 100)
$pic=GUICreate("", 68, 71, 10, 10,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$gui); why using BitOr, I managed to that without it.
GUICtrlCreatePic(@Systemdir & "\oobe\images\merlin.gif",0,0, 0,0)

GUISetState(@SW_SHOW,$pic)
GUISetState(@SW_SHOW,$gui)

HotKeySet("{ESC}", "main")
HotKeySet("{LEFT}", "left")
HotKeySet("{RIGHT}", "right")
HotKeySet("{DOWN}", "down")
HotKeySet("{UP}", "up")
$picPos = WinGetPos($pic)
$guiPos = WinGetPos($gui)

do
    $msg = GUIGetMsg()
until $msg = $GUI_EVENT_CLOSE
Exit

Func main()
    $guiPos = WinGetPos($gui)
    WinMove($gui,"",$guiPos[0]+10,$guiPos[1]+10)
EndFunc

Func left ()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]-10,$picPos[1])
EndFunc

Func right()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0]+10,$picPos[1])
EndFunc

Func down()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]+10)
EndFunc

Func up()
    $picPos = WinGetPos($pic)
    WinMove($pic,"",$picPos[0],$picPos[1]-10)
EndFunc
You should always use BitOr. You will probably find many examples where the sum is used. Don't do that!

The values for the styles are sometimes multiples of 2 such as 2, 4, 512. In these cases BitOr will give the same result as addition.

Some styles are the combinations of other styles. Supposing one style is 2 Or 4 and another style is 32 Or 4. If you add them you get the style with a value 42, if you OR them you get a value 38.

As an example look at the window style $WS_POPUPwindow. Suppose you want that and you decide you also want a menu window so you add the style $WS_SYSMENU. BitOr($WS_POPUPWINDOW,$WS_SYSMENU) will give what you want but if you add them you will find you have somehow got a horizontal scroll bar which you didn't want.

This applies to lots of constants apart from styles. Adding values which should be Ored can make your program fail or crash or just not do what you want.

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

You should always use BitOr. You will probably find many examples where the sum is used. Don't do that!

The values for the styles are sometimes multiples of 2 such as 2, 4, 512. In these cases BitOr will give the same result as addition.

Some styles are the combinations of other styles. Supposing one style is 2 Or 4 and another style is 32 Or 4. If you add them you get the style with a value 42, if you OR them you get a value 38.

As an example look at the window style $WS_POPUPwindow. Suppose you want that and you decide you also want a menu window so you add the style $WS_SYSMENU. BitOr($WS_POPUPWINDOW,$WS_SYSMENU) will give what you want but if you add them you will find you have somehow got a horizontal scroll bar which you didn't want.

This applies to lots of constants apart from styles. Adding values which should be Ored can make your program fail or crash or just not do what you want.

As allways martin you give the best answer, I will do that from now on.

Link to comment
Share on other sites

and this is for those who come down on me all the time because of my questions:

well, I am not a programmer! well I was in the past, 7 years ago when learning and studying Altera master class and VHDL.

allthough working for a computer company, wrinting in Chips (VHDL) and writing a script here is not the same at all.

and I havn't done that in 5 years, so forgive me if I bother anyone. (you don't have to answer). my choose of AutoIT

for automation is because it is a script language desined for those who don't know programing at all. or forgot what it

was. and this forum topic is "General help an support". and this is what I need occecinally.

Link to comment
Share on other sites

martin

Some styles are the combinations of other styles. Supposing one style is 2 Or 4 and another style is 32 Or 4. If you add them you get the style with a value 42, if you OR them you get a value 38.

Nice answer! As i understand, reiterative value be omited?

MsgBox(0, "", BitOR(2, 4, 4))
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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