BOOL ZDrOleClient::InterfaceConnect( IUnknown *pObj, REFIID riid, IUnknown *pIUnknownSink, LPDWORD pdwConn ) { TraceLineS( "ZDrOleClient::InterfaceConnect", "" ); HRESULT hr; IConnectionPointContainer *pCPointContainer = 0; IConnectionPoint *pCPoint = 0; if ( pObj == 0 || pIUnknownSink == 0 || pdwConn == 0 ) return( FALSE ); hr = pObj->QueryInterface( IID_IConnectionPointContainer, (LPVOID *) &pCPointContainer ); if ( FAILED( hr ) ) return( FALSE ); hr = pCPointContainer->FindConnectionPoint( riid, &pCPoint ); if ( SUCCEEDED( hr ) ) { hr = pCPoint->Advise( pIUnknownSink, pdwConn ); if ( hr == E_POINTER ) AfxMessageBox( "Invalid Pointer!" ); else if ( hr == CONNECT_E_ADVISELIMIT ) AfxMessageBox( "No more Connections available!" ); else if ( hr == CONNECT_E_CANNOTCONNECT ) AfxMessageBox( "No Connection!" ); pCPoint->Release( ); } else { if ( hr == E_OUTOFMEMORY ) TraceLineS( "FindConnectionPoint failed: ", "E_OUTOFMEMORY" ); else if ( hr == E_UNEXPECTED ) TraceLineS( "FindConnectionPoint failed: ", "E_UNEXPECTED" ); else if ( hr == E_POINTER ) TraceLineS( "FindConnectionPoint failed: ", "E_POINTER" ); else if ( hr == CONNECT_E_NOCONNECTION ) TraceLineS( "FindConnectionPoint failed: ", "CONNECT_E_NOCONNECTION" ); else if ( hr == S_OK ) TraceLineS( "FindConnectionPoint failed: ", "S_OK" ); else TraceLineX( "FindConnectionPoint failed: ", (zLONG) hr ); } pCPointContainer->Release( ); return( SUCCEEDED( hr ) ); } // InterfaceConnect
///////////////////////////////////////////////////////////////////////////// // // bSubcontrol - TRUE - add controls to existing pZSubtask->m_pZMIXCtrl // FALSE - delete existing pZSubtask->m_pZMIXCtrl and start // a new list // ///////////////////////////////////////////////////////////////////////////// void OPERATION CreateZeidonCtrls( zVIEW vSubobject, ZSubtask *pZSubtask, CWnd *pWndParent, ZMapAct *pzmaComposite, zSHORT nOffsetX, zSHORT nOffsetY, zBOOL bSubcontrol ) { zKZWDLGXO_Ctrl_DEF CtrlDef; zFARPROC_CONTROL lpfnCtrlProc; LPLIBRARY hCCtlLibrary; zPCHAR pchDLL_Name; zPCHAR pchCOP; zSHORT nRC; #ifdef DEBUG_ALL TraceLineX( "CreateZeidonCtrls parent - ", (zLONG) pZSubtask ); #endif nRC = CheckExistenceOfEntity( vSubobject, szlCtrl ); if ( bSubcontrol == FALSE ) { mDeleteInit( pZSubtask->m_pZMIXCtrl ); if ( nRC > zCURSOR_UNCHANGED ) { zLONG lTempCtrlCnt; // just to get the long temporarily GetIntegerFromAttribute( &lTempCtrlCnt, pZSubtask->m_vDialog, szlWnd, "CtrlCnt" ); // TraceLineI( "CreateZeidonCtrls count ", lTempCtrlCnt ); pZSubtask->m_pZMIXCtrl = new ZMultiIdxSet( (fnCOMPARE) fnCompareCtrlNodes, (fnCOMPARE) fnSeekCtrlNode, lTempCtrlCnt ); // Instead of having ZMultiIdxSet delete the nodes itself, we call // a recursive routine (fnDeleteCtrls) to guarantee the child // controls are deleted before their parents. } else pZSubtask->m_pZMIXCtrl = 0; CreateViewFromViewForTask( &(pZSubtask->m_vPE), pZSubtask->m_pZTask->m_vPE, pZSubtask->m_vDialog ); } #ifdef DEBUG_LODSTRUCT zmemset( CtrlDef.Tag, 0xFE, sizeof( CtrlDef ) ); // CtrlDef.CheckByte = 0xFE; #endif while ( nRC > zCURSOR_UNCHANGED ) { // Get the structure of attributes for this control. zPCHAR pch = 0; // for derived Text attribute GetStructFromEntityAttrs( (zPCHAR) CtrlDef.Tag, vSubobject, szlCtrl ); #ifdef DEBUG_LODSTRUCT if ( CtrlDef.CheckByte != 0xFE ) MessageBox( 0, "CtrlDef Structure Length Error", "GetStructFromEntityAttrs", MB_OK ); // zPCHAR pchCheckByte = (zPCHAR) &(CtrlDef.CheckByte); // pchCheckByte--; // if ( *pchCheckByte == (char) 0xFE ) // TraceLineS( "zdrctl CtrlDef CheckByte error??", "" ); #endif GetAddrForAttribute( (zPCHAR *) &pch, vSubobject, szlCtrl, szlD_Text ); if ( *pch ) zstrcpy( CtrlDef.Text, pch ); #ifdef DEBUG_ALL TraceLineS( "Tag ", CtrlDef.Tag ); TraceLineI( "Type ", CtrlDef.Type ); TraceLineI( "IdNbr ", CtrlDef.IdNbr ); TraceLineI( "PSDLG_X ", CtrlDef.PSDLG_X ); TraceLineI( "PSDLG_Y ", CtrlDef.PSDLG_Y ); TraceLineI( "SZDLG_X ", CtrlDef.SZDLG_X ); TraceLineI( "SZDLG_Y ", CtrlDef.SZDLG_Y ); #endif // The token is validated by the painter and/or conversion to // the executable object, but we check here anyway. nRC = SetCursorFirstEntityByInteger( pZSubtask->m_pZTask->m_vPE, szlCtrl, szlKey, CtrlDef.Type, 0 ); if ( nRC != zCURSOR_SET ) { TraceLine( "(drvr) ID (%d) not found (%d) in PPE for Ctrl: %s.%s.%s", CtrlDef.Type, nRC, pZSubtask->m_pzsDlgTag ? *(pZSubtask->m_pzsDlgTag) : "?", pZSubtask->m_pzsWndTag ? *(pZSubtask->m_pzsWndTag) : "?", CtrlDef.Tag ); DisplayEntityInstance( pZSubtask->m_pZTask->m_vPE, szlCtrl ); DisplayObjectInstance( pZSubtask->m_pZTask->m_vPE, 0, 0 ); // Skip this one and try the next. nRC = SetCursorNextEntity( vSubobject, szlCtrl, 0 ); continue; } GetAddrForAttribute( (zPCHAR *) &pchDLL_Name, pZSubtask->m_pZTask->m_vPE, szlCtrl, szlDLL ); GetAddrForAttribute( (zPCHAR *) &pchCOP, pZSubtask->m_pZTask->m_vPE, szlCtrl, szlCOP ); // If the DLL name is added to the list, this is the first time it // has been encountered ... so call its initialization routine. pZSubtask->m_pZTask->AddApplicationDLL( pZSubtask, pchDLL_Name ); hCCtlLibrary = 0; // set to zero for GetOperationDynamicCallAddress lpfnCtrlProc = (zFARPROC_CONTROL) GetOperationDynamicCallAddress( pZSubtask->m_vDialog, (LPLPLIBRARY) &hCCtlLibrary, pchDLL_Name, pchCOP, "(drvr) Ctrl" ); try { if ( lpfnCtrlProc ) // && (k % 2) == 0 ) { // TraceLineS( "Create Control: ", pchCOP ); (*lpfnCtrlProc)( pZSubtask, pWndParent, pzmaComposite, vSubobject, nOffsetX, nOffsetY, &CtrlDef ); } } #if 0 catch( CResourceException *e ) { zCHAR szMsg[ 256 ]; e->GetErrorMessage( szMsg, sizeof( szMsg ) ); zstrcat( szMsg, } #endif catch( CException *e ) { zCHAR szMsg[ 256 ]; e->GetErrorMessage( szMsg, sizeof( szMsg ) ); MessageSend( pZSubtask->m_vDialog, 0, "Zeidon Control", szMsg, zMSGQ_MODAL_ERROR, FALSE ); break; } nRC = SetCursorNextEntity( vSubobject, szlCtrl, 0 ); } // end of: while ( nRC == zCURSOR_UNCHANGED ) looping thru controls if ( bSubcontrol == FALSE ) { DropView( pZSubtask->m_vPE ); pZSubtask->m_vPE = 0; // using this to determine Ctrls have been created // Ctrl creation is complete ... notify each ctrl. if ( pZSubtask->m_pZMIXCtrl ) { pZSubtask->m_pZMIXCtrl->VisitInorder( (fnVISIT_INORDER) fnPostCreateCtrls, 0, 0, 0 ); } } }
//*********************************************************************** // // ENTRY: zNetStart // // PURPOSE: To initialize a network protocol. // // DESCR: This operation allocates a buffer to keep track of WinSock // information and calls WSAStartup to start the network. // // PARAMETERS: pszNetworkName - Unique internal 'Zeidon' name of the // network. // ppHandle - Void pointer that has been initialized to // null. The value of this pointer is passed // to all later network calls. This allows // initialization data to be passed to later // calls. // // RETURNS: 0 - Network started OK. // zCALL_ERROR - Error starting network. // //*********************************************************************** int PASCAL zNetStart( LPSTR pszNetworkName, LPVOID * ppHandle, HINSTANCE hInstance, HWND hwndTrace ) { WSADATA WSAData; int status; HGLOBAL hMemHandle; LPSOCKETS lpSockets; HWND hwnd; ghwndTrace = hwndTrace; *ppHandle = 0; if ( (status = WSAStartup( 0x0101, &WSAData ) ) != 0 ) { char szTemp[80]; wsprintf(szTemp, "Error loading starting WinSock: %d", status); MessageBox( 0, szTemp, szlErrorTitle, MB_OK ); return( zCALL_ERROR ); } TraceLineX( "(zwinsock) Task ID = ", (LONG) hInstance ); TraceLineX( "(zwinsock) WinSock Version = ", WSAData.wVersion ); TraceLineX( "(zwinsock) WinSock HighVersion = ", WSAData.wHighVersion ); TraceLineS( "(zwinsock) WinSock Description = ", WSAData.szDescription ); TraceLineS( "(zwinsock) System status = ", WSAData.szSystemStatus ); TraceLineI( "(zwinsock) Max sockets = ", WSAData.iMaxSockets ); TraceLineI( "(zwinsock) Max UPD datagram = ", WSAData.iMaxUdpDg ); if ( gnNetworkCount == 0 ) { WNDCLASS wc; memset( &wc, 0, sizeof( wc ) ); wc.style = 0; wc.lpfnWndProc = fnWinsockDlgProc; wc.hInstance = hInstance; wc.lpszClassName = "WinsockClientWindow"; if ( !RegisterClass( &wc ) ) { MessageBox( 0, "Error trying to create WinsockClientWindow class", szlErrorTitle, MB_OK ); WSACleanup( ); return( zCALL_ERROR ); } } gnNetworkCount++; hwnd = CreateWindow( "WinsockClientWindow", "Winsock Client Window", 0, // Window style. 0, 0, 100, 100, // Pos & size. HWND_DESKTOP, // Parent, 0, // Menu bar. hInstance, // 0 ); if ( hwnd == 0 ) { MessageBox( 0, "Error create Winsock Client Window", szlErrorTitle, MB_OK ); UnregisterClass( "WinsockClientWindow", hInstance ); WSACleanup( ); return( zCALL_ERROR ); } hMemHandle = GlobalAlloc( GPTR, sizeof( SocketsRecord ) ); if ( hMemHandle == 0 ) { char szTemp[ 80 ]; UnregisterClass( "WinsockClientWindow", hInstance ); DestroyWindow( hwnd ); WSACleanup( ); wsprintf( szTemp, "Out of memory starting network '%s'", pszNetworkName ); MessageBox( 0, szTemp, szlErrorTitle, MB_OK ); return( zCALL_ERROR ); } *ppHandle = GlobalLock( hMemHandle ); lpSockets = *ppHandle; lpSockets->hMemHandle = hMemHandle; lpSockets->hwndMain = hwnd; lpSockets->hwndTrace = hwndTrace; lpSockets->sockListen = INVALID_SOCKET; return( 0 ); } // zNetStart