Ejemplo n.º 1
0
static bool GetIntergraph( CFile& rFile, CString& rString, TOPOMAP& theMap ) {
	CRuntimeClass	*pRT;
	bool	bRet = false;
	if( NULL == ( pRT = GetPictureType( &rFile ) ) );
	CPicture	*pPict = (CPicture*) pRT->CreateObject();
	VERIFY( pPict->Attach( &rFile ) && pPict->ReadHeader() );
	long X0, Y0, X1, Y1;
	TAG	tag270;
	TAG tag33918;
	GetPictInfo( pPict, X0, Y0, X1, Y1);
	if( pPict->GetTag( 33918, tag33918 ) ) {
		long	nItems = tag33918.Count();
		if( ( 4 + 64 ) == nItems ) {
			IGTAG33918*	pData = (IGTAG33918*) tag33918.pVal();
			_ASSERTE(sizeof(theMap.m_transform.m_matrix) == sizeof(pData->dblVal) );
			memcpy( theMap.m_transform.m_matrix, pData->dblVal, sizeof(theMap.m_transform.m_matrix) );
			//////////////////////////////////////////////////////////////////
			// Karteninformation basteln
			theMap.m_sizeOfPicture.cx = X1;
			theMap.m_sizeOfPicture.cy = Y1;
			// GCP's: LinksUnten, RechtsUnten, RechtsOben, LinksOben
			theMap.m_listOfGCP.erase( theMap.m_listOfGCP.begin(), theMap.m_listOfGCP.end() );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT(  0, Y1, 0 ) ) );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT( X1, Y1, 0 ) ) );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT( X1,  0, 0 ) ) );
			theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( ),  GEOPOINT(  0,  0, 0 ) ) );
			bRet = true;
		}
	}
	delete pPict;
	return bRet;
}
Ejemplo n.º 2
0
bool CPluginParamDlg::CreateView()
{
	// create child view that contains parameter controls
	CRuntimeClass	*pFactory = RUNTIME_CLASS(CPluginParamView);
	m_View = DYNAMIC_DOWNCAST(CPluginParamView, pFactory->CreateObject());
	if (m_View == NULL) {
		AfxMessageBox(IDS_PLUGIN_CANT_CREATE_VIEW);
		return(FALSE);
	}
	CRect	rView;
	GetViewHolderRect(rView);
	DWORD	dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_BORDER;
    if (!m_View->Create(NULL, NULL, dwStyle, rView, this, 0, NULL)) {
		AfxMessageBox(IDS_PLUGIN_CANT_CREATE_VIEW);
		return(FALSE);
	}
	if (!m_View->InitRows(m_PluginPath, m_SampleRate)) {
		CString	msg;
		AfxFormatString2(msg, IDS_PLUGIN_CANT_LOAD, m_PluginPath,
			CWinAppEx::GetLastErrorString());
		AfxMessageBox(msg);
		return(FALSE);
	}
	if (m_Param.GetSize())
		m_View->SetParams(m_Param);
	SetWindowText(CString(m_View->GetDescriptor()->Name));
	return(TRUE);
}
Ejemplo n.º 3
0
STDMETHODIMP CPictHolder::OpenPictureFile(BSTR strPicture)
{
    Close();
    CString S( strPicture );
    if( !m_fileOfPicture.Open( S, CFile::modeRead | CFile::typeBinary ) )
        return E_FAIL;
    CRuntimeClass	*pRT;
    CPicture		*pPict = NULL;
    HRESULT	hr = E_FAIL;
    try {
        for(;;) {
            if( NULL == ( pRT = GetWritablePictureType( &m_fileOfPicture ) ) )
                break;
            pPict = (CPicture*) pRT->CreateObject();
            VERIFY( pPict->Attach( &m_fileOfPicture ) && pPict->ReadHeader() );
            m_pPicture = pPict;
            hr = S_OK;
            break;
        }
    } catch(...) {
        if( pPict )
            delete pPict;
        m_pPicture = NULL;
    }
    return hr;
}
Ejemplo n.º 4
0
static bool GetReferenced( CFile& rFile, CString& rString, TOPOMAP& theMap ) {
	CRuntimeClass	*pRT;
	if( NULL == ( pRT = GetPictureType( &rFile ) ) );
	CPicture	*pPict = (CPicture*) pRT->CreateObject();
	VERIFY( pPict->Attach( &rFile ) && pPict->ReadHeader() );
	long X0, Y0, X1, Y1;
	TAG	tag270;
	GetPictInfo( pPict, X0, Y0, X1, Y1);
	if( pPict->GetTag( 270, tag270 ) ) {
		rString = tag270.strVal();
	}
	delete pPict;
	//////////////////////////////////////////////////////////////////
	// Karteninformation basteln
	theMap.m_sizeOfPicture.cx = X1;
	theMap.m_sizeOfPicture.cy = Y1;
	// GCP's: LinksUnten, RechtsUnten, RechtsOben, LinksOben
	GEOPOINT	LO, RU;
	LO.X = 0; LO.Y = 0;
	RU.X = 0; RU.Y = 0;
	theMap.m_listOfGCP.erase( theMap.m_listOfGCP.begin(), theMap.m_listOfGCP.end() );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( LO.X, RU.Y, 0 ),  GEOPOINT(  0, Y1, 0 ) ) );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( RU.X, RU.Y, 0 ),  GEOPOINT( X1, Y1, 0 ) ) );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( RU.X, LO.Y, 0 ),  GEOPOINT( X1,  0, 0 ) ) );
	theMap.m_listOfGCP.push_back(  GCP( GEOPOINT( LO.X, LO.Y, 0 ),  GEOPOINT(  0,  0, 0 ) ) );
	return true;
}
Ejemplo n.º 5
0
/////////////////////////////////////////////////////////////////////////////
// 新建OWM对象ControlBar(for Xtreme)
/////////////////////////////////////////////////////////////////////////////
BOOL CPlugIn::NewOwmControlBar()
{
	if(m_pVciObj == NULL)
	{
		return FALSE;
	}

	IVciOwm* pIVciOwm = (IVciOwm*)m_pVciObj;
	CMultiDocTemplate* pDocTemplate = NULL;
	pIVciOwm->GetDocTemplate(&pDocTemplate);

	CRuntimeClass* pCtrlBarClass = NULL;
	pIVciOwm->GetRuntimeClass(4, &pCtrlBarClass);

	if(!pCtrlBarClass)
		return FALSE;

	if(m_pControlBar)
		return FALSE;

	// 此处已经修改为支持Xtreme
	CMainFrame* pMainFrame = (CMainFrame*)(AfxGetMainWnd());

	m_pControlBar = (CControlBar*)(pCtrlBarClass->CreateObject());

//	pMainFrame->EnableDockingEx(CBRS_ALIGN_ANY, CBRS_XT_FLAT);
//	pMainFrame->DockControlBar( pBar );

	return TRUE;
}
Ejemplo n.º 6
0
void CEditorRoot::SetEditTool( const CString &sEditToolName,bool bStopCurrentTool/*=true */ )
{
	CEditTool *pTool = GetEditTool();
	if (pTool && pTool->GetClassDesc())
	{
		if (stricmp(pTool->GetClassDesc()->ClassName(),sEditToolName) == 0)
			return;
	}

	IClassDesc *pClass = this->GetClassFactory()->FindClass( sEditToolName );
	if (!pClass)
	{
		//Warning( "Editor Tool %s not registered.",(const char*)sEditToolName );
		return;
	}
	if (pClass->SystemClassID() != ESYSTEM_CLASS_EDITTOOL)
	{
		//Warning( "Class name %s is not a valid Edit Tool class.",(const char*)sEditToolName );
		return;
	}
	CRuntimeClass *pRtClass = pClass->GetRuntimeClass();
	if (pRtClass && pRtClass->IsDerivedFrom(RUNTIME_CLASS(CEditTool)))
	{
		CEditTool *pEditTool = (CEditTool*)pRtClass->CreateObject();
		this->SetEditTool(pEditTool);
		return;
	}
	else
	{
		//Warning( "Class name %s is not a valid Edit Tool class.",(const char*)sEditToolName );
		return;
	}
}
Ejemplo n.º 7
0
CObject* CXMLArchiveNode::CreateObject(const CString& className)
{
	CRuntimeClass* pClass = NULL;

	// First see if the CRuntimeClass object is cached
	if (!m_classMap.Lookup(className, (void*&)pClass))
	{
		// Search app specific classes
		AFX_MODULE_STATE* pModuleState = AfxGetModuleState();

		for (pClass = pModuleState->m_classList; pClass != NULL; pClass = pClass->m_pNextClass)
		{
			if (className == pClass->m_lpszClassName)
			{
				m_classMap[className] = (void*&)pClass;
				break;
			}
		}
	}

	if (pClass == NULL)
	{
		TRACE1("You did not declare the class %s DECLARE_XMLSERIAL", (const char *)className);
		ASSERT(FALSE);
		return NULL;
	}

	return pClass->CreateObject();
}
Ejemplo n.º 8
0
CStaticDoc* CStaticDoc::CreateNewDocument( )
{
	CRuntimeClass *pDocClass = RUNTIME_CLASS(CStaticDoc);
	CStaticDoc* pDocument = (CStaticDoc*)pDocClass->CreateObject();
	if (pDocument == NULL)
	{
		TRACE1("Warning: Dynamic create of document type %hs failed.\n",
			pDocClass->m_lpszClassName);
		return NULL;
	}
	ASSERT_KINDOF(CStaticDoc, pDocument);
	return pDocument;
}
BOOL CImpactChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
	if(m_pwndImpact==NULL) {
		CRuntimeClass* pRuntimeClass = RUNTIME_CLASS(CImpactForm);
		CObject* pObject = pRuntimeClass->CreateObject();
		ASSERT( pObject->IsKindOf(RUNTIME_CLASS(CImpactForm)));
		m_pwndImpact=(CImpactForm *) pObject;
		CRect rcClient; 
		GetClientRect(rcClient);
		m_pwndImpact->Create(this,rcClient);
		m_pwndImpact->ShowWindow(SW_SHOW);
	}
	return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
