BOOL MyAppWindow :: SaveFile( void ) { XFile savefile; XString s; mle->GetText( &s ); /* now open the file, create a new one if the given filename is not existing, otherwise overwrite */ /* it. open the file for write-access, dont allow any other programm to use the file while it is open*/ if( savefile.Open( path, XFILE_CREATE_IF_NEW | XFILE_REPLACE_EXISTING, XFILE_SHARE_DENYNONE | XFILE_WRITEONLY, s.GetLength()) == 0) { /* set the file-cursor to the beginning of the file */ savefile.Seek( 0, FILE_BEGIN); /*save the string */ savefile.Write ( (char*) s, s.GetLength()); /* close the file */ savefile.Close(); saved = TRUE; return TRUE; } else { XMessageBox( "could not open file", "error", MB_OK| MB_ERROR); return FALSE; } }
void CAnalysisHowPage::OnOK() { CAnalysisComputation& computation = m_pAnalysis->GetComputation(); if (computation.m_bSelectTimeTransformation && computation.m_bMeanOverReplication && computation.m_kind == CAnalysisComputation::STATISTIC && computation.m_statisticType2 == -1) { XMSGBOXPARAMS xmb; _tcscpy_s(xmb.szCompanyName, 260, _T("NRCan")); xmb.lpszModule = _T("HowPage"); xmb.nLine = IDS_SIM_HOW_WARNING; XMessageBox(m_hWnd, UtilWin::GetCString(IDS_SIM_HOW_WARNING), NULL, MB_OK | MB_DONOTTELLAGAIN | MB_ICONINFORMATION | MB_NORESOURCE, &xmb); } //if (rc & MB_DONOTTELLAGAIN) //{ // TRACE(_T("MB_DONOTTELLAGAIN\n")); //} }
BOOL MyWindow :: DoCommand(LONG command) { switch(command) { case IDP_PLAY: sound->Play(); toolBar->GetWindow( IDP_STOP )->Enable(); toolBar->GetWindow( IDP_PLAY )->Enable( FALSE ); break; case IDP_STOP: if( sound->Stop() ) XMessageBox("error"); toolBar->GetWindow( IDP_STOP )->Enable( FALSE ); toolBar->GetWindow( IDP_BACK )->Enable(); toolBar->GetWindow( IDP_PLAY )->Enable(); break; case IDP_BACK: if( sound->Rewind() ) XMessageBox("error"); toolBar->GetWindow( IDP_STOP )->Enable( FALSE ); toolBar->GetWindow( IDP_PLAY )->Enable(); break; case IDP_OPEN: { XFileDialog dlg( this, "c:\\mmos2\\sounds\\"); if( dlg.GetCommand() == DID_OK) { XString s; dlg.GetFileName( &s ); if( sound->SetDataFile( (char*) s ) != 0) { XMessageBox( "cannot load sound file"); return TRUE; } toolBar->GetWindow( IDP_PLAY )->Enable(); toolBar->GetWindow( IDP_STOP )->Enable( FALSE ); toolBar->GetWindow( IDP_BACK )->Enable( FALSE ); } } break; default: return FALSE; } return TRUE; }
/* load a file */ BOOL MyAppWindow :: LoadFile ( char * p) { // is there already a file loaded or has the user entered some text? if(loaded == FALSE && saved == TRUE) { //no, we load the file in the window of the current thread XFile loadfile; /* now open the file, fail if given filename is not existing */ /* open the file for read-access, dont allow any other programm to use the file while it is open*/ if( loadfile.Open( p, XFILE_FAIL_IF_NEW | XFILE_OPEN_EXISTING, XFILE_SHARE_DENYWRITE | XFILE_READONLY ) == 0) { XString s; loading = TRUE; //how large is the file? XFileInfo info; loadfile.GetFileInfo( &info ); LONG size = info.GetFileSize(); //read the complete file loadfile.Read ( (PVOID) s.GetBuffer(info.GetFileSize() + 1), size); s.ReleaseBuffer( info.GetFileSize() ); //set the XString content to the mle mle->SetText( s ); //dontïforget to close the file loadfile.Close(); loaded = TRUE; path = p; mle->SetFocus(); GetText( &s ); s+= " - "; s+= p; SetText( s ); loading = FALSE; return TRUE; } else { XMessageBox( p, "couldnït open File!", MB_OK|MB_ERROR); return FALSE; } } else { //there is a file loaded, or the user has entered some text, so // we create a new window and load the file // XResource res( IDM_MAIN, ((MyApp*) GetProcess())->GetResourceLibrary()); MyAppWindow * win = new MyAppWindow( IDM_MAIN ); win->LoadFile(p); return TRUE; } }
BOOL SearchDialog :: DoCommand( LONG com ) { switch( com ) { case PUSH_CANCEL: break; case PUSH_REPLACE: { XString buffer; GetWindow( ENTRY_REPLACE )->GetText( &buffer ); mle->InsertString( buffer ); } return FALSE; case PUSH_SEARCH: { XString buffer; GetWindow( ENTRY_SEARCH )->GetText( &buffer ); search.SetSearchItem( buffer ); GetWindow( ENTRY_REPLACE )->GetText( &buffer ); search.SetReplaceItem( buffer ); LONG start, end; mle->GetSelection( start, end); if(start > end ) end = start; search.SetStartPoint( end ); XCheckBox * c = (XCheckBox*) GetWindow( CHECK_REPLACE ); if( c->IsSelected()) search.SetReplaceAll( TRUE ); else search.SetReplaceAll( FALSE ); if( mle->Search( &search ) ) mle->Activate(); else XMessageBox( "pattern not found!", "Search", MB_OK|MB_ICONEXCLAMATION, this); return FALSE; } } return TRUE; }
static void MemChecker_Button_Listener(MemChecker *pMe, XEvent *pEvent) { if (XEVT_COMMAND == pEvent->nCode) { switch(pEvent->dwParam) { case IDS_BEGIN_WATCH: case IDS_RUN_AND_WATCH: { int nErr = SUCCESS; MemHookInitParam sParam = {0}; AEEAppInfo ai = {0}; if (ISHELL_QueryClass(pMe->a.m_pIShell, pMe->m_clsCheckedApp, &ai)) { sParam.pIShell = pMe->a.m_pIShell; sParam.clsApp = pMe->m_clsCheckedApp; sParam.eOutputMode = pMe->m_eOutputMode; MemHook_Install(&sParam); if (IDS_RUN_AND_WATCH == pEvent->dwParam) { nErr = ISHELL_StartApplet(pMe->a.m_pIShell, pMe->m_clsCheckedApp); } } else { nErr = ECLASSNOTSUPPORT; } if (SUCCESS == nErr) { pMe->m_bBackground = TRUE; // Go background ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE); MemChecker_WaitForAppStartup(pMe); } else // Failed { MemHook_Uninstall(); if (IDS_BEGIN_WATCH == pEvent->dwParam) { XMessageBox( L"Please set a valid applet class id in \"config.ini\".", L"Error"); } else { XMessageBox( L"Can not start the applet. " L"Please set a valid applet class id in \"config.ini\".", L"Error"); } } } break; case IDS_ABOUT: XMessageBox( L"BREW Memory Leak Checker\n\n" L"Version: 1.0.1\n\n" L"Copyright 2010-2012 by DXJ. All Rights Reserved.\n\n" L"Email: [email protected]", L"About me"); break; default: break; } } }
BOOL CPPgScheduler::OnCommand(WPARAM wParam, LPARAM lParam) { int item= m_actions.GetSelectionMark(); // add if (wParam>=MP_SCHACTIONS && wParam<MP_SCHACTIONS+20 && m_actions.GetItemCount()<16) { int action=wParam-MP_SCHACTIONS; int i=m_actions.GetItemCount(); m_actions.InsertItem(i,GetActionLabel(action)); // MORPH START leuk_he: Remove 2nd apply in scheduler SetModified(); // MORPH END leuk_he: Remove 2nd apply in scheduler m_actions.SetItemData(i,action); m_actions.SetSelectionMark(i); if (action<6) OnCommand(MP_CAT_EDIT,0); // Mighty Knife START: parameterless schedule events else if (action>=ACTION_BACKUP && action<=ACTION_RELOAD) { // Small warning message if (action == ACTION_UPDIPCONF || action == ACTION_UPDFAKES || action == ACTION_UPDCOUNTRY) { XMessageBox (NULL,GetResString (IDS_SCHED_UPDATE_WARNING), GetResString (IDS_WARNING),MB_OK | MB_ICONINFORMATION,NULL); m_actions.SetItemText(i,1,L"update"); } else m_actions.SetItemText(i,1,L"-"); CTime myTime1 ;m_time.GetTime(myTime1); // MORPH add check for one time events CTime myTime2 ;m_timeTo.GetTime(myTime2); if ( myTime1!= myTime2) // leuk_he: warn because will be executeed every minute! if(XMessageBox (NULL,GetResString(IDS_SCHED_WARNENDTIME), GetResString (IDS_WARNING),MB_OKCANCEL| MB_ICONINFORMATION,NULL)== IDOK) m_timeTo.SetTime(&myTime1); // On ok reset end time. } // Mighty Knife END //MORPH START - Changed by Stulle, Show cat name for scheduler cat actions else m_actions.SetItemText(i,1,L"-1 ("+GetResString(IDS_ALL)+L")"); //MORPH END - Changed by Stulle, Show cat name for scheduler cat actions } else if (wParam>=MP_SCHACTIONS+20 && wParam<=MP_SCHACTIONS+80) { CString newval; //MORPH START - Changed by Stulle, Show cat name for scheduler cat actions /* newval.Format(_T("%i"),wParam-MP_SCHACTIONS-22); */ int iCat = wParam-MP_SCHACTIONS-22; CString strCatTitle; if(iCat == -1) strCatTitle = GetResString(IDS_ALL); else { Category_Struct* thisCat = thePrefs.GetCategory(iCat); if(thisCat) strCatTitle = thisCat->strTitle; else // should not happen strCatTitle = GetResString(IDS_UNKNOWN); } newval.Format(L"%i (%s)",iCat,strCatTitle); //MORPH END - Changed by Stulle, Show cat name for scheduler cat actions m_actions.SetItemText(item,1,newval); // MORPH START leuk_he: Remove 2nd apply in scheduler SetModified(); // lhane } else if (wParam == ID_HELP) { OnHelp(); return TRUE; } switch (wParam){ case MP_CAT_EDIT: { if (item!=-1) { InputBox inputbox; // todo: differen prompts CString prompt; switch (m_actions.GetItemData(item)) { case 1: case 2: prompt=GetResString(IDS_SCHED_ENTERDATARATELIMIT)+_T(" (")+GetResString(IDS_KBYTESPERSEC)+_T(")"); break; default: prompt=GetResString(IDS_SCHED_ENTERVAL); } inputbox.SetLabels(GetResString(IDS_SCHED_ACTCONFIG),prompt,m_actions.GetItemText(item,1)); inputbox.DoModal(); CString res=inputbox.GetInput(); if (!inputbox.WasCancelled()) m_actions.SetItemText(item,1,res); // MORPH START leuk_he: Remove 2nd apply in scheduler SetModified(); //MORPH END leuk_he: Remove 2nd apply in schedulerd } break; } case MP_CAT_REMOVE: { // remove if (item!=-1) { int ix=m_actions.GetSelectionMark(); if (ix!=-1) { m_actions.DeleteItem(ix); } // MORPH START leuk_he: Remove 2nd apply in scheduler SetModified(); // MORPH END leuk_he: Remove 2nd apply in scheduler } break; } } return CPropertyPage::OnCommand(wParam, lParam); }
/// @brief 属性网格元素,添加项. /// @param hEle 元素句柄. /// @param pName 项名称. /// @param type 项类型. /// @param groupID 所属组ID,如果-1没有分组 /// @return 新添加的项ID标示符,如果失败返回-1. int WINAPI XPGrid_AddItem(HELE hEle,wchar_t *pName,int type,int groupID) //添加项 { IsPGridDebug(hEle,__FUNCTION__); propertyGrid_ *pObj=(propertyGrid_*)hEle; PGridItem_ *pItem=(PGridItem_*)malloc(sizeof(PGridItem_)); pItem->id=PGrid_AddID(hEle); pItem->posy=NULL; pItem->hEle=NULL; pItem->type=type; pItem->pName=NULL; pItem->pValue=NULL; pItem->pNext=NULL; if(pName) { int size=wcslen(pName)+1; pItem->pName=(wchar_t*)malloc(size*sizeof(wchar_t)); wcscpy_s(pItem->pName,size,pName); } switch(type) { case PGRID_EDIT: { HELE hEdit=XEdit_Create(0,0,20,20,hEle); XEle_ShowEle(hEdit,FALSE); pItem->hEle=hEdit; }break; case PGRID_COMBOBOX: { HELE hCom=XComboBox_Create(0,0,20,20,hEle); XEle_ShowEle(hCom,FALSE); pItem->hEle=hCom; }break; case PGRID_CHOOSECOLOR: { HELE hColor= XCHColor_Create(0,0,20,20,hEle); XEle_ShowEle(hColor,FALSE); pItem->hEle=hColor; }break; case PGRID_EDIT_FILE: { HELE hEditFile= XEditFile_Create(0,0,20,20,hEle); XEle_ShowEle(hEditFile,FALSE); pItem->hEle=hEditFile; } #ifdef _DEBUG case PGRID_STRING: break; default: { XMessageBox(hEle,L"XPGrid_AddItem() API,参数type错误",L"炫彩界面库-错误提示",XMB_OK); } #endif } if(-1==groupID) //一级项 { PGridNode_ *pNode=(PGridNode_*)malloc(sizeof(PGridNode_)); pNode->pItem=pItem; pNode->type=2; pNode->pNext=NULL; if(NULL==pObj->pItemList) { pObj->pItemList=pNode; pObj->pItemLast=pNode; }else { pObj->pItemLast->pNext=pNode; pObj->pItemLast=pNode; } }else //二级项 { PGridGroup_ *pGroup=PGrid_GetGroup(hEle,groupID); if(pGroup) { if(NULL==pGroup->pItemList) { pGroup->pItemList=pItem; pGroup->pItemLast=pItem; }else { pGroup->pItemLast->pNext=pItem; pGroup->pItemLast=pItem; } } } pObj->bAdjust=TRUE; return pItem->id; }