Page 3 of 3

Re: detect USB Device arrive/remove : how to use with harbour / HMG

Posted: Sun Feb 09, 2020 6:31 am
by AUGE_OHR
hi,

i found a Solution but not all is clear to me

Code: Select all

STATIC caItems := {}                                                  // for GRID
STATIC acImage := {}
STATIC aDrives
change PUBLIC to Field-wide STATIC have help with those Variable

Code: Select all

   nMainThreadID := GetCurrentThreadID()
   HMG_ThreadShareData( 1, Win_1.HANDLE )

   aThread[ 1 ] := hb_threadStart( HB_THREAD_INHERIT_PUBLIC, @Wait4Action() )
   aThread[ 2 ] := hb_threadStart( HB_THREAD_INHERIT_PUBLIC, @DoNothing() )

   AttachThreadInput( nMainThreadID, HMG_ThreadHBtoWinID( aThread[ 1 ] ), .T. )
   AttachThreadInput( nMainThreadID, HMG_ThreadHBtoWinID( aThread[ 2 ] ), .T. )

   CREATE EVENT PROCNAME USB_Detect() HWND Win_1.HANDLE STOREINDEX nIndex
   EventProcessAllHookMessage( nIndex, .T. )
here i have mix some Code ... donĀ“t ask me how it work ... but it work :D

Code: Select all

FUNCTION Wait4Action()
...
      Fillgrid()
      DO_Image( .T. )
these both use Code like this

Code: Select all

   Win_1.Grid_Device.hide()
   ...
   Win_1.Grid_Device.show()
so now i can go on with HBFM and include USB-Device