Ejemplo n.º 10
0
CDialogGraphDen::CDialogGraphDen(CWnd* pParent /*=NULL*/)
	: CDialog(CDialogGraphDen::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogGraphDen)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT

	CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CGraphDView );
	CObject* pObject = pRuntimeClass->CreateObject();
	ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CGraphDView ) ) );


	m_pGDView=(CGraphDView *)pObject;

}
Ejemplo n.º 11
0
static bool ReduceOneMapFile( LPCTSTR lpszInFile, LPCTSTR lpszOutFile, PICTSAMPLEPARAM &fp, int level) 
{
	BOOL	bRet;
	CMemBlock	memInput( Size4MB );
	CMemBlock	memOutput( Size2MB );

	CRuntimeClass	*pInRT;
	CRuntimeClass	*pOutRT = NULL;

	CPicture		*pInPict;
	CPicture		*pOutPict;

	CFile		fileInput;
	CFile		fileOutput;


	CPictSample	filter;

	if( fileInput.Open( lpszInFile, CFile::modeRead | CFile::typeBinary ) ) {
		pInRT = ::GetWritablePictureType( &fileInput );
		if( NULL == pOutRT )
			pOutRT = pInRT;
		if( NULL != pInRT && NULL != ( pInPict = (CPicture*) pInRT->CreateObject() ) ) {
			if( fileOutput.Open( lpszOutFile, CFile::modeReadWrite | CFile::modeCreate | CFile::typeBinary ) ) {
				VERIFY( NULL != ( pOutPict = (CPicture*) pOutRT->CreateObject() ) );
				if( pInPict->Attach( &fileInput ) && pInPict->ReadHeader() ) {
					if( pOutPict->Attach( &fileOutput ) ) {
						switch( pInPict->GetBitsPerSample() ) {
						case 1 : fp.sampleParam = 0; break;
//						case 8 : fp.sampleParam = level > 2 ? 3 : 0; break;     // #HK050104
//						case 8 : fp.sampleParam = level <= 2 ? 3 : 0; break;     // #HK050120
						case 8 : fp.sampleParam = 3; break;     // #HK050120
						}
						filter.SetFilterData( &fp.p );
						bRet = filter.Filter( pInPict, pOutPict );
						pOutPict->Detach();
					}
					pInPict->Detach();
				}
				fileOutput.Close();
				delete pOutPict;
			}
			delete pInPict;
		}
		fileInput.Close();
	}
	return TRUE == bRet ? 1 : 0;
}
Ejemplo n.º 12
0
int CPatchBar::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CMySizingControlBar::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	m_Engine = &theApp.GetEngine();
	CRuntimeClass	*pFactory = RUNTIME_CLASS(CPatchView);
	m_View = DYNAMIC_DOWNCAST(CPatchView, pFactory->CreateObject());
	DWORD	dwStyle = AFX_WS_DEFAULT_VIEW;
    CRect r(0, 0, 0, 0);	// arbitrary initial size
    if (!m_View->Create(NULL, NULL, dwStyle, r, this, IDC_PATCH_VIEW, NULL))
		return -1;
	m_View->m_Parent = this;
	m_View->SetNotifyWnd(this);
	m_View->SetAccel(NULL, theApp.GetMain());
	m_View->CreateCols(COLUMNS, m_ColInfo, IDD_PATCH_ROW);
		
	return 0;
}
Ejemplo n.º 13
0
int MapInfo( const int argc, const char *argv[], istream& s_in, ostream& s_out, ostream& s_err ) {
	int		c;
	bool	bRaw = false;
	LPCTSTR	optarg;
	int		optind = 1;

	while( EOF != ( c = getopt( argc, argv, "rg?", optind, optarg ) ) ) {
		switch( c ) {
		case 'r' :	bRaw = true; break;
		case 'g' :	setlocale( LC_ALL, _T("German") ); break;
		case '?' :	Usage( s_err ); return TRUE;
		}
	}
	if( argc < optind ) {
		Usage( s_err );
		return FALSE;
	}
	CMemBlock		memPict( Size4MB );
	CRuntimeClass	*pRT;
	CPicture		*pPict;
	CFile			fileInput;
	for( ; optind < argc; optind++ ) {
		if( fileInput.Open( argv[optind], CFile::modeRead | CFile::typeBinary ) ) {
			pRT = ::GetPictureType( &fileInput );
			if( NULL != pRT && NULL != ( pPict = (CPicture*) pRT->CreateObject() ) ) {
				VERIFY( pPict->Attach( &fileInput ) && pPict->ReadHeader() );
				pPict->DumpTags( s_out, bRaw );
				pPict->Detach();
				delete pPict;
			} else {
				s_err << _T("cannot determine FileType: ") << argv[optind] << endl;
			}
			fileInput.Close();
		} else {
			s_err << _T("cannot open File: ") << argv[optind] << endl;
		}
	}
	return TRUE;
}
void CBCGPToolbarMenuButton::CopyFrom (const CBCGPToolbarButton& s)
{
	CBCGPToolbarButton::CopyFrom (s);

	const CBCGPToolbarMenuButton& src = (const CBCGPToolbarMenuButton&) s;

	m_bDefault = src.m_bDefault;
	m_bMenuOnly	= src.m_bMenuOnly;
	m_bIsRadio = src.m_bIsRadio;
	m_pWndMessage = src.m_pWndMessage;
	m_bMenuPaletteMode = src.m_bMenuPaletteMode;
	m_nPaletteRows = src.m_nPaletteRows;
	m_bQuickCustomMode = src.m_bQuickCustomMode;
	m_bShowAtRightSide = src.m_bShowAtRightSide;

	SetTearOff (src.m_uiTearOffBarID);

	while (!m_listCommands.IsEmpty ())
	{
		delete m_listCommands.RemoveHead ();
	}

	for (POSITION pos = src.m_listCommands.GetHeadPosition (); pos != NULL;)
	{
		CBCGPToolbarMenuButton* pItem = (CBCGPToolbarMenuButton*) src.m_listCommands.GetNext (pos);
		ASSERT (pItem != NULL);
		ASSERT_KINDOF (CBCGPToolbarMenuButton, pItem);

		CRuntimeClass* pSrcClass = pItem->GetRuntimeClass ();
		ASSERT (pSrcClass != NULL);

		CBCGPToolbarMenuButton* pNewItem = (CBCGPToolbarMenuButton*) pSrcClass->CreateObject ();
		ASSERT (pNewItem != NULL);
		ASSERT_KINDOF (CBCGPToolbarMenuButton, pNewItem);

		pNewItem->CopyFrom (*pItem);
		m_listCommands.AddTail (pNewItem);
	}
}
Ejemplo n.º 15
0
CChildFrame* CChildFrame::CreateNewFrame( CStaticDoc* pStaticDoc )
{
	if (pStaticDoc != NULL)
		ASSERT_VALID(pStaticDoc);
	// create a frame wired to the specified document

	ASSERT( pStaticDoc->GetIDResource() != 0); // must have a resource ID to load from
	CCreateContext context;
	context.m_pCurrentFrame = NULL;
	context.m_pCurrentDoc = NULL;		//pStaticDoc;
	context.m_pLastView = NULL;
	context.m_pNewViewClass = NULL; // pViewClass if this is set, a view will be created!
	context.m_pNewDocTemplate = NULL;

	CRuntimeClass* pFrameClass = RUNTIME_CLASS(CChildFrame);

	CChildFrame * pFrame = (CChildFrame*)pFrameClass->CreateObject();
	if (pFrame == NULL)
	{
		TRACE1("Warning: Dynamic create of frame %hs failed.\n",
			pFrameClass->m_lpszClassName);
		return NULL;
	}
	ASSERT_KINDOF(CChildFrame, pFrame);

	// create new from resource
	if (!pFrame->LoadFrame( pStaticDoc->GetIDResource(),
			WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,   // default frame styles
			AfxGetMainFrame(), &context))
	{
		TRACE0("Warning: Couldn't create a child frame.\n");
		// frame will be deleted in PostNcDestroy cleanup
		return NULL;
	}

	// it worked !
	return pFrame;
}
Ejemplo n.º 16
0
CDialogPlacePart::CDialogPlacePart(CWnd* pParent /*=NULL*/,DWORD dwType /*=0*/)
	: CDialog(CDialogPlacePart::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDialogPlacePart)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	int iData=IDD;
	m_dwType=dwType;
	m_bFlagNew=FALSE;				//clear new flag
	m_bFlagHdlItemChanged=TRUE;		//enables hadling of item changed event
	m_bFlagHdlItemChanged1=TRUE;	//disables handling of item changed event for 1 time
	m_bDragging = FALSE;			//for dragging operations

	//Create part viewer
	if(iData=IDD_PLACEPART2){

		CRuntimeClass* pRuntimeClass = RUNTIME_CLASS( CPartPView );
		CObject* pObject = pRuntimeClass->CreateObject();
		ASSERT( pObject->IsKindOf( RUNTIME_CLASS( CPartPView ) ) );

		m_pPPView=(CPartPView *)pObject;
		m_pPPView->SetPlacePartDlg(this);
	}
}
Ejemplo n.º 17
0
CWnd *CFrameWnd::CreateView( CCreateContext *pContext, UINT nID )
/***************************************************************/
{
    if( pContext == NULL ) {
        return( NULL );
    }

    CRuntimeClass *pClass = pContext->m_pNewViewClass;
    if( pClass == NULL ) {
        return( NULL );
    }

    CWnd *pView = (CWnd *)pClass->CreateObject();
    if( pView == NULL ) {
        return( NULL );
    }
    ASSERT( pView->IsKindOf( RUNTIME_CLASS( CWnd ) ) );

    if( !pView->Create( NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect( 0, 0, 0, 0 ),
                        this, nID, pContext ) ) {
        return( NULL );
    }
    return( pView );
}
//*********************************************************************
CBCGPGridItem* CCxNDArrayDimGrid::CreateItem (int nRow, int nColumn)
{
	CCxNDArrayDimItem* pItem = NULL;

	CRuntimeClass* pItemRTC = NULL;
	if (m_mapItemsRTC.Lookup (nColumn, pItemRTC))
	{
		ASSERT (pItemRTC != NULL);

		pItem = DYNAMIC_DOWNCAST (CCxNDArrayDimItem, pItemRTC->CreateObject ());
	}
	else if (m_pDefaultItemRTC != NULL)
	{
		pItem = DYNAMIC_DOWNCAST (CCxNDArrayDimItem, m_pDefaultItemRTC->CreateObject ());
	}
	else
	{
		pItem = new CCxNDArrayDimItem ();
	}

	if (pItem == NULL)
	{
		ASSERT (FALSE);
		return NULL;
	}

	ASSERT_VALID (pItem);
	
	if (!pItem->OnCreate (nRow, nColumn))
	{
		delete pItem;
		return NULL;
	}

	return pItem;
}
Ejemplo n.º 19
0
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{	
	CDocument *pDoc=NULL;
	POSITION pos;
	BOOL bRet = FALSE;
	//create the source view for this document at this time
	CRuntimeClass *prc = RUNTIME_CLASS(CSourceView);
	ENSURE(prc);
	m_pSrcView = (CSourceView*)prc->CreateObject();
	if(m_pSrcView)
		VERIFY(m_pSrcView->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW,
		CRect(0,0,0,0), this, AFX_IDW_PANE_LAST, NULL));


	//create the doc-template view and save off a pointer to it
	bRet = CFrameWnd::OnCreateClient(lpcs, pContext);
	pDoc = pContext->m_pCurrentDoc;
	if(bRet && pDoc)
	{
		pos = pDoc->GetFirstViewPosition();
		pDoc->AddView(m_pSrcView);
	}
	else
		return FALSE;

	CView *pView = pDoc->GetNextView(pos);
	ASSERT(pView->IsKindOf(RUNTIME_CLASS(CHTMLEdView)));
	if(pView)
	{
		m_pWebView = (CHTMLEdView*) pView;
	}
	else
		return FALSE;

	return bRet;
}
void CTraverseBySourceExchange::OnRecvSync(const uchar * data, int /*len*/, DWORD /*ip*/, WORD /*port*/)
{
	TRACE("Receive NAT Sync Request From Source Exchange!\n");

	//UINT realsize=len-1;// VC-linhai[2007-08-06]:warning C4189: “realsize” : 局部变量已初始化但不引用
	const uchar * realdata=data+1;

	DWORD cip = *(DWORD*)(realdata);
	WORD cport = *(WORD*)(realdata+4);

	if(cip==0 || cport==0)
	{
		return;
	}
	const uchar * id=realdata+6;

	DWORD ConnAck = 0;
	memcpy(&ConnAck, id+16, 4);

	TRACE("recv sync, ConnAck=%08x\n", ConnAck);
#ifdef _DEBUG
	in_addr addr;
	addr.s_addr = cip;
	TRACE("peer addr of %02X%02X%02X%02X = %s:%d\n", id[0], id[1], id[2],id[3],
		inet_ntoa(addr), ntohs(cport));
#endif
	uchar myid[16];
	GetMyUserHash(myid);
	if(memcmp(id, myid, 16)==0)
	{
		_AddLogLine(false, _T("ERROR: recv myself for traversal"));
		return;
	}

	CAsyncSocketEx * pASock=NULL;
	CUpDownClient * pClient= CGlobalVariable::clientlist->FindClientByUserHash(id);
	if(pClient)
	{
		pASock = pClient->socket;

		if(! pASock)
		{
			CRuntimeClass * pClassSocket = RUNTIME_CLASS(CClientReqSocket);
			CClientReqSocket * socket = static_cast<CClientReqSocket*>(pClassSocket->CreateObject());
			socket->SetClient(pClient);
			if (!socket->Create())
			{
				socket->Safe_Delete();
				return;
			}

			pClient->socket = socket;
			pASock = socket;
		}
		ASSERT(pASock);
		if(! pASock) 
		{
			return;
		}
	}
	else
	{
		TRACE("\n->%s: Accept a incoming sock for %02X%02X%02X%02X\n", __FUNCTION__,
			id[0],id[1],id[2],id[3]);

		pASock = CGlobalVariable::natthread->GetTempASock(id);
	}

	m_dwClientIp = cip;
	m_wClientPort = cport;

	m_dwState |=NAT_S_SYNC;
	SendPingPacket();
}
Ejemplo n.º 21
0
void CUSBLogView::OnEditPaste(void) 
{
    if(!IsClipboardFormatAvailable(GetApp().m_uClipboardFormat))
    {
        TRACE("OnEditPaste(): no suitable clipboard format available!\n");
        return;
    }

    // we need a focused URB as well...
    int nFocusedURB = m_Log.FindFocusedURB();
    if(-1 == nFocusedURB)
    {
        nFocusedURB = 0;
    }

    if(!AfxGetMainWnd()->OpenClipboard())
    {
        TRACE("Error while opening clipboard!\n");
        return;
    }
    // from here on, we have to close the clipboard
    // before exiting this function, otherwise other
    // applications might not get a chance to copy/paste
    // stuff!
    HANDLE hBinary = NULL;
    PVOID pData = NULL;
    try
    {
        hBinary = GetClipboardData(GetApp().m_uClipboardFormat);
        if(NULL == hBinary)
        {
            AfxThrowNotSupportedException();
        }

        pData = GlobalLock(hBinary);
        {
            CMyMemFile memFile(pData);
            CArchive ar(&memFile, CArchive::load);
            DWORD dwVersion = ar.ReadCount();
            if(_VERSION_DWORD_ != dwVersion)
            {
                AfxThrowNotSupportedException();
            }

            DWORD nURBCnt = ar.ReadCount();
            TRACE("Pasting %d URBs...\n", nURBCnt);
            
            CUSBLogDoc *pDoc = GetDocument();
            int nInsertLocation = nFocusedURB;
            while(0 < nURBCnt)
            {
                CRuntimeClass *pClass = ar.ReadClass();
                if(!pClass->IsDerivedFrom(RUNTIME_CLASS(CURB)))
                {
                    TRACE("unknown runtime class!\n");
                    AfxThrowArchiveException(CArchiveException::badClass);
                }

                CURB *pURB = (CURB*) pClass->CreateObject();
                ASSERT(NULL != pURB);
                pURB->SetChunkAllocator(&pDoc->m_arURB.m_ChunkAllocator);
                pURB->Serialize(ar);
                pDoc->m_arURB.InsertAt(nInsertLocation, pURB);
                nInsertLocation++;
                --nURBCnt;
            }
            pDoc->UpdateAllViews(NULL, 1);
            OnEditSelectNone();
            m_Log.SetFocusedURB(nFocusedURB);            
        }

        GlobalUnlock(hBinary);
        hBinary = NULL;

        CloseClipboard();
    }
    catch(...)
    {
        if((NULL != pData) && (NULL != hBinary))
        {
            GlobalUnlock(hBinary);
        }
        CloseClipboard();
        throw;
    }
}
Ejemplo n.º 22
0
CSettingsPage* XPageSettings()
{
	CRuntimeClass* pClass = RUNTIME_CLASS( CPlaySettingsPage );
	return (CSettingsPage*)pClass->CreateObject();
}
Ejemplo n.º 23
0
// Command line export function
void CCommandLineExport::CommandLineExport(const CString& fileIn, const CString& fileOut, const CString& fileLog,  const CString& fileDPCM)
{
	// open log
	bool bLog = false;
	CStdioFile fLog;
	if (fileLog.GetLength() > 0)
	{
		if(fLog.Open(fileLog, CFile::modeCreate | CFile::modeWrite | CFile::typeText, NULL))
			bLog = true;
	}

	// create CFamiTrackerDoc for export
	CRuntimeClass* pRuntimeClass = RUNTIME_CLASS(CFamiTrackerDoc);
	CObject* pObject = pRuntimeClass->CreateObject();
	if (pObject == NULL || !pObject->IsKindOf(RUNTIME_CLASS(CFamiTrackerDoc)))
	{
		if (bLog) fLog.WriteString(_T("Error: unable to create CFamiTrackerDoc\n"));
		return;
	}
	CFamiTrackerDoc* pExportDoc = static_cast<CFamiTrackerDoc*>(pObject);

	// open file
	if(!pExportDoc->OnOpenDocument(fileIn))
	{
		if (bLog)
		{
			fLog.WriteString(_T("Error: unable to open document: "));
			fLog.WriteString(fileIn);
			fLog.WriteString(_T("\n"));
		}
		return;
	}
	if (bLog)
	{
		fLog.WriteString(_T("Opened: "));
		fLog.WriteString(fileIn);
		fLog.WriteString(_T("\n"));
	}

	// find extension
	int nPos = fileOut.ReverseFind(TCHAR('.'));
	if (nPos < 0)
	{
		if (bLog)
		{
			fLog.WriteString(_T("Error: export filename has no extension: "));
			fLog.WriteString(fileOut);
			fLog.WriteString(_T("\n"));
		}
		return;
	}
	CString ext = fileOut.Mid(nPos);

	theApp.GetSoundGenerator()->GenerateVibratoTable(pExportDoc->GetVibratoStyle());

	// export
	if      (0 == ext.CompareNoCase(_T(".nsf")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportNSF(fileOut, pExportDoc->GetMachine() );
		if (bLog)
		{
			fLog.WriteString(_T("\nNSF export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".nes")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportNES(fileOut, pExportDoc->GetMachine() == PAL);
		if (bLog)
		{
			fLog.WriteString(_T("\nNES export complete.\n"));
		}
		return;
	}
	// BIN export requires two files
	else if (0 == ext.CompareNoCase(_T(".bin")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportBIN(fileOut, fileDPCM);
		if (bLog)
		{
			fLog.WriteString(_T("\nBIN export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".prg")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportPRG(fileOut, pExportDoc->GetMachine() == PAL);
		if (bLog)
		{
			fLog.WriteString(_T("\nPRG export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".asm")))
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportASM(fileOut);
		if (bLog)
		{
			fLog.WriteString(_T("\nASM export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".nsfe")))		// // //
	{
		CCompiler compiler(pExportDoc, bLog ? new CCommandLineLog(&fLog) : NULL);
		compiler.ExportNSFE(fileOut, pExportDoc->GetMachine());
		if (bLog)
		{
			fLog.WriteString(_T("\nNSFe export complete.\n"));
		}
		return;
	}
	else if (0 == ext.CompareNoCase(_T(".txt")))
	{
		CTextExport textExport;
		CString result = textExport.ExportFile(fileOut, pExportDoc);
		if (result.GetLength() > 0)
		{
			if (bLog)
			{
				fLog.WriteString(_T("Error: "));
				fLog.WriteString(result);
				fLog.WriteString(_T("\n"));
			}
		}
		else if (bLog)
		{
			fLog.WriteString(_T("Exported: "));
			fLog.WriteString(fileOut);
			fLog.WriteString(_T("\n"));
		}
		return;
	}
	else // use first custom exporter
	{
		CCustomExporters* pExporters = theApp.GetCustomExporters();
		if (pExporters)
		{
			CStringArray sNames;
			pExporters->GetNames(sNames);
			if (sNames.GetCount())
			{
				pExporters->SetCurrentExporter(sNames[0]);
				CFamiTrackerDocWrapper documentWrapper(CFamiTrackerDoc::GetDoc(), 0);
				bool bResult = (pExporters->GetCurrentExporter().Export(&documentWrapper, fileOut));
				if (bLog)
				{
					fLog.WriteString(_T("Custom exporter: "));
					fLog.WriteString(sNames[0]);
					fLog.WriteString(_T("\n"));
					fLog.WriteString(_T("Export "));
					fLog.WriteString(bResult ? _T("succesful: ") : _T("failed: "));
					fLog.WriteString(fileOut);
					fLog.WriteString(_T("\n"));
				}
				return;
			}
		}
	}

	if (bLog)
	{
		fLog.WriteString(_T("Error: unable to find matching export extension for: "));
		fLog.WriteString(fileOut);
		fLog.WriteString(_T("\n"));
	}
	return;
}
CActiveSourceWnd::CActiveSourceWnd(void):m_pContext(NULL)
{
	CRuntimeClass* pFactory = RUNTIME_CLASS(CActiveSourceView);
	m_pFormView = (CActiveSourceView *)(pFactory->CreateObject());	
}
Ejemplo n.º 25
0
BOOL CTestOutlineTextDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// Initialize the scroll view
	CRect rect;
	GetClientRect(&rect);
	CClientDC dc(this);
	int PosY = 190*dc.GetDeviceCaps(LOGPIXELSY)/96;
	int nMargin = 7*dc.GetDeviceCaps(LOGPIXELSY)/96;
	CRect rect2(nMargin,PosY,rect.Width()-nMargin*2,rect.Height()-nMargin-PosY);
	CRuntimeClass *pClass = RUNTIME_CLASS(CMyScrollView);
	m_pScrollView = (CMyScrollView*)pClass->CreateObject();
	m_pScrollView->Create(NULL, NULL, WS_CHILD | WS_VISIBLE, rect2, this, 10001);
	m_pScrollView->ModifyStyleEx(0, WS_EX_CLIENTEDGE);
	m_pScrollView->OnInitialUpdate();
	m_pScrollView->SetWindowPos(
		&m_staticShadowColor,
		nMargin,PosY,
		rect.Width()-nMargin*2,
		rect.Height()-nMargin-PosY,
		SWP_SHOWWINDOW);

	m_pScrollView->Render(false);

	// Initialize buttons
	COLORREF color= RGB(64,0,64);
	m_btnOutlineColor1.SetColor(color);
	m_pScrollView->SetOutlineColor1(Gdiplus::Color(GetRValue(color),GetGValue(color),GetBValue(color)));
	COLORREF color2= RGB(255,128,255);
	m_btnOutlineColor2.SetColor(color2);
	m_pScrollView->SetOutlineColor2(Gdiplus::Color(GetRValue(color2),GetGValue(color2),GetBValue(color2)));
	COLORREF colorText= RGB(255, 128, 64);
	m_btnTextColor.SetColor(colorText);
	m_pScrollView->SetTextColor1(Gdiplus::Color(GetRValue(colorText),GetGValue(colorText),GetBValue(colorText)));
	COLORREF colorText2= RGB(255,0,0);
	m_btnTextColor2.SetColor(colorText2);
	m_pScrollView->SetTextColor2(Gdiplus::Color(GetRValue(colorText2),GetGValue(colorText2),GetBValue(colorText2)));
	m_chkGradientText.SetCheck(1);
	m_pScrollView->EnableTextGradient(true);

	// initialize combo.
	m_cboTextEffect.AddString(_T("Single Outline"));
	m_cboTextEffect.AddString(_T("Double Outline"));
	m_cboTextEffect.AddString(_T("Text Glow"));
	m_cboTextEffect.AddString(_T("Gradient Outline"));
	m_cboTextEffect.AddString(_T("Just Outline"));
	m_cboTextEffect.AddString(_T("No Outline"));
	m_cboTextEffect.AddString(_T("Double Text Glow"));
	m_cboTextEffect.SetCurSel(3);
	m_pScrollView->SetTextEffect(GradOutline);
	EnableOutline2UI(TRUE, TRUE);
	m_cboTextPath.AddString(_T("GDI+"));
	m_cboTextPath.AddString(_T("GDI"));
	m_cboTextPath.SetCurSel(0);
	m_pScrollView->SetTextPath(GdiPlus);
	m_edtAngle.EnableWindow(FALSE);
	m_staticAngle.EnableWindow(FALSE);

	// Set the font
	//LOGFONT lf;
	memset(&m_lf, 0, sizeof(m_lf));
	m_lf.lfHeight = -48; //-MulDiv(48, dc.GetDeviceCaps(LOGPIXELSY), 72);
	m_lf.lfWeight = FW_NORMAL;
	//m_lf.lfItalic = TRUE;
	//m_lf.lfOrientation = 100;
	//m_lf.lfEscapement = 100;
	//m_lf.lfOutPrecision = OUT_TT_ONLY_PRECIS;
	m_lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
	m_lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
	m_lf.lfQuality = PROOF_QUALITY;

	wcscpy_s(m_lf.lfFaceName, _T("Arial Black"));
	m_edtFont.SetWindowText(_T("Arial Black, 36 Regular"));
	m_pScrollView->SetLogFont(&m_lf);
	m_pScrollView->SetFontSize(48);

	// Set the Text
	CString str = _T("TEXT DESIGNER");
	m_edtText.SetWindowText(str);
	m_pScrollView->SetText(str);

	// Set the Alphas
	m_edtOutlineAlpha1.SetWindowText(_T("255"));
	m_pScrollView->SetOutlineAlpha1(255);
	m_edtOutlineAlpha2.SetWindowText(_T("255"));
	m_pScrollView->SetOutlineAlpha2(255);

	// Set the Thickness
	m_edtThickness1.SetWindowText(_T("5"));
	m_pScrollView->SetOutlineThickness1(5);
	m_edtThickness2.SetWindowText(_T("5"));
	m_pScrollView->SetOutlineThickness2(5);

	// Set Text Position
	m_edtPosX.SetWindowText(_T("10"));
	m_pScrollView->SetTextPosX(10);
	m_edtPosY.SetWindowText(_T("10"));
	m_pScrollView->SetTextPosY(10);
	m_edtAngle.SetWindowText(_T("0"));
	m_pScrollView->SetTextAngle(0);

	// Set Shadow Properties
	m_chkEnableShadow.SetCheck(1);
	//m_pScrollView->SetEnableShadow(true);
	OnBnClickedChkEnableShadow();
	m_edtShadowAlpha.SetWindowText(_T("128"));
	m_pScrollView->SetShadowAlpha(128);
	m_edtShadowOffsetX.SetWindowText(_T("4"));
	m_pScrollView->SetShadowOffsetX(4);
	m_edtShadowOffsetY.SetWindowText(_T("4"));
	m_pScrollView->SetShadowOffsetY(4);
	m_btnShadowColor.SetColor(RGB(0,0,0));
	m_pScrollView->SetShadowColor(Gdiplus::Color(0,0,0));
	m_edtShadowThickness.SetWindowText(_T("8"));
	m_pScrollView->SetShadowThickness(8);
	m_chkDiffusedShadow.SetCheck(0);
	OnBnClickedChkDiffusedShadow();

	// PNG rendering
	m_chkPngRendering.SetCheck(0);
	OnBnClickedChkEnablePngRendering();

	m_chkExtrudedText.SetCheck(0);
	OnBnClickedChkExtrudedText();

	m_chkEnableReflection.SetCheck(0);
	m_chkEnableReflection.EnableWindow(FALSE);
	m_pScrollView->EnableReflection(false);
	m_btnReflectSettings.EnableWindow(FALSE);
	m_btnSavePng.EnableWindow(FALSE);
	m_btnSaveRefPng.EnableWindow(FALSE);

	//m_btnFont.EnableWindow(FALSE);

	m_pScrollView->Render(true);

	return TRUE;  // return TRUE  unless you set the focus to a control
}