Attribute VB_Name = "modHiLo" Option Explicit ' ' '============================================================================================================= ' ' modHiLo Module ' -------------- ' ' Created By : Kevin Wilson ' http://www.TheVBZone.com ( The VB Zone ) ' http://www.TheVBZone.net ( The VB Zone .net ) ' ' Last Update : September 01, 2000 ' ' VB Versions : 5.0 / 6.0 ' ' Requires : NOTHING ' ' Description : This module is meant to make getting the "High Order" and "Low Order" of a specified LONG ' or INTEGER value. This module also will take a BYTE or INTEGER "High Order" and "Low Order" ' value and properly combine them to make either an INTEGER or LONG value. Many Win32 API ' functions and callbacks make use of this to pass two pieces of information through one variable. ' For example, it's easier for an API to pass you one LONG variable that contains two INTEGER ' values representing an X and a Y coordinate in the High/Low Order of that LONG as compared to ' passing two LONG or INTEGER values. ' ' Win32 Def : ' ' #define LOWORD(l) ((WORD)(l)) ' #define HIWORD(l) ((WORD)(((DWORD)(l) >> 16) & 0xFFFF)) ' #define LOBYTE(w) ((BYTE)(w)) ' #define HIBYTE(w) ((BYTE)(((WORD)(w) >> 8) & 0xFF)) ' #define MAKEWORD(a, b) ((WORD)(((BYTE)(a)) | ((WORD)((BYTE)(b))) << 8)) ' #define MAKELONG(a, b) ((LONG)(((WORD)(a)) | ((DWORD)((WORD)(b))) << 16)) ' '============================================================================================================= ' ' LEGAL: ' ' You are free to use this code as long as you keep the above heading information intact and unchanged. Credit ' given where credit is due. Also, it is not required, but it would be appreciated if you would mention ' somewhere in your compiled program that that your program makes use of code written and distributed by ' Kevin Wilson (www.TheVBZone.com). Feel free to link to this code via your web site or articles. ' ' You may NOT take this code and pass it off as your own. You may NOT distribute this code on your own server ' or web site. You may NOT take code created by Kevin Wilson (www.TheVBZone.com) and use it to create products, ' utilities, or applications that directly compete with products, utilities, and applications created by Kevin ' Wilson, TheVBZone.com, or Wilson Media. You may NOT take this code and sell it for profit without first ' obtaining the written consent of the author Kevin Wilson. ' ' These conditions are subject to change at the discretion of the owner Kevin Wilson at any time without ' warning or notice. Copyright© by Kevin Wilson. All rights reserved. ' '============================================================================================================= ' Function that extracts the "Low Order" (lower 16bits) of a 32bit number Public Function LOWORD(ByVal dwValue As Long) As Integer LOWORD = Val("&H" & Right("0000" & Hex(dwValue), 4)) End Function ' Function that extracts the "High Order" (upper 16bits) of a 32bit number Public Function HIWORD(ByVal dwValue As Long) As Integer HIWORD = Val("&H" & Left(Right("00000000" & Hex(dwValue), 8), 4)) End Function ' Function that extracts the "Low Order" (lower 8bits) of a 16bit number Public Function LOBYTE(ByVal wValue As Integer) As Byte LOBYTE = Val("&H" & Right("00" & Hex(wValue), 2)) End Function ' Function that extracts the "High Order" (upper 8bits) of a 16bit number Public Function HIBYTE(ByVal wValue As Integer) As Byte HIBYTE = Val("&H" & Left(Right("0000" & Hex(wValue), 4), 2)) End Function ' Function that combines two 8bit numbers to make a 16bit number Public Function MAKEWORD(ByVal bHigh As Byte, ByVal bLow As Byte) As Integer MAKEWORD = Val("&H" & Right("00" & Hex(bHigh), 2) & Right("00" & Hex(bLow), 2)) End Function ' Function that combines two 16bit numbers to make a 32bit number Public Function MAKELONG(ByVal wHigh As Integer, ByVal wLow As Integer) As Long MAKELONG = Val("&H" & Right("0000" & Hex(wHigh), 4) & Right("0000" & Hex(wLow), 4)) End Function