Click here to Skip to main content
15,888,293 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionChanging CMainFrame Minimize ICON Pin
ForNow9-Jan-19 14:02
ForNow9-Jan-19 14:02 
QuestionRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 4:07
David Crow10-Jan-19 4:07 
AnswerRe: Changing CMainFrame Minimize ICON Pin
ForNow10-Jan-19 4:39
ForNow10-Jan-19 4:39 
GeneralRe: Changing CMainFrame Minimize ICON Pin
David Crow10-Jan-19 4:42
David Crow10-Jan-19 4:42 
GeneralRe: Changing CMainFrame Minimize ICON Pin
ForNow10-Jan-19 5:09
ForNow10-Jan-19 5:09 
QuestionUsage of bitset ? Pin
Vaclav_9-Jan-19 5:12
Vaclav_9-Jan-19 5:12 
AnswerRe: Usage of bitset ? Pin
Daniel Pfeffer9-Jan-19 5:46
professionalDaniel Pfeffer9-Jan-19 5:46 
AnswerRe: Usage of bitset ? Pin
k50549-Jan-19 6:09
mvek50549-Jan-19 6:09 
I suspect what you want to use is bit-field struct members.

e.g. your device sends you 2 bytes, formatted as follows
1-2 op status code 1
3-6 op status code 2
7-12 error code
13-16 unused

You could model that as follows
C++
struct  op_status {
    unsigned int  status_1:2;
    unsigned int  status_2:2;
    unsigned int  error:6;
};

If you are unfamiliar with this construct a struct member like unsigned int item:2 defines a member only 2 bits wide. The type of a bit-field member should be integral, (e.g. char, short, int, etc) but can be signed or unsigned as needed.

You can use the struct members as short ints e.g
C++
int devfd = open("/dev/a_device", O_RDWR);

struct op_status i2c_status;

read(devfd, &i2c_status, sizeof(i2c_status));

if(i2c_status.status_1 == 1) {
    /* do something */
} else if ( i2c_status.status_1 == 2 && i2c_status.status_2 = 1) {
    switch(i2c_status.error) {
        case 1:  /* handle error code 1 */
            break;
        case 2:  /* handle error code 2 */
            break;
        ...
        default: /* do something else */
    }
}

looking a <bitset>, I don't see a nice way to group the bits together to treat them as a single unit, like you can using bit-fields. Usually, bit-fields are packed together, but check your compiler documentation to make sure. Also, don't forget that bit and/or byte order coming from your device might not match your CPU, so you may need to declare various fields out-of-order with respect to the documentation.
GeneralRe: Usage of bitset ? Pin
Daniel Pfeffer9-Jan-19 21:38
professionalDaniel Pfeffer9-Jan-19 21:38 
GeneralRe: Usage of bitset ? Pin
Vaclav_10-Jan-19 4:39
Vaclav_10-Jan-19 4:39 
QuestionVC++ 2017 redistributables versions. Pin
Maximilien8-Jan-19 4:21
Maximilien8-Jan-19 4:21 
AnswerRe: VC++ 2017 redistributables versions. Pin
Victor Nijegorodov8-Jan-19 8:43
Victor Nijegorodov8-Jan-19 8:43 
GeneralRe: VC++ 2017 redistributables versions. Pin
Maximilien8-Jan-19 9:01
Maximilien8-Jan-19 9:01 
GeneralRe: VC++ 2017 redistributables versions. Pin
Victor Nijegorodov8-Jan-19 9:03
Victor Nijegorodov8-Jan-19 9:03 
QuestionSubclassing a listcontrol in dialog bar Pin
manoharbalu6-Jan-19 23:48
manoharbalu6-Jan-19 23:48 
AnswerRe: Subclassing a listcontrol in dialog bar Pin
Victor Nijegorodov7-Jan-19 2:12
Victor Nijegorodov7-Jan-19 2:12 
Questionupdating output value with timer and resetting if the timer exceeds a certain time or it has a new input value Pin
crucial19536-Jan-19 14:42
crucial19536-Jan-19 14:42 
SuggestionRe: updating output value with timer and resetting if the timer exceeds a certain time or it has a new input value Pin
David Crow6-Jan-19 14:59
David Crow6-Jan-19 14:59 
AnswerRe: updating output value with timer and resetting if the timer exceeds a certain time or it has a new input value Pin
leon de boer6-Jan-19 16:17
leon de boer6-Jan-19 16:17 
QuestionSeperate source code for the tokens in the compiler c++ Pin
Member 141086114-Jan-19 20:10
Member 141086114-Jan-19 20:10 
AnswerRe: Seperate source code for the tokens in the compiler c++ Pin
Richard MacCutchan4-Jan-19 22:08
mveRichard MacCutchan4-Jan-19 22:08 
AnswerRe: Seperate source code for the tokens in the compiler c++ Pin
jschell5-Jan-19 5:59
jschell5-Jan-19 5:59 
QuestionPostmessage Not Working With WH_GETMESSAGE-MFC Pin
srinivasankrishnaa1-Jan-19 20:11
srinivasankrishnaa1-Jan-19 20:11 
AnswerRe: Postmessage Not Working With WH_GETMESSAGE-MFC Pin
Richard MacCutchan1-Jan-19 22:08
mveRichard MacCutchan1-Jan-19 22:08 
GeneralRe: Postmessage Not Working With WH_GETMESSAGE-MFC Pin
srinivasankrishnaa1-Jan-19 22:25
srinivasankrishnaa1-Jan-19 22:25 

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.