Click here to Skip to main content
16,004,906 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Modal dialog problem Pin
Chandrasekharan P4-Jan-09 23:34
Chandrasekharan P4-Jan-09 23:34 
GeneralRe: Modal dialog problem Pin
Code-o-mat5-Jan-09 0:49
Code-o-mat5-Jan-09 0:49 
AnswerRe: Modal dialog problem Pin
Nibu babu thomas4-Jan-09 21:55
Nibu babu thomas4-Jan-09 21:55 
QuestionStrange behavior in bit fields in "C++" Pin
Joseph Marzbani4-Jan-09 19:07
Joseph Marzbani4-Jan-09 19:07 
AnswerRe: Strange behavior in bit fields in "C++" Pin
KarstenK4-Jan-09 21:00
mveKarstenK4-Jan-09 21:00 
AnswerRe: Strange behavior in bit fields in "C++" Pin
Sameerkumar Namdeo4-Jan-09 21:01
Sameerkumar Namdeo4-Jan-09 21:01 
AnswerRe: Strange behavior in bit fields in "C++" Pin
CPallini4-Jan-09 23:08
mveCPallini4-Jan-09 23:08 
AnswerRe: Strange behavior in bit fields in "C++" Pin
Stuart Dootson5-Jan-09 0:13
professionalStuart Dootson5-Jan-09 0:13 
Like you, this behaviour seems a little unintuitive to me. Intel chips are little-endian (i.e. least-significant bytes first), but I thought that within a byte, a bit-field would extract the most significant bits first. Obviously not - as documented[^], Microsoft treat bytes as least-significant bit first as well.

Your only way round this is to do some bit manipulation yourself - the easiest way is probably to use bit-fields to extract the bits and glue them together again in methods of the struct - something like this:

struct CHUNKS
{
   unsigned  int FirstChunk() const { return firstChunk; }
   unsigned  int SecondChunk() const { return (secondChunkMSB<<4)|secondChunkLSB; }
   unsigned  int ThirdChunk() const { return (thirdChunkMSB<<2)|thirdChunkLSB; }
   unsigned  int FourthChunk() const { return fourthChunk; }
private:
   unsigned int secondChunkMSB:2;
   unsigned int firstChunk:6;

   unsigned int thirdChunkMSB:4;
   unsigned int secondChunkLSB:4;

   unsigned int fourthChunk:6;
   unsigned int thirdChunkLSB:2;
}*pChunk = NULL;
This does give the expected results for your test data.



Questionmemset? Pin
dec824-Jan-09 18:53
dec824-Jan-09 18:53 
AnswerRe: memset? Pin
dec824-Jan-09 19:18
dec824-Jan-09 19:18 
GeneralRe: memset? Pin
CPallini4-Jan-09 20:00
mveCPallini4-Jan-09 20:00 
AnswerRe: memset? Pin
ThatsAlok5-Jan-09 0:45
ThatsAlok5-Jan-09 0:45 
QuestionMy modal dialog loses focus to the parent dialog Pin
manoharbalu4-Jan-09 18:30
manoharbalu4-Jan-09 18:30 
AnswerRe: My modal dialog loses focus to the parent dialog Pin
David Crow5-Jan-09 8:10
David Crow5-Jan-09 8:10 
QuestionFile Exists Pin
rdop4-Jan-09 18:14
rdop4-Jan-09 18:14 
AnswerRe: File Exists Pin
Naveen4-Jan-09 18:20
Naveen4-Jan-09 18:20 
AnswerRe: File Exists Pin
Hamid_RT4-Jan-09 18:35
Hamid_RT4-Jan-09 18:35 
GeneralRe: File Exists Pin
KarstenK4-Jan-09 21:01
mveKarstenK4-Jan-09 21:01 
GeneralRe: File Exists Pin
Hamid_RT4-Jan-09 21:14
Hamid_RT4-Jan-09 21:14 
GeneralRe: File Exists Pin
ThatsAlok5-Jan-09 0:19
ThatsAlok5-Jan-09 0:19 
AnswerRe: File Exists Pin
Sameerkumar Namdeo4-Jan-09 21:04
Sameerkumar Namdeo4-Jan-09 21:04 
GeneralRe: File Exists Pin
ThatsAlok5-Jan-09 0:20
ThatsAlok5-Jan-09 0:20 
QuestionHow to create a custom list control in MFC ? Pin
shah1864-Jan-09 18:08
shah1864-Jan-09 18:08 
AnswerRe: How to create a custom list control in MFC ? Pin
Hamid_RT4-Jan-09 18:36
Hamid_RT4-Jan-09 18:36 
AnswerRe: How to create a custom list control in MFC ? Pin
Maximilien5-Jan-09 2:55
Maximilien5-Jan-09 2: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.