C Struct -> Harbour Using Help!!
Harbour Function from C structure to assign a value.
The value read from the Harbour Function C struct is different.
1) passed Value: 10
2) read Value: 2
- Code: Select all Expand view
/* Harbour Sample Function */
Function Main()
...
oWnd:bCommNotify = { | pParam, nValue | EventNotify( pParam, nValue ) }
oThread := ThreadOn( 10, 20, oWnd:hWnd ) // Input Parameter 10, 20, oWnd:hWnd
Return nil
Function EventNotify( pParam, nValue )
MsgInfo( GetWaitData( pParam ) ) // Return Value 2
Return nil
/*---------------------------------------------------------------------------------------*/
/* C Function Sample Source */
typedef struct thread_param
{
long nParamNo;
int nIndexCode;
} THREAD_PARAM, *LPTHREAD_PARAM;
HB_FUNC( THREADON )
{
DWORD dwThreadID;
HANDLE hThread;
LPTHREAD_PARAM pWaitParam = ( LPTHREAD_PARAM ) hb_xgrab( sizeof( THREAD_PARAM ) );
memset( ( char * )pWaitParam, 0, sizeof( THREAD_PARAM ) );
pWaitParam->nParamNo = hb_parnl(1);
pWaitParam->nIndexCode = hb_parni(2);
CommNotifyHwnd = (HWND)hb_parnl( 3 );
hThread = CreateThread( NULL, 0, (LPTHREAD_START_ROUTINE)WaitThread, (LPVOID)pWaitParam, 0, &dwThreadID );
....
}
DWORD WINAPI WaitThread( LPVOID pVoid )
{
DWORD dwExitCode;
LPTHREAD_PARAM pWaitParam = (LPTHREAD_PARAM)pVoid;
SendMessage( CommNotifyHwnd, WM_COMMNOTIFY, (WPARAM)pWaitParam, (LPARAM)0 );
....
}
HB_FUNC( GETWAITDATA )
{
LPTHREAD_PARAM pWaitParam = (LPTHREAD_PARAM)hb_param( 1, HB_IT_ANY );
hb_retnl( pWaitParam->nParamNo );
}
Thanks