Serialcoder en Français Serialcoder in English
TEL : +33 (0)9 72 13 15 17

Windows Forms FAQ resources

12. Windows Forms from MFC

12.7 I need to encode the LParam argument of a mouse message. How do I do MakeLong , HiWord and LoWord type conversions?


You can create static methods that encode and decode these values. Here are some.

static int MakeLong(int LoWord, int HiWord)
{
     return (HiWord << 16) | (LoWord & 0xffff);
}
static IntPtr MakeLParam(int LoWord, int HiWord)
{
     return (IntPtr) ((HiWord << 16) | (LoWord & 0xffff));
}
static int HiWord(int Number)
{
     return (Number >> 16) & 0xffff;
}
static int LoWord(int Number)
{
     return Number & 0xffff;
}