Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


"|" and "|=" symbol in C++?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Master Cheater
Reputation: 1

Joined: 17 Feb 2016
Posts: 490

PostPosted: Sun Apr 09, 2017 1:50 pm    Post subject: "|" and "|=" symbol in C++? Reply with quote

I am confused by the two expressions below, which are written in a tutorial explaining WIN API:

First:
Code:

style = WS_CHILD | WS_VISIBLE | SS_BLACKFRAME;


What does the "|" mean in the expression? I know that it is setting the appearance of a control, but why use "|"? Is it a binary OR? Or is it a required way to set the windows style?

Second:
Code:

if (*c == 0) style |= ES_MULTILINE | ES_AUTOVSCROLL;


What does the "|=" mean?

Thanks in advance.

_________________
**************

A simple example is better then ten links. Very Happy


Last edited by Dr.Disrespect on Sun Apr 09, 2017 6:00 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 341

Joined: 09 May 2003
Posts: 19983
Location: The netherlands

PostPosted: Sun Apr 09, 2017 1:58 pm    Post subject: Reply with quote

first one does a binary OR of WS_CHILD | WS_VISIBLE | SS_BLACKFRAME and stores the result in style

the second one can be rewritten as
Code:

style = style | ES_MULTILINE | ES_AUTOVSCROLL;


which OR's ES_MULTILINE | ES_AUTOVSCROLL with style

basically OR just sets flags (doesn't remove them) so you can see it as just adding these options to the existing style options

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Dr.Disrespect
Master Cheater
Reputation: 1

Joined: 17 Feb 2016
Posts: 490

PostPosted: Sun Apr 09, 2017 5:59 pm    Post subject: Reply with quote

Dark Byte wrote:
first one does a binary OR of WS_CHILD | WS_VISIBLE | SS_BLACKFRAME and stores the result in style

the second one can be rewritten as
Code:

style = style | ES_MULTILINE | ES_AUTOVSCROLL;


which OR's ES_MULTILINE | ES_AUTOVSCROLL with style

basically OR just sets flags (doesn't remove them) so you can see it as just adding these options to the existing style options


Thanks a lot, DB, well explained. Smile

_________________
**************

A simple example is better then ten links. Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites