Click here to Skip to main content
15,879,326 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: mouse cursor not shown in the CScrollView Pin
Iain Clarke, Warrior Programmer23-Jul-09 9:03
Iain Clarke, Warrior Programmer23-Jul-09 9:03 
GeneralRe: mouse cursor not shown in the CScrollView Pin
transoft23-Jul-09 9:17
transoft23-Jul-09 9:17 
GeneralRe: mouse cursor not shown in the CScrollView Pin
Iain Clarke, Warrior Programmer23-Jul-09 9:26
Iain Clarke, Warrior Programmer23-Jul-09 9:26 
GeneralRe: mouse cursor not shown in the CScrollView Pin
transoft23-Jul-09 10:09
transoft23-Jul-09 10:09 
QuestionUsing vista's virtualisation Pin
Kees195823-Jul-09 7:25
Kees195823-Jul-09 7:25 
QuestionBit Shift and Mask Pin
resolvequestion23-Jul-09 6:29
resolvequestion23-Jul-09 6:29 
AnswerRe: Bit Shift and Mask Pin
Cedric Moonen23-Jul-09 7:40
Cedric Moonen23-Jul-09 7:40 
AnswerRe: Bit Shift and Mask Pin
Iain Clarke, Warrior Programmer23-Jul-09 9:17
Iain Clarke, Warrior Programmer23-Jul-09 9:17 
That article Cedric pointed you at is great, but doesn't cover bit fields, which is what I'd use in your place.

Not by a compiler, so take this with healthy doubt over the exact syntax, but you can read a book, right?
struct {
  union
  {
     unsigned char Byte;
     struct {
       unsigned char Flag1 : 1;   // : 1 means take 1 bit
       unsigned char Option1 : 2;   // : 1 means take 2 bits
       unsigned char Flag2 : 1;   // : 1 means take 1 bit
       unsigned char Flag3 : 1;   // : 1 means take 1 bit
       unsigned char Flag4 : 1;   // : 1 means take 1 bit
       unsigned char Flag5 : 1;   // : 1 means take 1 bit
       unsigned char Flag6 : 1;   // : 1 means take 1 bit
     } Bits;
   } Flags;
   unsigned char Checksum;
   unsigned short int Sequence;
} PacketHeader


You can use it like:
PacketHeader packet;
ReadPacketSomehow (packet);
if (packet.Flags.Bits.Flag3)
{
   ....
}
if (packet.Flags.Bits.Option3 == 3)  // 2 bits, 0..3
{
   ....
}


Hope that helps you,

Iain.

I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[^]

GeneralRe: Bit Shift and Mask Pin
resolvequestion23-Jul-09 9:59
resolvequestion23-Jul-09 9:59 
GeneralRe: Bit Shift and Mask Pin
Iain Clarke, Warrior Programmer23-Jul-09 20:46
Iain Clarke, Warrior Programmer23-Jul-09 20:46 
GeneralRe: Bit Shift and Mask Pin
CPallini23-Jul-09 10:30
mveCPallini23-Jul-09 10:30 
GeneralRe: Bit Shift and Mask Pin
Iain Clarke, Warrior Programmer23-Jul-09 20:49
Iain Clarke, Warrior Programmer23-Jul-09 20:49 
AnswerRe: Bit Shift and Mask Pin
CPallini23-Jul-09 10:27
mveCPallini23-Jul-09 10:27 
Questionwhat happens in following code exactly? [modified] Pin
sam_psycho23-Jul-09 5:52
sam_psycho23-Jul-09 5:52 
AnswerRe: what happens in following code exactly? Pin
Code-o-mat23-Jul-09 6:01
Code-o-mat23-Jul-09 6:01 
GeneralRe: what happens in following code exactly? Pin
sam_psycho23-Jul-09 6:11
sam_psycho23-Jul-09 6:11 
AnswerRe: what happens in following code exactly? Pin
Iain Clarke, Warrior Programmer23-Jul-09 9:06
Iain Clarke, Warrior Programmer23-Jul-09 9:06 
AnswerRe: what happens in following code exactly? Pin
Joe Woodbury23-Jul-09 10:44
professionalJoe Woodbury23-Jul-09 10:44 
Question[mfc] restart other process Pin
rahuljin23-Jul-09 5:51
rahuljin23-Jul-09 5:51 
AnswerRe: [mfc] restart other process Pin
ThatsAlok23-Jul-09 6:05
ThatsAlok23-Jul-09 6:05 
GeneralRe: [mfc] restart other process Pin
rahuljin23-Jul-09 7:01
rahuljin23-Jul-09 7:01 
AnswerRe: [mfc] restart other process Pin
Code-o-mat23-Jul-09 6:11
Code-o-mat23-Jul-09 6:11 
GeneralRe: [mfc] restart other process Pin
rahuljin23-Jul-09 6:52
rahuljin23-Jul-09 6:52 
GeneralRe: [mfc] restart other process Pin
Code-o-mat23-Jul-09 7:09
Code-o-mat23-Jul-09 7:09 
AnswerRe: [mfc] restart other process Pin
Rajesh R Subramanian23-Jul-09 7:55
professionalRajesh R Subramanian23-Jul-09 7:55 

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.