Click here to Skip to main content
15,895,799 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOUT parameters in inline asm Pin
csrss29-Mar-11 3:25
csrss29-Mar-11 3:25 
AnswerRe: OUT parameters in inline asm [SOLVED] Pin
csrss29-Mar-11 4:17
csrss29-Mar-11 4:17 
QuestionBit extraction from byte Pin
sathishrdh29-Mar-11 2:22
sathishrdh29-Mar-11 2:22 
AnswerRe: Bit extraction from byte Pin
Niklas L29-Mar-11 2:27
Niklas L29-Mar-11 2:27 
GeneralRe: Bit extraction from byte Pin
Albert Holguin29-Mar-11 3:50
professionalAlbert Holguin29-Mar-11 3:50 
GeneralRe: Bit extraction from byte Pin
Peter_in_278029-Mar-11 11:43
professionalPeter_in_278029-Mar-11 11:43 
GeneralRe: Bit extraction from byte Pin
Albert Holguin29-Mar-11 12:51
professionalAlbert Holguin29-Mar-11 12:51 
AnswerRe: Bit extraction from byte Pin
Stefan_Lang30-Mar-11 1:53
Stefan_Lang30-Mar-11 1:53 
As mentioned above, use '&' to test for a bit pattern. I've illustrated that in the inline function extract below.

If you don't have the actual values of the bits to test for though, you may need to combine the variables that contain the test bits. In that case use the bitwise or operator '|'. I've illustrated that in the inline function test2Flags below.

You can easily combine more than 2 flags to test for by combining several of them with '|'. See the last call to extract below.

typedef unsigned char byte;
const byte indicator1 = 0x01;
const byte indicator2 = 0x02;
const byte indicator3 = 0x04;
const byte indicator4 = 0x08;
const byte indicator5 = 0x10;
const byte indicator6 = 0x20;
const byte indicator7 = 0x40;
const byte indicator8 = 0x80;

inline byte extract(byte indicators, byte mask) {
    return indicators & mask;
}
inline test2Flags(byte indicators, byte flag1, byte flag2) {
    return extract(indicators, flag1 | flag2);
}
int main() {
    byte myIndicator = 0x34;
    byte testMyIndicators3and5 = test2Flags(myIndicator, indicator2, indicator5); // result is 0x10
    byte testSeveralFlags = extract(myIndicators, indicator2 | indicator3 | indicator4); // = 0x04
    return 0;
}


Of course, you don't need to define any function for that, I just did this to enhance readability and focus on the relevant syntax.
QuestionFrench localization using Single-byte character set (SBCS) Pin
Selvam R28-Mar-11 23:27
professionalSelvam R28-Mar-11 23:27 
AnswerRe: French localization using Single-byte character set (SBCS) Pin
Richard MacCutchan28-Mar-11 23:59
mveRichard MacCutchan28-Mar-11 23:59 
GeneralRe: French localization using Single-byte character set (SBCS) Pin
Selvam R29-Mar-11 0:25
professionalSelvam R29-Mar-11 0:25 
GeneralRe: French localization using Single-byte character set (SBCS) Pin
Richard MacCutchan29-Mar-11 3:09
mveRichard MacCutchan29-Mar-11 3:09 
GeneralRe: French localization using Single-byte character set (SBCS) Pin
Selvam R29-Mar-11 18:48
professionalSelvam R29-Mar-11 18:48 
QuestionHow to revert SetCheckBox style ? [modified] Pin
_Flaviu28-Mar-11 21:30
_Flaviu28-Mar-11 21:30 
AnswerRe: How to revert SetCheckBox style ? Pin
Richard MacCutchan28-Mar-11 22:32
mveRichard MacCutchan28-Mar-11 22:32 
GeneralRe: How to revert SetCheckBox style ? Pin
_Flaviu29-Mar-11 5:03
_Flaviu29-Mar-11 5:03 
GeneralRe: How to revert SetCheckBox style ? Pin
Richard MacCutchan29-Mar-11 5:36
mveRichard MacCutchan29-Mar-11 5:36 
GeneralRe: How to revert SetCheckBox style ? Pin
_Flaviu29-Mar-11 20:52
_Flaviu29-Mar-11 20:52 
QuestionCapture keyboard event in a dialog dll Pin
Y K Kishore Kumar28-Mar-11 20:27
Y K Kishore Kumar28-Mar-11 20:27 
AnswerRe: Capture keyboard event in a dialog dll Pin
Selvam R29-Mar-11 1:49
professionalSelvam R29-Mar-11 1:49 
QuestionIs any way to draw Background Image? Pin
002comp28-Mar-11 19:47
002comp28-Mar-11 19:47 
AnswerRe: Is any way to draw Background Image? Pin
Nitheesh George28-Mar-11 20:30
Nitheesh George28-Mar-11 20:30 
AnswerRe: Is any way to draw Background Image? Pin
Niklas L28-Mar-11 20:57
Niklas L28-Mar-11 20:57 
AnswerRe: Is any way to draw Background Image? Pin
Hans Dietrich28-Mar-11 22:46
mentorHans Dietrich28-Mar-11 22:46 
GeneralRe: Is any way to draw Background Image? Pin
002comp29-Mar-11 2:32
002comp29-Mar-11 2:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.