#include #include #include using namespace std; int main() { unsigned char mask; // Print int variables in hex. cout << hex; // Perform bitwise And. // Used for clearing selected bits to 0. unsigned char x = 0xe6; mask = 0x2d; x &= mask; cout << setw(2) << setfill('0'); cout << "x == " << static_cast(x) << endl; // Perform bitwise Or. // Used for setting selected bits to 1. unsigned char y = 0xae; mask = 0x35; y |= mask; cout << setw(2) << setfill('0'); cout << "y == " << static_cast(y) << endl; // Perform bitwise XOr. // Used for toggling selected bits. unsigned char z = 0x87; mask = 0xde; z |= mask; cout << setw(2) << setfill('0'); cout << "z == " << static_cast(z) << endl; // Perform bitwise complement. // Used for toggling all bits. unsigned char w = 0x87; z = ~w; cout << setw(2) << setfill('0'); cout << "w == " << static_cast(w) << endl; cout << endl; // Print mask FWS_ADDTOTITLE. cout << "Add to title mask "; cout << setw(8) << setfill('0'); cout << FWS_ADDTOTITLE << endl; // Print left button mask. cout << "Left Button Mask "; cout << setw(8) << setfill('0'); cout << MK_LBUTTON << endl; // Print right button mask. cout << "Right Button Mask "; cout << setw(8) << setfill('0'); cout << MK_RBUTTON << endl; // Print middle button mask. cout << "Middle Button Mask "; cout << setw(8) << setfill('0'); cout << MK_MBUTTON << endl; // Print shift key mask. cout << "Shift Key Mask "; cout << setw(8) << setfill('0'); cout << MK_SHIFT << endl; // Print control key mask. cout << "Control Key Mask "; cout << setw(8) << setfill('0'); cout << MK_CONTROL << endl; cout << endl; unsigned int style = 0x00cfc000; unsigned int ADDTOTITLE_MASK = 0x00008000; style &= ~ADDTOTITLE_MASK; cout << "New value of style. "; cout << setw(8) << setfill('0'); cout << style << endl; return EXIT_SUCCESS; } // Output: // x == 24 // y == bf // z == df // w == 87 // // Add to title mask 00008000 // Left Button Mask 00000001 // Right Button Mask 00000002 // Middle Button Mask 00000010 // Shift Key Mask 00000004 // Control Key Mask 00000008 // // New value of style. 00cf4000