Chriss,
Here the relevant part of my code.
ptrCallback_cme=Thisform.HWnd
******Connecting to midi input and defining window callback*****
nResult = midiInOpen(@hDevice, nCmeIn-1, ptrCallback_cme, 0, CALLBACK_WINDOW+MIDI_IO_STATUS)
arrInHandles(1,1)=nCmeIn
arrInHandles(2,1)=hDevice
nResult2 =...