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

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

User avatar
AUGE_OHR
Posts: 2061
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany

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

Post 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
have fun
Jimmy
Post Reply