C Struct -> Harbour Using Help!!

Post Reply
oknbs
Posts: 31
Joined: Wed Mar 19, 2008 8:52 am

C Struct -> Harbour Using Help!!

Post by oknbs »

Dear All

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

/* 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: C Struct -> Harbour Using Help!!

Post by Antonio Linares »

Are you returning pWaitParam to high level (PRG) ?

It is not in your code...

:-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
oknbs
Posts: 31
Joined: Wed Mar 19, 2008 8:52 am

Re: C Struct -> Harbour Using Help!!

Post by oknbs »

Thank you for your answer Antonio. :)

oknbs.
Post Reply