bool InputBox (char* Caption, char* OutBuffer, size_t OutBufferLen, char* UpperCaption, CWnd* Parent) { CInputBox* C = new CInputBox(Parent); C->m_Caption = Caption; C->m_Edit = OutBuffer; C->m_UpperCaption = UpperCaption; if (C->DoModal() != IDOK) { delete C; return false; }; if (strlen (C->m_Edit) < OutBufferLen - 1) strcpy (OutBuffer, C->m_Edit); else { strncpy (OutBuffer, C->m_Edit, OutBufferLen - 2); OutBuffer[OutBufferLen - 1] = 0; }; delete C; return true; };
void CMainFrame::OnMenu( CMenuWnd *pMenu,CControlUI* pSender,LPCTSTR sType ) { if(_tcscmp(sType,_T("click"))!=0) return; int id=pMenu->id(); CString itemName=pSender->GetName(); if(id==IDM_BUDDYITEM) { CBuddyListItem *pItem=m_pBuddyList->GetSelectedBuddyItem(); if(!pItem) return; if(itemName==_T("menu_buddy_sendmsg")) { GetContext()->GetSessionManager().OpenChatFrame(pItem->GetJid()); } else if(itemName==_T("menu_buddy_modifyremark")) { CInputBox inputBox; CString strRemark; if(inputBox.ShowInput(_T("Ð޸ı¸×¢"),strRemark,_T("ÊäÈ뱸ע"),_T(""),*this)) { } } else if(itemName==_T("menu_buddy_profile")) { } else if(itemName==_T("menu_buddy_changegroup")) { } else if(itemName==_T("menu_buddy_delete")) { GetContext()->GetClient()->rosterManager()->remove(pItem->GetJid()); } } else if(id==IDM_STATUS) { if(itemName==_T("menu_status_online")) { GetContext()->GetClient()->setPresence(gloox::Presence::Available,1); } else if(itemName==_T("menu_status_away")) { GetContext()->GetClient()->setPresence(gloox::Presence::Away,1); } else if(itemName==_T("menu_status_hidden")) { GetContext()->GetClient()->setPresence(gloox::Presence::Unavailable,1); } } }
void COnlineSearch::OnButtonNewprofile() { CInputBox dlg; dlg.SetCaption(AfxLoadString(IDS_STRING_NEWPROFCAP)); dlg.SetPrompt(AfxLoadString(IDS_STRING_NEWPROFPROMPT)); if (dlg.DoModal() == IDOK && !dlg.m_strText.IsEmpty()) { CString name = dlg.m_strText; CSearchProfile* profile = m_ProfilesList.New(name); int i = m_cboProfiles.AddString(name); m_cboProfiles.SetItemDataPtr(i, profile); m_cboProfiles.SetCurSel(i); OnSelchangeComboProfiles(); m_editHost.SetFocus(); } }
void CDofEditing::OnToolsChangedofnumber() { // TODO: Add your command handler code here CString NewDof; CString Mex="Input the new DOF Number"; CInputBox *Box; Box=new CInputBox(this, &NewDof, &Mex ); int Result=Box->DoModal(); delete Box; if(Result==IDOK){ m_Dof->dof.dofNumber=atoi(NewDof); TheTreeViews->UpdateItemLabel(m_Dof->TreeItem); } UpdateAngles(); }
void CGameApp::SaveScore() { HINSTANCE hInst= GetModuleHandle (0); CInputBox *myinp; myinp = new CInputBox(hInst); char result[21]; strcpy(result, ""); myinp->ShowInputBox(0, "Score", "Enter your name !", result, 50); delete myinp; // Save score int finalScore = countScore; FILE *f = fopen("score.txt", "a"); fprintf(f, "%s %d", result, finalScore); fclose(f); }
int CCommDBOper::ADOOpenDBCon(_ConnectionPtr &pCon,const CString strDB,CString &strPassword,int iWarn) { //函数功能 打开指定数据库 //输入参数说明 pCon 要打开的数据库对象,strDB 要连接的ACCESS数据库文件全路径 // strPassword 密码 iWarn 出错警告方式 0,不警告,1,警告,2,警告且退出程序 //作者 LFX CString strCon; _TCHAR dbConnectionString[]=_T("Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=%s;Jet OLEDB:Database Password=%s"); strCon.Format(dbConnectionString,strDB,strPassword); if(!PathFileExists(_T(strDB))) { WarnMessage("要打开的数据库文件名不存在!!!",iWarn); return RET_FAILED; } if (pCon == NULL) { pCon.CreateInstance(__uuidof(Connection) ); } else { ADOCloseConnectDB(pCon,0); } int iLoop = 0; while (true) { //连接ACCESS数据库 iLoop++; //如果没密码,且为第一次循环 if ( strPassword.IsEmpty() && (iLoop <= 1)) { try { pCon->Open(_bstr_t(strCon),"","",-1); } catch(_com_error &e) { CString strTemp; CInputBox inputBox; inputBox.m_bIsProtected = TRUE; strTemp.LoadString(IDS_NEEDPASSWORD); inputBox.m_strWndText.Format("%s%s",strDB,strTemp); inputBox.m_strTitle.LoadString(IDS_PLEASEINPUTDBPASSWORD); if (inputBox.DoModal() != IDOK) { WarnMessage("密码错误,打开数据库失败!!!",iWarn); return RET_FAILED; } else { strPassword = inputBox.m_strValue; } } break; } //如果有密码 try { pCon->Open(_bstr_t(strCon),"","",-1); } catch (_com_error &e) { CString strMsg; strMsg.Format("%s:%d %s", __FILE__, __LINE__, (LPSTR)e.Description()); AfxMessageBox(strMsg); CString errormessage; errormessage.Format("打开数据库 %s 失败!\r\n错误信息:%s",strDB,e.ErrorMessage()); WarnMessage(errormessage,iWarn); return RET_FAILED; } break; } //END while(true) return RET_OK; }