Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hiword and loword

Status
Not open for further replies.

Horrid

Programmer
May 20, 1999
373
I have a windowproc function that is returning a value that I must exract the hiword and loword from, but I cant find any definitions for hiword and loword that I understand

Found these defs in MSDN docs. They are declared in windef.h

#define HIWORD(l) ((WORD) (((DWORD) (l) >> 16) & 0xFFFF))
#define LOWORD(l) ((WORD) (l))

does anyone know how to declare these within VB so I can use these functions?

I tried this one
Public Declare Function Hiword Lib "windef" (ByVal dwValue As DWORD) As WORD, but windef can't be found, I checked the C file and it was just type definitions.

any help or even ideas would be most appreciated.
 
Not familiar with those terms, but the defines suggest theat you need to get the left | right 32 bits of a 64 bit value. A common approach to this is to define the original value, in the case probably as a double or long, and then define a byte array (0:7). Translate the Double / long to a string and 'pack' the bytes as characters into the byte array.
MichaelRed
redmsp@erols.com

There is never time to do it right but there is always time to do it over
 
Thanks,
I manages to find what I was looking for in the end, was on VBaccelerator

Public Property Get LoWord(ByRef lThis As Long) As Long
LoWord = (lThis And &HFFFF&)
End Property

Public Property Let LoWord(ByRef lThis As Long, ByVal lLoWord As Long)
lThis = lThis And Not &HFFFF& Or lLoWord
End Property

Public Property Get HiWord(ByRef lThis As Long) As Long
If (lThis And &H80000000) = &H80000000 Then
HiWord = ((lThis And &H7FFF0000) \ &H10000) Or &H8000&
Else
HiWord = (lThis And &HFFFF0000) \ &H10000
End If
End Property

Public Property Let HiWord(ByRef lThis As Long, ByVal lHiWord As Long)
If (lHiWord And &H8000&) = &H8000& Then
lThis = lThis And Not &HFFFF0000 Or ((lHiWord And &H7FFF&) * &H10000) Or &H80000000
Else
lThis = lThis And Not &HFFFF0000 Or (lHiWord * &H10000)
End If
End Property
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top