static UINT_PTR CALLBACK CCHookProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) { UINT_PTR res; HB_BOOL fInit = HB_FALSE; PHB_ITEM pBlock; if( msg == WM_INITDIALOG ) { CHOOSECOLOR * cc = ( CHOOSECOLOR * ) lParam; SetProp( hWnd, _HB_CHOOSECOLOR_CB_PROP_, hb_itemNew( ( PHB_ITEM ) cc->lCustData ) ); fInit = HB_TRUE; } if( ( pBlock = ( PHB_ITEM ) GetProp( hWnd, _HB_CHOOSECOLOR_CB_PROP_ ) ) != NULL && hb_vmRequestReenter() ) { PHB_ITEM pWnd = hbwapi_itemPut_HANDLE( NULL, hWnd ); PHB_ITEM pMsg = hb_itemPutNInt( NULL, msg ); PHB_ITEM pLPa = hb_itemPutNInt( NULL, wParam ); PHB_ITEM pWPa = hb_itemPutNInt( NULL, lParam ); hb_evalBlock( pBlock, pWnd, pMsg, pLPa, pWPa ); res = ( UINT_PTR ) hbwapi_par_RESULT( -1 ); hb_itemRelease( pWnd ); hb_itemRelease( pMsg ); hb_itemRelease( pLPa ); hb_itemRelease( pWPa ); if( msg == WM_NCDESTROY ) { RemoveProp( hWnd, _HB_CHOOSECOLOR_CB_PROP_ ); hb_itemRelease( pBlock ); } hb_vmRequestRestore(); } else res = 0; return fInit ? 1 : res; }
static INT_PTR CALLBACK hb_wvt_gtDlgProcModal( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) { PHB_GTWVT _s = hb_wvt_gtGetWVT(); INT_PTR lReturn = 0; if( _s ) { int iIndex, iType; PHB_ITEM pFunc = NULL; int iFirst = ( int ) lParam; if( iFirst > 0 && iFirst <= ( int ) HB_SIZEOFARRAY( _s->hDlgModal ) ) { _s->hDlgModal[ iFirst - 1 ] = hDlg; SendMessage( hDlg, WM_INITDIALOG, 0, 0 ); return lReturn; } iType = 0; for( iIndex = 0; iIndex < ( int ) HB_SIZEOFARRAY( _s->hDlgModal ); iIndex++ ) { if( _s->hDlgModal[ iIndex ] != NULL && _s->hDlgModal[ iIndex ] == hDlg ) { if( _s->pFuncModal[ iIndex ] != NULL ) { pFunc = _s->pFuncModal[ iIndex ]; iType = _s->iTypeModal[ iIndex ]; } break; } } if( pFunc ) { switch( iType ) { case 1: /* Function Name */ if( hb_vmRequestReenter() ) { hb_vmPushDynSym( ( PHB_DYNS ) pFunc ); hb_vmPushNil(); hbwapi_vmPush_HANDLE( hDlg ); hb_vmPushNumInt( message ); hb_vmPushNumInt( wParam ); hb_vmPushNumInt( lParam ); hb_vmDo( 4 ); lReturn = ( INT_PTR ) hbwapi_par_RESULT( -1 ); hb_vmRequestRestore(); } break; case 2: /* Block */ /* eval the codeblock */ if( HB_IS_EVALITEM( pFunc ) ) { if( hb_vmRequestReenter() ) { hb_vmPushEvalSym(); hb_vmPush( pFunc ); hbwapi_vmPush_HANDLE( hDlg ); hb_vmPushNumInt( message ); hb_vmPushNumInt( wParam ); hb_vmPushNumInt( lParam ); hb_vmSend( 4 ); lReturn = ( INT_PTR ) hbwapi_par_RESULT( -1 ); hb_vmRequestRestore(); } } else { /* TODO: internal error: missing codeblock */ } break; } switch( message ) { case WM_COMMAND: switch( LOWORD( wParam ) ) { case IDOK: EndDialog( hDlg, IDOK ); lReturn = 0; break; case IDCANCEL: EndDialog( hDlg, IDCANCEL ); lReturn = 0; break; } break; #if ! defined( HB_OS_WIN_CE ) case WM_NCDESTROY: #else case WM_DESTROY: #endif if( _s->pFuncModal[ iIndex ] != NULL && _s->iTypeModal[ iIndex ] == 2 ) hb_itemRelease( ( PHB_ITEM ) _s->pFuncModal[ iIndex ] ); _s->hDlgModal[ iIndex ] = NULL; _s->pFuncModal[ iIndex ] = NULL; _s->iTypeModal[ iIndex ] = 0; lReturn = 0; break; } } } return lReturn; }