void CCalcUnary::OnDeterminant() { // TODO: Add your control notification handler code here // TODO: Add your control notification handler code here UpdateData(); xpMatrix mtx; CWaitCursor wait; float ret = 0; //invert the matrix try { //CAllPages * pParent = STATIC_DOWNCAST(CAllPages, GetParent()); char buffer[255]; if (getMatrix(mtx) == TRUE) { wait.Restore( ); m_det = gcvt(mtx.getDet(),10, buffer); //m_det = _gcvt(mtx.getDet()); } UpdateData(false); //pParent->m_pMtx = &m_mtxResult; //pParent->SetActivePage(0); //pParent->m_calcResults.pGridCtrl->Refresh(); } catch (xpException * e) { CString errMess; e->getErrorMessage(errMess); MessageBox(errMess, "Matrix Calculation Error", MB_OK); e->Delete(); } }
void CCalcUnary::OnTranspose() { // TODO: Add your control notification handler code here UpdateData(); CString st1 = m_selValList1; xpMatrix mtx; CWaitCursor wait; try { if (getMatrix(mtx) == TRUE) { int r = mtx.getRowCount(); int c = mtx.getColumnCount(); wait.Restore( ); m_mtxResult = mtx.getTranspose(); } CAllPages * pParent = STATIC_DOWNCAST(CAllPages, GetParent()); pParent->m_pMtx->pDoc->m_mtx = &m_mtxResult; pParent->updateMtxList(); pParent->SetActivePage(0); } catch (xpException * e) { CString errMess; e->getErrorMessage(errMess); MessageBox(errMess, "Matrix Calculation Error", MB_OK); e->Delete(); } }
void CCalcUnary::OnInverse() { // TODO: Add your control notification handler code here UpdateData(); xpMatrix mtx; CWaitCursor wait; //invert the matrix try { CAllPages * pParent = STATIC_DOWNCAST(CAllPages, GetParent()); if (getMatrix(mtx) == TRUE) { wait.Restore( ); m_mtxResult = mtx.getInverse(); } pParent->m_pMtx->pDoc->m_mtx = &m_mtxResult; pParent->SetActivePage(0); pParent->m_calcResults.pGridCtrl->Refresh(); } catch (xpException * e) { CString errMess; e->getErrorMessage(errMess); MessageBox(errMess, "Matrix Calculation Error", MB_OK); e->Delete(); } }
// GME currently does not use this function // you only need to implement it if other invokation mechanisms are used STDMETHODIMP RawComponent::ObjectsInvokeEx( IMgaProject *project, IMgaObject *currentobj, IMgaObjects *selectedobjs, long param) { AFX_MANAGE_STATE( AfxGetStaticModuleState() ); if ( ! m_Facade.m_bEnabled ) return S_OK; COMTRY { CWaitCursor crsrWait; OCLUML::ConstraintVector vecConstraints; m_Facade.CheckAllConstraints( vecConstraints ); crsrWait.Restore(); if ( ! vecConstraints.empty() ) { CSyntacticSemanticDialog dlgErrors( AfxGetApp()->m_pActiveWnd ); for ( int i = 0 ; i < vecConstraints.size() ; i++ ) dlgErrors.AddItem( vecConstraints[ i ] ); dlgErrors.DoModal(); } m_Facade.Finalize(); } COMCATCH( ASSERT( 0 ); ) }
BOOL CXmasterApp::InitInstance() { CWaitCursor pCursor; #ifndef _DEBUG if ( SetFirstInstance() == FALSE ) return FALSE; #endif #ifdef _AFXDLL Enable3dControls(); #else Enable3dControlsStatic(); #endif SetRegistryKey( gcszCopyright ); GetVersionNumber(); AfxOleInit(); AfxEnableControlContainer(); CSplashDlg* dlgSplash = new CSplashDlg; dlgSplash->Topmost(); dlgSplash->Step( _T("Winsock") ); WSADATA wsaData; if ( WSAStartup( 0x0101, &wsaData ) ) return FALSE; dlgSplash->Step( _T("注册表") ); Settings.Load(); Profiles.Setup(); Skin.Apply(); dlgSplash->Step( _T("数据库") ); m_bInitialized = OpenDatabase(); dlgSplash->Step( _T(" 图形用户界面") ); m_pMainWnd = new CMainWnd(); CoolMenu.EnableHook(); CString strCaption; strCaption.LoadString( AFX_IDS_APP_TITLE ); m_pMainWnd->SetWindowText( (LPCTSTR)strCaption ); dlgSplash->Topmost(); m_pMainWnd->ShowWindow( SW_SHOWMAXIMIZED ); m_pMainWnd->UpdateWindow(); dlgSplash->Step( _T("网络") ); m_pMainWnd->SendMessage( WM_COMMAND, ID_NETWORK_CONNECT ); pCursor.Restore(); dlgSplash->Hide(); LogMessage( "程序启动", TRUE ); return TRUE; }
void CFindByStrDlg::OnOK() { // TODO: Add extra validation here try { UpdateData(TRUE); vector<CRossDoc*> RossDocs; if(GetCheckedRadioButton(IDC_FIND_IN_ALL_DICTS,IDC_FIND_IN_ACTIVE_DICT)==IDC_FIND_IN_ALL_DICTS) { CDocTemplate* pRossDocTemplate = GetRossDocTemplate(); POSITION pos = pRossDocTemplate->GetFirstDocPosition(); while( pos ) RossDocs.push_back ((CRossDoc*)pRossDocTemplate->GetNextDoc(pos)); } else { RossDocs.push_back(m_pActiveRossDoc); }; CWaitCursor C; vector<CRossPocketItem> PocketItems; for (int RossDocNo=0; RossDocNo<RossDocs.size(); RossDocNo++) { CRossDoc* pRossDoc = RossDocs[RossDocNo]; CTempArticle A; A.m_pRoss = pRossDoc->GetRoss(); size_t UnitNo; try { for (UnitNo = 0; UnitNo < pRossDoc->GetRoss()->GetUnitsSize(); UnitNo++) { if (pRossDoc->GetRoss()->IsEmptyArticle(UnitNo)) continue; A.ReadFromDictionary(UnitNo, false, true); if (A.GetArticleStr().find(m_FindString) != -1) PocketItems.push_back(CRossPocketItem(UnitNo, pRossDoc)); }; } catch (...) { string Mess = string ("Errors in article ") + pRossDoc->GetRoss()->GetEntryStr(UnitNo) ; AfxMessageBox (Mess.c_str()); }; }; C.Restore(); OpenPocket(PocketItems, CString("Search Results for ") + m_FindString); } catch (...) { AfxMessageBox ("Something is wrong"); }; CDialog::OnOK(); }
BOOL CXuser32App::InitInstance() { CWaitCursor pCursor; #ifndef _DEBUG if ( SetFirstInstance() == FALSE ) return FALSE; #endif Enable3dControls(); SetRegistryKey( gcszCopyright ); AfxOleInit(); AfxEnableControlContainer(); WSADATA wsaData; WSAStartup( 0x0101, &wsaData ); CString xUserId, xPassword; CheckUsage( xUserId, xPassword, m_bTestor ); CConnectDlg pConnect; if ( pConnect.DoModal(xUserId, xPassword) != IDOK ) return FALSE; //if ( pConnect.DoModal() != IDOK ) return FALSE; CSplashDlg* dlgSplash = new CSplashDlg; dlgSplash->Topmost(); dlgSplash->Step( _T("注册表") ); Settings.Load(); Skin.Apply(); dlgSplash->Step( _T("GUI") ); m_pMainWnd = new CMainWnd(); CoolMenu.EnableHook(); #if 0 CString strCaption; strCaption.LoadString( AFX_IDS_APP_TITLE ); m_pMainWnd->SetWindowText( (LPCTSTR)strCaption ); #else m_pMainWnd->SetWindowText( _T("96031城市总机") ); #endif dlgSplash->Topmost(); m_pMainWnd->ShowWindow( SW_SHOW ); m_pMainWnd->UpdateWindow(); dlgSplash->Step( _T("连接") ); m_pMainWnd->SendMessage( WM_COMMAND, ID_TAB_CONNECT ); dlgSplash->Hide(); pCursor.Restore(); return m_bInitialized = TRUE; }
void CDialogMistakes::OnDblclkListMistakesStandard(NMHDR* pNMHDR, LRESULT* pResult) { int nSelection = 0; if ((nSelection = m_listStandardMistakes.GetSelectionMark()) > -1){ CMistake* pMistake = (CMistake*)m_listStandardMistakes.GetItemData(nSelection); CWaitCursor wait; m_pBjDlg->LoadDlg(pMistake); m_pBjDlg->BringWindowToTop(); wait.Restore(); } *pResult = 0; }
BOOL SomeLengthyProcess() { CWaitCursor wait; //Do the lengthy processing. Sleep(1000); AfxMessageBox(_T("Some result")); //This changes the cursor. wait.Restore(); //Restore the Wait cursor. //Continue Processing. Sleep(1000); //The destructor changes the cursor back to Regular cursor. return TRUE; }
CheckVersion::CheckStatus CAboutDlg::CheckLatestVersion(std::wstring &latest) { CInternetSession session(L"PasswordSafe Version Check"); CStdioFile *fh; // Put up hourglass...this might take a while CWaitCursor waitCursor; try { // Loading the file as binary since we're treating it as UTF-8 fh = session.OpenURL(L"https://pwsafe.org/latest.xml", 1, (INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD)); } catch (CInternetException *) { // throw; return CheckVersion::CANT_CONNECT; } ASSERT(fh != NULL); CString latest_xml; unsigned char buff[BUFSIZ + 1]; StringX chunk; UINT nRead; CUTF8Conv conv; while ((nRead = fh->Read(buff, BUFSIZ)) != 0) { buff[nRead] = '\0'; // change to widechar representation if (!conv.FromUTF8(buff, nRead, chunk)) { fh->Close(); delete fh; session.Close(); return CheckVersion::CANT_READ; } else latest_xml += chunk.c_str(); } fh->Close(); delete fh; session.Close(); waitCursor.Restore(); // restore normal cursor CheckVersion vh(m_nMajor, m_nMinor, m_nBuild); return vh.CheckLatestVersion(LPCWSTR(latest_xml), latest); }
BOOL CXphoneApp::InitInstance() { CWaitCursor pCursor; if ( ! SetFirstInstance() ) return FALSE; CString xUserId, xPassword; if ( ! CheckUsage( xUserId, xPassword ) ) return FALSE; Enable3dControls(); SetRegistryKey( gcszCopyright ); GetVersionNumber(); AfxOleInit(); AfxEnableControlContainer(); CSplashDlg* dlgSplash = new CSplashDlg; dlgSplash->Topmost(); dlgSplash->Step( _T("Winsock") ); WSADATA wsaData; if ( WSAStartup( 0x0101, &wsaData ) ) return FALSE; dlgSplash->Step( _T("注册表") ); Settings.Load(); Skin.Apply(); dlgSplash->Step( _T("GUI") ); m_pMainWnd = new CConnectDlg; CoolMenu.EnableHook(); dlgSplash->Topmost(); m_pMainWnd->ShowWindow( SW_SHOWNORMAL ); // m_pMainWnd->BringWindowToTop(); dlgSplash->Step( _T("连接") ); m_pMainWnd->SendMessage( WM_COMMAND, ID_NETWORK_CONNECT ); dlgSplash->Hide(); pCursor.Restore(); return m_bInitialized = TRUE; }
//--------------------------------------------------------------------------- // 印刷の実行 int __fastcall TPrintDlgBox::Execute(void) { if( (!mColCount) || (!mRowCount) ) return FALSE; int r = FALSE; if( PrintDialog->Execute() == TRUE ){ TForm *pActive = Screen->ActiveForm; if( pActive != NULL ) pActive->Enabled = FALSE; mAbort = 0; CWaitCursor tw; Printer()->Title = "MMANA"; Printer()->BeginDoc(); Printer()->Canvas->Font->Name = "MS ゴシック"; mRC = Printer()->Canvas->ClipRect; if( InitSetup(Printer()->Canvas) == FALSE ){ mAbort = 1; } tw.Delete(); if( !mAbort ){ Show(); for( mPage = 0; mPage < mPageMax; mPage++ ){ // 印刷ループ if( mPage ) Printer()->NewPage(); DispPageStat(); Application->ProcessMessages(); if( mAbort ) break; DrawRect(); Application->ProcessMessages(); if( mAbort ) break; DrawPage(); Application->ProcessMessages(); if( mAbort ) break; } } tw.Wait(); if( mAbort ){ Printer()->Abort(); } else { Printer()->EndDoc(); r = TRUE; } if( pActive != NULL ) pActive->Enabled = TRUE; Visible = FALSE; } return r; }
void CReagentAreaCtrl::OnClickMenuReagentSelect() { ReagentConfigNode *pNode = m_pReagentData->GetNode(m_HoverPos); CWaitCursor wait; // 弹出试剂选择对话框 Reagent_Key key = pNode->ReagentID; CReagentSelectDlg dlg(key); dlg.DoModal(); wait.Restore(); // 判断取得的试剂ID if(key > 0) { // 设置数据 pNode->IsSetingReagent = true; pNode->ReagentID = key; // 重绘焦点位置 _InvalidPos(m_HoverPos); // 告诉“试剂区数据”对象,重绘所有视图 m_pReagentData->SpreadUpdateMessage(0); } }
STDMETHODIMP RawComponent::ObjectEvent(IMgaObject * obj, unsigned long eventmask, VARIANT v) { AFX_MANAGE_STATE( AfxGetStaticModuleState() ); if ( ! m_Facade.m_bEnabled ) return S_OK; CWnd* pMainWindow = AfxGetApp()->m_pActiveWnd; COMTRY { if( ( eventmask & OBJEVENT_ATTR ) || ( eventmask & OBJEVENT_CONNECTED ) ) { CComQIPtr<IMgaFCO> spFCO = obj; if( spFCO ) { std::string strKind = GME::GetObjectKind( spFCO.p ); if ( strKind == "Constraint" ) { CWaitCursor crsrWait; OCLUML::ConstraintVector vecConstraints; m_Facade.CheckConstraint( spFCO.p, vecConstraints, false ); if ( ! vecConstraints.empty() ) { CSyntacticSemanticDialog dlgErrors( pMainWindow ); for ( int i = 0 ; i < vecConstraints.size() ; i++ ) dlgErrors.AddItem( vecConstraints[ i ] ); crsrWait.Restore(); dlgErrors.DoModal(); } else crsrWait.Restore(); } if ( strKind == "ConstraintDefinition" ) { CWaitCursor crsrWait; OCLUML::ConstraintDefVector vecConstraintDefinitions; m_Facade.CheckConstraintDefinition( spFCO.p, vecConstraintDefinitions, false ); if ( ! vecConstraintDefinitions.empty() ) { CSyntacticSemanticDialog dlgErrors( pMainWindow ); for ( int i = 0 ; i < vecConstraintDefinitions.size() ; i++ ) dlgErrors.AddItem( vecConstraintDefinitions[ i ] ); crsrWait.Restore(); dlgErrors.DoModal(); } else crsrWait.Restore(); } m_Facade.Finalize(); } } } COMCATCH( ASSERT( 0 ); ) }
void DboxMain::ImportFilters() { CString cs_title, cs_temp, cs_text; cs_text.LoadString(IDS_PICKXMLFILE); const std::wstring XSDfn(L"pwsafe_filter.xsd"); std::wstring XSDFilename = PWSdirs::GetXMLDir() + XSDfn; if (!pws_os::FileExists(XSDFilename)) { CGeneralMsgBox gmb; cs_temp.Format(IDSC_MISSINGXSD, XSDfn.c_str()); cs_title.LoadString(IDSC_CANTVALIDATEXML); gmb.MessageBox(cs_temp, cs_title, MB_OK | MB_ICONSTOP); return; } std::wstring dir; if (m_core.GetCurFile().empty()) dir = PWSdirs::GetSafeDir(); else { std::wstring cdrive, cdir, dontCare; pws_os::splitpath(m_core.GetCurFile().c_str(), cdrive, cdir, dontCare, dontCare); dir = cdrive + cdir; } CPWFileDialog fd(TRUE, L"xml", NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_LONGNAMES, CString(MAKEINTRESOURCE(IDS_FDF_XML)), this); fd.m_ofn.lpstrTitle = cs_text; if (!dir.empty()) fd.m_ofn.lpstrInitialDir = dir.c_str(); INT_PTR rc = fd.DoModal(); if (m_inExit) { // If U3ExitNow called while in CPWFileDialog, // PostQuitMessage makes us return here instead // of exiting the app. Try resignalling PostQuitMessage(0); return; } if (rc == IDCANCEL) return; if (rc == IDOK) { std::wstring strErrors; CString XMLFilename = fd.GetPathName(); CWaitCursor waitCursor; // This may take a while! MFCAsker q; rc = m_MapFilters.ImportFilterXMLFile(FPOOL_IMPORTED, L"", std::wstring(XMLFilename), XSDFilename.c_str(), strErrors, &q); waitCursor.Restore(); // Restore normal cursor UINT uiFlags = MB_OK | MB_ICONWARNING; switch (rc) { case PWScore::XML_FAILED_VALIDATION: cs_temp.Format(IDS_FAILEDXMLVALIDATE, fd.GetFileName(), strErrors.c_str()); break; case PWScore::XML_FAILED_IMPORT: cs_temp.Format(IDS_XMLERRORS, fd.GetFileName(), strErrors.c_str()); break; case PWScore::SUCCESS: if (!strErrors.empty()) { std::wstring csErrors = strErrors + L"\n"; cs_temp.Format(IDS_XMLIMPORTWITHERRORS, fd.GetFileName(), csErrors.c_str()); } else { cs_temp.LoadString(IDS_FILTERSIMPORTEDOK); uiFlags = MB_OK | MB_ICONINFORMATION; } break; default: ASSERT(0); } // switch CGeneralMsgBox gmb; cs_title.LoadString(IDS_STATUS); gmb.MessageBox(cs_temp, cs_title, uiFlags); } }
// CResonanceStudioDraw drawing // Note the top left is origen void ResonanceStudioDraw::Draw(HWND m_hWnd, RECT rc, CResonanceStudioDoc *pDoc ) { CWaitCursor wait; clientRectangle = rc; pTheCoordinator = pDoc->GetCoordinator(); if ( pTheCoordinator == nullptr ) { return; } ptheParameterPack = pTheCoordinator->GetParameterPack(); ptheFrequencyScale = ptheParameterPack->GetFrequencyScale(); CPropertiesWnd *pthePropertiesWnd = &(pTheMainFrame->m_wndProperties); pthePropertiesWnd->SetOutputStatus(); SetPalette(); HRESULT hr = CreateGraphicsResources(m_hWnd, rc); if (SUCCEEDED(hr)) { pRenderTarget->BeginDraw(); // set the background and force a paint while we do our procesing pRenderTarget->Clear(backgroundColor); if ( pTheCoordinator->ProcessAndGetWICBitmap( &pWICBitmap ) ) { // nothing to do. need actual screen size in renderTarget to map } // Get display times and other information highFrequencyLimit = ptheParameterPack->GetFilterHigh(); lowFrequencyLimit = ptheParameterPack->GetFilterLow(); rectangleSize = pRenderTarget->GetSize(); dataBottom = rectangleSize.height; dataTop = audioScreenFraction * rectangleSize.height; if (pWICBitmap != nullptr ) { // Copy WIC bitmap to ID2D1 bitmap hr = pRenderTarget->CreateBitmapFromWicBitmap( pWICBitmap, NULL, &pbitmap ); time0 = pTheCoordinator->GetCurrentDisplayStartTime(); time1 = pTheCoordinator->GetCurrentDisplayEndTime(); double rate = pTheCoordinator->GetSamplingRate(); SetStatus( time0, time1 ); SetPixelTimeGrid( time1-time0, rate ); // Use top 20% of screen for audio //const double xAxis = 0.1 * rectangleSize.height; double vScale = 0.2 * rectangleSize.height ; DrawAudioLine( 0.0, vScale ); // Display the bitmap. Collect rectangle data first. Display to bottom section, below audio UINT uiWidth = 0; UINT uiHeight = 0; pWICBitmap->GetSize( &uiWidth, &uiHeight ); D2D1_RECT_F sourceRectangle; CPropertiesWnd *pthePropertiesWnd = &(pTheMainFrame->m_wndProperties); if ( pthePropertiesWnd->GetFullScreenOrPan() == "Pan" ) { // Limit travel float x = (float) panViewCorner.x; float y = (float) panViewCorner.y; x = max( x, 0.0f ); y = max( y, 0.0f ); x = min( x, uiWidth - rectangleSize.width ); y = min( y, uiHeight - rectangleSize.height ); sourceRectangle = D2D1::RectF(x, y, x + rectangleSize.width, y + rectangleSize.height); } else { sourceRectangle = D2D1::RectF(0.0f, 0.0, (float) uiWidth, (float) uiHeight); } D2D1_RECT_F destinationRectangle = D2D1::RectF( 0.0f, (float) vScale, rectangleSize.width, rectangleSize.height); pRenderTarget->DrawBitmap(pbitmap, destinationRectangle,1.0F,D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, sourceRectangle); ptheDrawTimeFrequencyGrid->Draw( pRenderTarget, D2D1::RectF(0.0, (float) dataTop, rectangleSize.height, (float) dataBottom ), ptheParameterPack, time0, time1 ); } hr = pRenderTarget->EndDraw(); wait.Restore(); DiscardGraphicsResources(); } }
void CADQIDlg::OnDblClkInterfaces() { CString s; int xx=0; int idx; IUnknown *pNewUnk = NULL; idx = m_cListIf.GetCurSel(); if ( idx == LB_ERR ) { MessageBeep(0); return; } CWaitCursor wait; m_cListIf.GetText( idx, s ); ////////////////////////////////////////////////////////////// // // Find the appropriate dialog box to display // ///////////////////////////////////////////////////////////////// while( !IsEqualIID( *adsiIfs[xx].pIID, IID_NULL ) && s != adsiIfs[xx].szIf ) { xx++; } ASSERT( !IsEqualIID( *adsiIfs[xx].pIID, IID_NULL ) ); if ( adsiIfs[xx].pFn ) { m_pUnk->AddRef(); (*adsiIfs[xx].pFn)( m_pUnk, &pNewUnk ); } else { wait.Restore(); AfxMessageBox(_T("No UI implemented yet")); } //////////////////////////////////////////////////// // if IADsOpenObject is selected, special care /////////////////////////////////////////////////// if ( pNewUnk ) { HRESULT hr; BSTR bstr; IADs *pADs; hr = pNewUnk->QueryInterface( IID_IADs, (void**) &pADs ); if ( SUCCEEDED(hr) ) { pADs->get_ADsPath( &bstr ); } pADs->Release(); m_sADsPath = bstr; SysFreeString( bstr ); m_pUnk->Release(); // old ads iunknown path; m_pUnk = pNewUnk; UpdateData(FALSE); EnumerateInterface(); } }
void CModel::Resequence(bool bReScanASEFiles /* = false */) { CWaitCursor wait; CRect Rect; CProgressCtrl *pProgress = NULL; if (bReScanASEFiles && ((CAssimilateApp*)AfxGetApp())->m_pMainWnd) { pProgress = new CProgressCtrl; bool bOK = !!pProgress->Create( WS_CHILD|WS_VISIBLE|PBS_SMOOTH, // DWORD dwStyle, CRect(100,100,200,200), // const RECT& rect, ((CAssimilateApp*)AfxGetApp())->m_pMainWnd, // CWnd* pParentWnd, 1 // UINT nID ); if (!bOK) { delete pProgress; pProgress = NULL; } } int iTotMasterSequences = GetTotMasterSequences(); if (pProgress) { pProgress->SetRange(0,iTotMasterSequences); } int iSequenceNumber=0; int curFrame = 0; CSequence* curSequence = m_sequences; while(curSequence != NULL) { if (pProgress) { pProgress->SetPos(iSequenceNumber++); wait.Restore(); } // mark current enums as valid or not... curSequence->SetValidEnum(((CAssimilateApp*)AfxGetApp())->ValidEnum(curSequence->GetEnum())); for (int _i=0; _i<MAX_ADDITIONAL_SEQUENCES; _i++) { CSequence *additionalSeq = curSequence->AdditionalSeqs[_i]; additionalSeq->SetValidEnum(((CAssimilateApp*)AfxGetApp())->ValidEnum(additionalSeq->GetEnum())); } if ( bReScanASEFiles ) { // new code, first of all check for changed framecounts (ie updated ASE file), and update sequence if nec... CString nameASE = ((CAssimilateApp*)AfxGetApp())->GetQuakeDir(); nameASE+= curSequence->GetPath(); if (!FileExists(nameASE)) { if (gbCarWash_DoingScan) { strCarWashErrors += va("Model file missing: \"%s\"\n",nameASE); } else { if ( gbReportMissingASEs ) { gbReportMissingASEs = GetYesNo(va("Model file missing: \"%s\"\n\nContinue recieving this message?",nameASE)); } } } else { int iStartFrame, iFrameCount, iFrameSpeed; iFrameCount = curSequence->GetFrameCount(); // default it in case we skip an XSI read iFrameSpeed = curSequence->GetFrameSpeed(); // default it in case we cache this file curSequence->ReadASEHeader( nameASE, iStartFrame, iFrameCount, iFrameSpeed, true); // true = can skip XSI read if ( iFrameCount != curSequence->GetFrameCount() ) { if (gbCarWash_DoingScan) { strCarWashErrors += va("file: \"%s\" has a framecount of %d, but .CAR file says %d\n",nameASE,iFrameCount,curSequence->GetFrameCount()); } else { // don't mention it if the current count is zero, it's probably a new anim we've just added... if ( curSequence->GetFrameCount() ) { if (giFixUpdatedASEFrameCounts == YES || giFixUpdatedASEFrameCounts == NO) { CYesNoYesAllNoAll query( va("Model file: \"%s\"",nameASE), "", va("... has a framecount of %d instead of %d as the QDT/CAR file says",iFrameCount, curSequence->GetFrameCount()), "", "", "Do you want me to fix this?" ); giFixUpdatedASEFrameCounts = query.DoModal(); } } // update the sequence?... if (giFixUpdatedASEFrameCounts == YES || giFixUpdatedASEFrameCounts == YES_ALL || !curSequence->GetFrameCount() // update: I think this should be here? ) { curSequence->SetFrameCount( iFrameCount ); } } } } // findmeste: this no longer seems to do anything under JK2, presumablt EF1-only? #if 0 // now try to do any auto-associate between the ASE filename base and the existing enums, // so if we find (eg) /...../...../CROUCH.ASE and we have BOTH_CROUCH then auto-set the enum to BOTH_CROUCH CString stringASEName = nameASE; Filename_BaseOnly(stringASEName); // now = (eg) "falldeath" or "injured" etc for (int i=0; ; i++) { LPCSTR p = ((CAssimilateApp*)AfxGetApp())->GetEnumEntry(i); if (!p) // EOS? break; CString stringEnum = p; // note, I could check stuff like "IsEnumSeperator(LPCSTR lpString)" on <p>, but you'd never // have one of those enums assigned to a sequence anyway. char *psEnumPosAfterUnderScore = strchr(stringEnum,'_'); if (psEnumPosAfterUnderScore++) // check it, and skip to next char { // does this enum match the ASE name? if ( !stricmp( psEnumPosAfterUnderScore, stringASEName ) ) { // ok, we've found a good candidate, so set it... (no need for query-prev code, but I wanted to) if ( strcmp( curSequence->GetEnum(), stringEnum)) { curSequence->SetEnum(stringEnum); } } } else { // this should never happen... if (gbCarWash_DoingScan) { strCarWashErrors += va("found an anim enum with no underscore: \"%s\"\n",stringEnum); } else { ASSERT(0); ErrorBox(va("Error! Somehow I found an anim enum with no underscore: \"%s\"",stringEnum)); } } } #endif } // More bollox for Gummelt... :-) // now do the other freaky trick (you'd better be grateful for all this Mike!!! <g>), which is: // If you find the substring DEATH in this (master) sequence's enum, then ensure that the first *additional* // sequence of it is set to be the corresponding DEAD enum, but using the last frame only (and non-looping) // // (... or something...) { // keep scope local for neatness if ( strstr (curSequence->GetEnum(), "DEATH") ) { // scan this sequence's additional sequences for a DEAD of the same basic type... CString stringEnumDEAD = curSequence->GetEnum(); ASSERT(!IsEnumSeperator(stringEnumDEAD)); stringEnumDEAD.Replace("DEATH","DEAD"); // 1st, is there even a corresponding DEAD enum in the global enum table that we can look for... CString stringEnum; bool bEnumFound = false; for (int iEnumEntry=0; !bEnumFound; iEnumEntry++) { LPCSTR p = ((CAssimilateApp*)AfxGetApp())->GetEnumEntry(iEnumEntry); if (!p) // EOS? break; stringEnum = p; // note, I could check stuff like "IsEnumSeperator(LPCSTR lpString)" on <p>, but you'd never // have one of those enums assigned to a sequence anyway. // does this enum match the one we've built? if ( !_stricmp( stringEnum, stringEnumDEAD ) ) { bEnumFound = true; } } if ( bEnumFound ) { // ok, there *is* one of these, so let's scan this sequence's additional sequences to see if we've // got it... CSequence *additionalSeq; // outside FOR scope for (int i=0; i<MAX_ADDITIONAL_SEQUENCES; i++) { additionalSeq = curSequence->AdditionalSeqs[i]; if (additionalSeq->AdditionalSequenceIsValid()) { if (!strcmp(additionalSeq->GetEnum(),stringEnum)) { break; // we've found one! } } } // if we didn't find one, NULL the ptr if (int i=MAX_ADDITIONAL_SEQUENCES) { additionalSeq = NULL; } // did we find one? (or did it have the wrong info in?) if ( additionalSeq == NULL // didn't find one || additionalSeq->GetFrameCount()!=1 || additionalSeq->GetLoopFrame() !=-1 || additionalSeq->GetStartFrame()!= curSequence->GetFrameCount()-1 || additionalSeq->GetFrameSpeed()!= curSequence->GetFrameSpeed() ) { // find a slot to add this new sequence to, or use the faulty one... if (additionalSeq == NULL) { for (int i=0; i<MAX_ADDITIONAL_SEQUENCES; i++) { additionalSeq = curSequence->AdditionalSeqs[i]; if (!additionalSeq->AdditionalSequenceIsValid()) { break; // found an unused slot } } } // so have we got a slot to work with? if ( additionalSeq == NULL ) { if (gbCarWash_DoingScan) { strCarWashErrors += va( "F**k!!!: I need an 'additional sequence' slot free in the entry: \"%s\" to generate a DEAD seq, but there isn't one spare. Edit this yourself later.\n",curSequence->GetPath()); } else { ErrorBox( va( "F**k!!!\n\nI need an 'additional sequence' slot free in the ASE:\n\n\"%s\"\n\n... to generate a DEAD seq, but there isn't one spare. Edit this yourself later.",curSequence->GetPath())); } } else { additionalSeq->SetStartFrame( curSequence->GetFrameCount()-1 ); additionalSeq->SetFrameCount( 1 ); additionalSeq->SetLoopFrame (-1 ); additionalSeq->SetFrameSpeed( curSequence->GetFrameSpeed() ); additionalSeq->SetEnum ( stringEnumDEAD ); } } } } } curSequence->SetTargetFrame(curFrame + curSequence->GetStartFrame()); // slightly more legal than just (curFrame) // update: now set any additional sequences within it... for (int i=0; i<MAX_ADDITIONAL_SEQUENCES; i++) { curSequence->AdditionalSeqs[i]->SetTargetFrame(curFrame + curSequence->AdditionalSeqs[i]->GetStartFrame()); } curFrame += curSequence->GetFrameCount(); curFrame += curSequence->GetGenLoopFrame()?1:0; // findme: is this right? I hate this system curSequence = curSequence->GetNext(); } m_totFrames = curFrame; ghAssimilateView->GetDocument()->SetModifiedFlag(); if (pProgress) { delete pProgress; pProgress = 0; } }
int ImageSocket::read_buffer(char *buffer, int size) { StartAutoWait(5); //5 second //char szBuffer[BUFSIZE]; //ZeroMemory(szBuffer,sizeof(szBuffer)); CString xx; CWaitCursor wait; //memset(buffer,0,size); //int len = cs.Receive(buffer, size); //int len = cs.Receive(szBuffer,BUFSIZE); ///Receive all data --------------------------------- int nTotalRead=0; int nRead=0; BOOL bRead=TRUE; int i,nTrimLF, nSpace=0; i = nTrimLF = nSpace = 0; //trim off LF char chLF[2]; while(bRead) { nRead = cs.Receive(chLF, 2); if (nRead==0 || SOCKET_ERROR == nRead) { CString sError; sError.Format("数据接收失败!发送的数据,或者网络可能出现问题,错误代码:%d", GetLastError()); //AfxMessageBox(sError); CLogFile::WriteLog(sError); bRead = FALSE; StopAutoWait(); return 0; } if ( chLF[1] == cnLF) continue; break; } buffer[0]=chLF[0]; buffer[1]=chLF[1]; nTotalRead+=nRead; while(bRead) { nSpace = BUFSIZE-nTotalRead; nRead = cs.Receive(buffer+nTotalRead, nSpace); if (nRead==0 || SOCKET_ERROR == nRead) { CString sError; sError.Format("数据接收失败!发送的数据,或者网络可能出现问题,错误代码:%d", GetLastError()); AfxMessageBox(sError); bRead = FALSE; StopAutoWait(); return 0; } nTotalRead+=nRead; if (nRead>0 && nTotalRead>=4) { //------------------------------------liangjl 2011-04-20-------------------------- //some time , we will read the end character which is not be read from the pre cmd. /*/so ,here we should throw these messages... if (( *(buffer+1) == cnLF) && ( *(buffer+3) == cnLF) ) { for (i=1; i<nTotalRead; i+=2) { if ( *(buffer+i) == cnLF) continue; break; } nTrimLF = i-1; //trim LF in front of the sMsg. if (nTrimLF==nTotalRead) // this mean, we read nothing..., we should continue read ... continue; //while... } *///--------------------------------------------------------------------------------- if ( ( *(buffer+nTotalRead-1) == cnLF) && ( *(buffer+nTotalRead-3) == cnCR) || (( *(buffer+nTotalRead-1) == cnLF) && ( *(buffer+nTotalRead-3) == cnLF))) { //ofstream ofs("1.data", ios::binary|ios::out); //ofs.write(buffer, nTotalRead); //ofs.close(); bRead = FALSE; break; } continue; } else { //AfxMessageBox("Socket数据读取有问题,放弃读取操作!"); continue; //bRead = FALSE; //break; } } StopAutoWait(); if (nTotalRead >= BUFSIZE) AfxMessageBox("数据缓冲区已满!"); ///-------------------------------------------------------- int len = nTotalRead; //int len = nTotalRead - nTrimLF; //if (len<0) return 0; //if socket failed to logon, here will be returned -1, add this to viod crash. if (nTotalRead<0) return 0; int nNum=len; /*/-------------------------------------------------- if (len%2) { CString str; str.Format("Odd %d", len); AfxMessageBox(str); } int nBytes = len/2; u_short *ps=NULL; ps=(u_short *)&szBuffer; if ( (*ps) == 0xFFFE ) { ps=(u_short *)(szBuffer+2); nBytes = len/2-1; } //u_short pconvs; for(int i=0;i<nBytes;i++,ps++) { *ps=ntohs(*ps); //ps++; //memcpy(&dstlocal[i], &pconvs, sizeof(pconvs)); } //UNICODE转换为ANSI int length = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(szBuffer+2), nBytes, NULL, 0, NULL,NULL); //int length = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(szBuffer+2), -1, NULL, 0, NULL,NULL); int nNum = WideCharToMultiByte(CP_ACP, 0, (WCHAR *)(szBuffer+2), nBytes, buffer, length, NULL,NULL); *///------------------------------------------------------ //write to Log File. //util::int2str(xx, len); util::int2str(xx,nNum); CLogFile::WriteLog("read buffer:" + xx); if(len > 0 && len < 1024){ buffer[len] = 0; CLogFile::WriteLog((const char *)buffer); } wait.Restore(); //return len; return nNum; }
void LoadText( const char *infile, SymbolArray &text ) { CWaitCursor WCursor; text.Read(infile); WCursor.Restore(); }
void CPadView::OnChoosePrintFont() { CWaitCursor wait; CFont* pFont = GetPrinterFont(); LOGFONT lf; LPLOGFONT plf = NULL; if (pFont != NULL) { pFont->GetObject(sizeof(LOGFONT), &lf); plf = &lf; } // magic to get printer dialog that would be used if we were printing! CPrintDialog dlgPrint(FALSE); if (!AfxGetApp()->GetPrinterDeviceDefaults(&dlgPrint.m_pd)) { AfxMessageBox(IDP_ERR_GET_DEVICE_DEFAULTS); return; } wait.Restore(); HDC hdcPrint = dlgPrint.CreatePrinterDC(); if (hdcPrint == NULL) { AfxMessageBox(IDP_ERR_GET_PRINTER_DC); return; } CDC dcScreen; dcScreen.Attach(::GetDC(NULL)); CDC dcPrint; dcPrint.Attach(hdcPrint); if (plf != NULL) { // need to map initial logfont to screen metrics. ::ScaleLogFont(plf, dcPrint, dcScreen); } // now bring up the dialog since we know the printer DC CFontDialog dlg(plf, CF_PRINTERFONTS, &dcPrint); if (dlg.DoModal() == IDOK) { // map the resulting logfont back to printer metrics. lf = dlg.m_lf; ::ScaleLogFont(&lf, dcScreen, dcPrint); SetPrinterFont(NULL); m_fontPrint.DeleteObject(); if (m_fontPrint.CreateFontIndirect(&lf)) { SetPrinterFont(&m_fontPrint); m_lfDefPrintFont = lf; // notify container that content has changed GetDocument()->UpdateAllItems(NULL); } } //NOTE: destructor will call dcPrint.DeleteDC ::ReleaseDC(NULL, dcScreen.Detach()); }