C Struct -> Harbour Using Help!!

C Struct -> Harbour Using Help!!

Postby oknbs » Mon Dec 10, 2012 5:51 pm

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  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
oknbs
 
Posts: 31
Joined: Wed Mar 19, 2008 8:52 am

Re: C Struct -> Harbour Using Help!!

Postby Antonio Linares » Tue Dec 11, 2012 10:32 am

Are you returning pWaitParam to high level (PRG) ?

It is not in your code...

:-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41366
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: C Struct -> Harbour Using Help!!

Postby oknbs » Thu Dec 13, 2012 3:42 am

Thank you for your answer Antonio. :)

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 52 guests