Click here to Skip to main content
15,921,837 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Prevent ALT F4 Pin
Harsha Gopal15-Jun-03 15:27
Harsha Gopal15-Jun-03 15:27 
GeneralRe: Prevent ALT F4 Pin
Anonymous15-Jun-03 17:34
Anonymous15-Jun-03 17:34 
GeneralRe: Prevent ALT F4 Pin
Ryan Binns15-Jun-03 17:50
Ryan Binns15-Jun-03 17:50 
GeneralRe: Prevent ALT F4 Pin
Joan M16-Jun-03 0:48
professionalJoan M16-Jun-03 0:48 
GeneralRe: Prevent ALT F4 Pin
Ryan Binns16-Jun-03 1:01
Ryan Binns16-Jun-03 1:01 
GeneralCouple of questions concerning bits Pin
georgiek5015-Jun-03 11:27
georgiek5015-Jun-03 11:27 
GeneralRe: Couple of questions concerning bits Pin
adamUK15-Jun-03 11:52
adamUK15-Jun-03 11:52 
GeneralRe: Couple of questions concerning bits Pin
Toni7815-Jun-03 12:07
Toni7815-Jun-03 12:07 
georgiek50 wrote:
I was under the impression (according to my programming book) that a left shift on a byte caused the bits on the left to "fall off" and zeros inserted to the right:
eg. 0x1F << 2 = 0xC0
but it equals 0x7C0


That's not the right answer. 0x1F << 2 = 0x7C.But in any case to ensure that you receive only the last 8 bits you can AND a byte with 0x0FF. For example:
char[ 0 ] = 0x1F;
DWORD dwVar = char[ 0 ];
dwVar = (dwVar << 2) & 0x0FF  // dwVar = 0x7C


georgiek50 wrote:
dwValue = ( ch[0] | (ch[1] << 8) | (ch[2] << 16) | (ch[3] << 24) );

The compiler will get each character in ch and store it into a register because that's the only place where shift operations can be performed. For example if you would see the above code written in machine language it would look like this:
mov eax, ch[0];    // ch[0] = byte ptr address in memory
mov edx, ch[1];    // same thing for ch[1]
shl edx, 8;        // ch1[] << 8
or eax, edx;       // ch[0] | (ch[1] << 8)
mov edx, ch[2];    // edx = ch[2]
shl edx, 16;       // ch[2] << 16
or eax, edx;       // ch[0] | (ch[1] << 8) | (ch[2] << 16 );
and so on....

The final result in eax will be moved to a dword ptr memory location that corresponds to dwValue. All the registers are 4 bytes long (32 bits) and a DWORD data type is a 32 bit unsigned integer. That's why this works.

// Afterall I realized that even my comment lines have bugs
GeneralRe: Couple of questions concerning bits Pin
georgiek5015-Jun-03 12:58
georgiek5015-Jun-03 12:58 
GeneralRe: Couple of questions concerning bits Pin
Harsha Gopal15-Jun-03 15:42
Harsha Gopal15-Jun-03 15:42 
GeneralRe: Couple of questions concerning bits Pin
georgiek5015-Jun-03 15:53
georgiek5015-Jun-03 15:53 
GeneralRe: Couple of questions concerning bits Pin
peterchen15-Jun-03 23:49
peterchen15-Jun-03 23:49 
GeneralText Object Model(Urgent) Pin
Asad Rasheed15-Jun-03 11:22
Asad Rasheed15-Jun-03 11:22 
GeneralRe: Text Object Model(Urgent) Pin
Ryan Binns15-Jun-03 17:55
Ryan Binns15-Jun-03 17:55 
QuestionHow Can i detect a radion button is clicked Pin
snipes15-Jun-03 11:14
snipes15-Jun-03 11:14 
AnswerRe: How Can i detect a radion button is clicked Pin
adamUK15-Jun-03 11:58
adamUK15-Jun-03 11:58 
GeneralRe: How Can i detect a radion button is clicked Pin
basementman16-Jun-03 4:20
basementman16-Jun-03 4:20 
GeneralWeb Browser control (questions) Pin
Member 43908315-Jun-03 10:29
Member 43908315-Jun-03 10:29 
GeneralRe: Web Browser control (questions) Pin
Tarundeep Singh Kalra16-Jun-03 3:53
Tarundeep Singh Kalra16-Jun-03 3:53 
GeneralRe: Web Browser control (questions) Pin
Member 43908316-Jun-03 13:07
Member 43908316-Jun-03 13:07 
GeneralRe: Web Browser control (questions) Pin
Neville Franks16-Jun-03 12:14
Neville Franks16-Jun-03 12:14 
GeneralRe: Web Browser control (questions) Pin
knappbl16-Jun-03 13:01
knappbl16-Jun-03 13:01 
GeneralRe: Web Browser control (questions) Pin
Member 43908316-Jun-03 13:08
Member 43908316-Jun-03 13:08 
GeneralRe: Web Browser control (questions) Pin
Neville Franks16-Jun-03 14:34
Neville Franks16-Jun-03 14:34 
QuestionHow do I get the Icon of a Window? Pin
LavosPhoenix15-Jun-03 6:49
LavosPhoenix15-Jun-03 6:49 

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.