i have this Code with Xbase++ and Ot4xb
Code: Select all
delegated_eval( { || ot4xb_CreateGenericWindow( MyVolHandler( oDlg ) ) } )
#define WM_DEVICECHANGE 0x0219
#define DBT_DEVICEARRIVAL 0x8000 // A device or piece of media has been inserted and is now available.
#define DBT_DEVICEQUERYREMOVE 0x8001 // Permission is requested to remove a device or piece of media. Any application can deny this request and cancel the removal.
#define DBT_DEVICEREMOVECOMPLETE 0x8004 // A device or piece of media has been removed.
#define DBT_DEVNODES_CHANGED 0x0007 // A device has been added to or removed from the system.
#define DBT_DEVTYP_VOLUME 2
CLASS MyVolHandler
EXPORTED:
CLASS VAR oMain
INLINE METHOD init( oParent )
::oMain := oParent
RETURN self
INLINE CLASS METHOD wndproc( hWnd, nMsg, wp, lp, ctx )
LOCAL devType
LOCAL nRet := 0
LOCAL bError
IF nMsg == WM_DEVICECHANGE
DO CASE
CASE wp == DBT_DEVICEARRIVAL
bError := ErrorBlock( {|e| Break(e) } )
BEGIN SEQUENCE
devType := PeekDWord( lp, 4 )
IF devType == DBT_DEVTYP_VOLUME
nRet := ::OnNewVolume( hWnd, PeekDWord( lp, 12 ), PeekWord( lp, 16 ) )
IF nRet > 0
PostAppEvent(xbeSD_Arrive,nRet,,::oMain)
ENDIF
ENDIF
END SEQUENCE
ERRORBLOCK( bError )
RETURN NIL
CASE wp == DBT_DEVICEQUERYREMOVE
CASE wp == DBT_DEVICEREMOVECOMPLETE
bError := ErrorBlock( {|e| Break(e) } )
BEGIN SEQUENCE
devType := PeekDWord( lp, 4 )
IF devType == DBT_DEVTYP_VOLUME
nRet := ::OnRemoveVolume( hWnd, PeekDWord( lp, 12 ), PeekWord( lp, 16 ) )
PostAppEvent(xbeSD_Remove,nRet,,::oMain)
ENDIF
END SEQUENCE
ERRORBLOCK( bError )
RETURN NIL
CASE wp == DBT_DEVNODES_CHANGED
ENDCASE
RETURN NIL
ENDIF
RETURN NIL
but how to write it for harbour / HMG