Ejemplo n.º 1
0
// Routine to load date qualifier strings from resources. Do not call before AfApp has m_hinst.
void LoadDateQualifiers()
{
	if (g_fDoneDateQual)
		return;

	int i;
	for (i = 0; i < 5; i++)
	{
		StrUni stu(g_rgridDateQual1[i]);
		Assert(stu.Length() < knPrecLen);
		u_strcpy(g_rgchwPrecFull[i], stu.Chars());
		StrAnsi sta(g_rgridDateQual1[i]);
		Assert(sta.Length() < knPrecLen);
		strcpy_s(g_rgchPrecFull[i], sta.Length(), sta.Chars());
	}
	for (i = 0; i < 2; i++)
	{
		StrUni stu(g_rgridDateQual2[i]);
		Assert(stu.Length() < knAdBcLen);
		u_strcpy(g_rgchwBC_ADFull[i], stu.Chars());
		StrAnsi sta(g_rgridDateQual2[i]);
		Assert(stu.Length() < knAdBcLen);
		strcpy_s(g_rgchBC_ADFull[i], sta.Length(), sta.Chars());
	}
	for (i = 0; i < 3; i++)
	{
		StrUni stu(g_rgridDateBlank[i]);
		Assert(stu.Length() < knBlankLen);
		u_strcpy(g_rgchwBlankFull[i], stu.Chars());
		StrAnsi sta(g_rgridDateBlank[i]);
		Assert(stu.Length() < knBlankLen);
		strcpy_s(g_rgchBlankFull[i], sta.Length(), sta.Chars());
	}
	g_fDoneDateQual = true;
}
Ejemplo n.º 2
0
/*----------------------------------------------------------------------------------------------
	Returns the name of the local host. (E.g., retrieves "AC-WIMBISHJ".)

	Returns true if successful, false otherwise.
----------------------------------------------------------------------------------------------*/
bool NetworkTreeView::GetLocalMachineName(achar * pszLocalMachineName, uint c)
{
	WSADATA data;
	if (0 == WSAStartup(MAKEWORD(2, 0), &data))
	{
		Vector<char> vch;
		vch.Resize(c);
		int nResult = gethostname(vch.Begin(), c);
		if (WSACleanup() || nResult)
		{
			*pszLocalMachineName = '\0';
			return false;
		}
		if (sizeof(achar) == sizeof(char))
		{
			memcpy(pszLocalMachineName, vch.Begin(), c);
		}
		else
		{
			Assert(sizeof(achar) == sizeof(wchar));
			// Convert name to wide characters.
			StrUni stu(vch.Begin());
			int cch = stu.Length();
			if ((unsigned)stu.Length() >= c)
				cch = c - 1;
			memcpy(pszLocalMachineName, stu.Chars(), cch * sizeof(achar));
			pszLocalMachineName[cch] = 0;
		}
		return true;
	}
	return false;

}
Ejemplo n.º 3
0
/*----------------------------------------------------------------------------------------------
	Create a property with the given writing system, old writing system, and named style (ktptNamedStyle).
	Note that ktptCharStyle (which this used to use) is effectively obsolete.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP TsPropsFact::MakePropsRgch(const OLECHAR * prgch, int cch,	int ws, int ows,
	ITsTextProps ** ppttp)
{
	BEGIN_COM_METHOD;
	ChkComArrayArg(prgch, cch);
	ChkComOutPtr(ppttp);
	if ((uint)ws > kwsLim)
		ThrowInternalError(E_INVALIDARG, "Magic writing system invalid in string");

	TsIntProp tip;
	TsStrProp tsp;
	int ctip = 0;
	int ctsp = 0;

	tip.m_nVal = ws;
	tip.m_nVar = ows;
	tip.m_tpt = ktptWs;
	ctip = 1;
	if (cch)
	{
		StrUni stu(prgch, cch);
		TsStrHolder * ptsh = TsStrHolder::GetStrHolder();
		tsp.m_hstuVal = ptsh->GetCookieFromString(stu);
		tsp.m_tpt = ktptNamedStyle;
		ctsp = 1;
	}
	TsTextProps::Create(ctip ? &tip : NULL, ctip, ctsp ? &tsp : NULL, ctsp, ppttp);

	END_COM_METHOD(g_factPropsFact, IID_ITsPropsFactory);
}
Ejemplo n.º 4
0
/*----------------------------------------------------------------------------------------------
	DisplayVariant is used for times and enumerations.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP CleCustDocVc::DisplayVariant(IVwEnv * pvwenv, int tag, VARIANT v, int frag,
	ITsString ** pptss)
{
	BEGIN_COM_METHOD;
	ChkComArgPtr(pvwenv);
	ChkComOutPtr(pptss);

	ITsStrFactoryPtr qtsf;
	qtsf.CreateInstance(CLSID_TsStrFactory);
	int ws = m_qlpi->GetDbInfo()->UserWs();

	if (tag == kflidCmPerson_Gender || tag == kflidCmPerson_IsResearcher)
	{
		int itss = v.intVal;
		int stid;
		switch (tag)
		{
		case kflidCmPerson_Gender:
			stid = kstidEnumGender;
			break;
		case kflidCmPerson_IsResearcher:
			stid = kstidEnumNoYes;
			if (itss)
				itss = 1;
			break;
		default:
			Assert(false);
			break;
		}
		StrUni stuEnum(stid);
		const wchar * pszEnum = stuEnum.Chars();
		const wchar * pszEnumLim = stuEnum.Chars() + stuEnum.Length();
		ITsStringPtr qtss;
		//ITsStrFactoryPtr qtsf;
		//qtsf.CreateInstance(CLSID_TsStrFactory);
		int itssTry = 0;
		while (pszEnum < pszEnumLim && itssTry <= itss)
		{
			const wchar * pszEnumNl = wcschr(pszEnum, '\n');
			if (!pszEnumNl)
				pszEnumNl = pszEnumLim;
			if (itss == itssTry)
			{
				return qtsf->MakeStringRgch(pszEnum, (pszEnumNl - pszEnum), ws, pptss);
			}
			itssTry++;
			pszEnum = pszEnumNl + 1;
		}
		// Fall-back behavior if we couldn't find a string: use the integer value.
		char rgch[20];
		_itoa_s(itss, rgch, 10);
		StrUni stu(rgch);
		return qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, pptss);
	}

	return SuperClass::DisplayVariant(pvwenv, tag, v, frag, pptss);

	END_COM_METHOD(g_fact1, IID_IVwViewConstructor)
}
int zmq_client::send_data( std::string &data, std::string destination )
{
    boost::shared_ptr<STU_ZMQ_CLIENT_MSG> stu(new STU_ZMQ_CLIENT_MSG);
    stu->data = data;
    stu->destination = destination;
    m_queue_send.add_queue(stu);
    return 0;

}
Ejemplo n.º 6
0
/*----------------------------------------------------------------------------------------------
	Initialize the list of encodings from the writing system factory.
----------------------------------------------------------------------------------------------*/
void WpFormatWsDlg::InitEncList()
{
	int cws;
	ILgWritingSystemFactoryPtr qwsf;
	qwsf.CreateInstance(CLSID_LgWritingSystemFactory);	// Get the memory-based factory.
	CheckHr(qwsf->get_NumberOfWs(&cws));
	int * prgenc = NewObj int[cws];
	CheckHr(qwsf->GetWritingSystems(prgenc));
	int wsUser;
	CheckHr(qwsf->get_UserWs(&wsUser));

	for (int iws = 0; iws < cws; iws++)
	{
		if (prgenc[iws] == 0)
			continue;

		IWritingSystemPtr qws;
		CheckHr(qwsf->get_Engine(prgenc[iws], &qws));
		if (!qws)
			continue;

		//	Generate the name to use for the writing system.
		SmartBstr sbstr;
		CheckHr(qws->get_UiName(wsUser, &sbstr));
		if (!sbstr)
			continue;
		StrUni stu(sbstr.Chars());
		StrApp str = stu;

		m_vws.Push(prgenc[iws]);
		m_vstr.Push(str);
	}
	Assert(m_vws.Size() == m_vstr.Size());

	//	Sort the encodings by name.
	for (iws = 0; iws < m_vws.Size() - 1; iws++)
	{
		for (int iws2 = iws + 1; iws2 < m_vws.Size(); iws2++)
		{
			if (m_vstr[iws] > m_vstr[iws2])
			{
				StrApp strTmp = m_vstr[iws];
				int encTmp = m_vws[iws];
				m_vstr[iws] = m_vstr[iws2];
				m_vws[iws] = m_vws[iws2];
				m_vstr[iws2] = strTmp;
				m_vws[iws2] = encTmp;
			}
		}
		if (m_vws[iws] == m_wsInit)
			m_iwsInit = iws;
	}

	delete[] prgenc;
}
Ejemplo n.º 7
0
/*----------------------------------------------------------------------------------------------
	Return the what's-this help string for the Date Dialog ellipsis button.

	@param pt not used.
	@param pptss Address of a pointer to an ITsString COM object for returning the help string.

	@return true.
----------------------------------------------------------------------------------------------*/
bool AfDeFeEdBoxBut::DeButton::GetHelpStrFromPt(Point pt, ITsString ** pptss)
{
	AssertPtr(pptss);

	StrApp str;
	str.Load(kstidEllipsisBtnDateWhatsThisHelp); // No context help available
	ITsStrFactoryPtr qtsf;
	qtsf.CreateInstance(CLSID_TsStrFactory);
	StrUni stu(str);
	CheckHr(qtsf->MakeString(stu.Bstr(), m_pdee->UserWs(), pptss));
	return true;
}
Ejemplo n.º 8
0
/*----------------------------------------------------------------------------------------------
	Create a new TssEdit. psz can be NULL if the control should start out empty.
----------------------------------------------------------------------------------------------*/
void TssEdit::Create(HWND hwndPar, int cid, DWORD dwStyle, HWND hwndToolTip, const achar * psz,
	ILgWritingSystemFactory * pwsf, int ws, IActionHandler * pacth)
{
	AssertPtrN(psz);
	AssertPtr(pwsf);

	ITsStringPtr qtss;
	if (psz)
	{
		ITsStrFactoryPtr qtsf;
		qtsf.CreateInstance(CLSID_TsStrFactory);
		StrUni stu(psz);
		CheckHr(qtsf->MakeString(stu.Bstr(), ws, &qtss));
	}
	Create(hwndPar, cid, dwStyle, hwndToolTip, qtss, pwsf, ws, pacth);
}
Ejemplo n.º 9
0
/*----------------------------------------------------------------------------------------------
	Creates an error object and then sets a description from a resource id. Also sets a full
	help URL as required by HtmlHelp. Uses ierr as an index for both resource id and help URL.
	@param ierr Index to a set of htm help files (second part of full help URL) and matching
	resource strings for Message Box text.
	@param pei [out] Error info object
----------------------------------------------------------------------------------------------*/
void LgKeymanHandler::ThrowErrorWithInfo(HRESULT hrErr, int stidDescription)
{
	IErrorInfoPtr qei;
	ICreateErrorInfoPtr qcei;

	// Create error info object.
	CheckHr(CreateErrorInfo(&qcei));

	StrUni stu(stidDescription);
	CheckHr(qcei->SetDescription((wchar *)stu.Chars()));

	// Now get the IErrorInfo interface of the error object and set it for the current thread.
	CheckHr(qcei->QueryInterface(IID_IErrorInfo, (void **)&qei));
	SetErrorInfo(0, qei);

	ThrowHr(hrErr, stu.Chars(), -1, qei);	// An error object exists.
}
Ejemplo n.º 10
0
void manager::on_studentaddbutton_click(){
    int ID;
    string name,birthday,gender,deptname;
    ID=ui->student_ID->text().toInt();
    name=ui->student_name->text().toStdString();
    birthday=ui->student_birthday->text().toStdString();
    gender=ui->student_gender->text().toStdString();
    deptname=ui->student_dept->text().toStdString();
    UStudent stu(ID,"******",name,deptname,birthday,gender);
    bool status=admi.AddStudent(stu);
    if(status) {
        QMessageBox::information(this,tr("提示"),tr("增加学生成功!"),QMessageBox::Ok);
    }
    else{
        QMessageBox::information(this,tr("提示"),tr("增加学生失败"),QMessageBox::Ok);
    }
}
Ejemplo n.º 11
0
Operation::Operation(){
    /***课程列表初始化***/
    ifstream fin;
    fin.open("Course.txt", ios::in);
    string cno, cname;
    float ccredit;
    while(!fin.eof()){
        fin >> cno >> cname >> ccredit;
        Course course(cno, cname, ccredit);
        cvec.push_back(course);
    }
    fin.close();
    /*初始化学生信息和选课成绩信息*/
    fin.open("Student.txt", ios::in);
    while(!fin.eof()){
        string sno, sname;
        string sex;
        Gender ssex;
        int sage, n;
        fin >> sno >> sname >> sex >> sage >> n;
        ssex = (sex == "男") ? MALE : FEMALE;
        Student stu(sno, sname, ssex, sage);
        string cno;
        float cscore;
        for(int i = 0; i < n; i++){
            fin >> cno >> cscore;
            stu.score += cscore;
            vector<Course>::iterator it;
            for(it = cvec.begin(); it != cvec.end(); it++){
                if(it->cno == cno){
                    stu.credit += it->ccredit;
                    Score score(*it, stu, cscore);
                    scvec.push_back(score);
                    break;
                }
            }
        }
        if(sno.length() == 0 || sname.length() == 0) continue;
        svec.push_back(stu);
    }
    fin.close();
}
Ejemplo n.º 12
0
/*----------------------------------------------------------------------------------------------
	Read the text to render from the file being opened.
----------------------------------------------------------------------------------------------*/
void WpDa::ReadTextFromFile(StrAnsi staFileName, Vector<StrUni> & vstu)
{
	OLECHAR pswzData[5000];
	memset(pswzData, 0, 5000);

	char pszData[10000];
	memset(pszData, 0, 10000);

	FILE * f = fopen(staFileName.Chars(), "rb");

//	IStreamPtr qstrm;
//	FileStream::Create(staFileName.Chars(),kfstgmRead,&qstrm);

	if (!f)
	{
		//	No such file
		ThrowHr(WarnHr(E_FAIL));
	}

	fread(pszData, 1, 10000, f);
	fclose(f);

	char * pch = pszData;
	OLECHAR * pchw;
	if (*pch == 0xFFFFFFFF && *(pch + 1) == 0xFFFFFFFE)
	{
		//	UTF16
		memcpy(pswzData, pszData + 2, 9998);
	}
	else if (*pch == 0xFFFFFFFE && *(pch + 1) == 0xFFFFFFFF)
	{
		//	UTF16 with the byte order reversed.
		pch += 2;
		pchw = pswzData;
		while (pch < pszData + 10000 && *pch != 0)
		{
			*pchw = (wchar)(*pch << 8 | *(pch + 1));
			pch += 2;
			pchw++;
		}
	}
	else
	{
		//	Assume plain 8-bit ANSI data.
		pchw = pswzData;
		while (pch < pszData + 5000 && *pch != 0)
		{
			*pchw = *pch;
			pch++;
			pchw++;
		}
	}

	//	Make a list of strings.

	pchw = pswzData;
	OLECHAR * pchwStrMin = pchw;
	while (pchw < pswzData + 5000 && *pchw != 0)
	{
		if (*pchw == 13 && *(pchw + 1) == 10)	// CRLF
		{
			//	Make a new string;
			StrUni stu(pchwStrMin, pchw - pchwStrMin);
			vstu.Push(stu);
			pchw += 2;	// skip CRLF
			pchwStrMin = pchw;
		}
		else
			pchw++;
	}
	StrUni stu(pchwStrMin, pchw - pchwStrMin);
	vstu.Push(stu);
}
Ejemplo n.º 13
0
void manager::on_studentwidget_click(int row, int col)
{
    QTableWidgetItem* temp;
    int ID;
    string name,birthday,gender,deptname;
    if(col==5) {
        QMessageBox msgBox;
        msgBox.setText("您确定更新学生信息吗");
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::No);
        int ret=msgBox.exec();
        switch (ret) {
        case QMessageBox::Yes: {
            temp=ui->student_table->item(row,0);
            ID = temp->text().toInt();
            temp=ui->student_table->item(row,1);
            name = temp->text().toStdString();
            temp=ui->student_table->item(row,2);
            birthday = temp->text().toStdString();
            temp=ui->student_table->item(row,3);
            gender = temp->text().toStdString();
            temp=ui->student_table->item(row,4);
            deptname = temp->text().toStdString();
            UStudent stu(ID,"******",name,deptname,birthday,gender);
            bool status=admi.UpdateStudent(stu);
            if(status) {
                QMessageBox::information(this,tr("提示"),tr("更新学生信息成功!"),QMessageBox::Ok);
                on_studentsearchbutton_click();
                break;
            }
            else{
                QMessageBox::information(this,tr("提示"),tr("更新学生信息失败"),QMessageBox::Ok);
                break;
            }
        }
        case QMessageBox::No:
            break;
        default:
            // should never be reached
            break;
        }
    }
    else if(col==6) {
        QMessageBox msgBox;
        msgBox.setText("您确定删除学生信息吗");
        msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
        msgBox.setDefaultButton(QMessageBox::No);
        int ret=msgBox.exec();
        switch (ret) {
        case QMessageBox::Yes: {
            temp=ui->student_table->item(row,0);
            ID = temp->text().toInt();
            temp=ui->student_table->item(row,1);
            name = temp->text().toStdString();
            temp=ui->student_table->item(row,2);
            birthday = temp->text().toStdString();
            temp=ui->student_table->item(row,3);
            gender = temp->text().toStdString();
            temp=ui->student_table->item(row,4);
            deptname = temp->text().toStdString();
            UStudent stu(ID,"******",name,deptname,birthday,gender);
            bool status=admi.RemoveStudent(stu);
            if(status) {
                QMessageBox::information(this,tr("提示"),tr("删除学生信息成功!"),QMessageBox::Ok);
                on_studentsearchbutton_click();
                break;
            }
            else{
                QMessageBox::information(this,tr("提示"),tr("删除学生信息失败"),QMessageBox::Ok);
                break;
            }
        }
        case QMessageBox::No:
            break;
        default:
            // should never be reached
            break;
        }
    }
}
Ejemplo n.º 14
0
/*----------------------------------------------------------------------------------------------
	This processes Windows messages on the window. In general, it normally calls the
	appropriate method on the edit class.
----------------------------------------------------------------------------------------------*/
bool TssEdit::FWndProc(uint wm, WPARAM wp, LPARAM lp, long & lnRet)
{
	bool fRet;

	switch (wm)
	{
	case WM_GETDLGCODE:
		// This is essential when embedded in a dialog to tell the dialog manager that it
		// wants to get key strokes. (We could try DLGC_WANTALLKEYS but I think we would then
		// get the Tab and Return keys...we may get them anyway with this combination...)
		// The last value tells Windows that when tabbing to this control we should use
		// EM_SETSEL to select all the text.
		lnRet = DLGC_WANTCHARS | DLGC_WANTARROWS | DLGC_HASSETSEL;
		return true;
	case EM_GETLINE:	// Use FW_EM_GETLINE.
	case EM_REPLACESEL:	// Use FW_EM_REPLACESEL.
		// We don't support these methods. Use the replacement TsString versions instead.
		Assert(false);
		lnRet = LB_ERR;
		return true;

	// NOTE: DO NOT send this message to a TssEdit if you want the actual text. Send the
	// FW_EM_GETTEXT message instead. This method is required for TssEdit controls on a
	// dialog because Windows will send the message to the control anytime the user hits a
	// key.
	case WM_GETTEXT:
		{
			ITsStringPtr qtss;
			GetText(&qtss);
			const wchar * pwrgch;
			int cch;
			HRESULT hr;
			IgnoreHr(hr = qtss->LockText(&pwrgch, &cch));
			if (FAILED(hr))
				return true;
			StrApp str(pwrgch, cch);
			qtss->UnlockText(pwrgch);
			lnRet = Min(cch + 1, (int)wp);
			achar * psz = reinterpret_cast<achar *>(lp);
			StrCpyN(psz, str.Chars(), lnRet);
		}
		return true;

	// NOTE: You should be sending an FW_EM_SETTEXT message instead of this.
	case WM_SETTEXT:
		{
			achar * psz = reinterpret_cast<achar *>(lp);
			StrUni stu(psz);
			ITsStrFactoryPtr qtsf;
			qtsf.CreateInstance(CLSID_TsStrFactory);
			ITsStringPtr qtss;
			CheckHr(qtsf->MakeStringRgch(stu.Chars(), stu.Length(), m_wsBase, &qtss));
			SetText(qtss);
		}
		return true;

	case EM_CANUNDO:
	case EM_CHARFROMPOS:
	case EM_EMPTYUNDOBUFFER:
	case EM_FMTLINES:
	case EM_GETFIRSTVISIBLELINE:
	case EM_GETHANDLE:
	case EM_GETMODIFY:
	case EM_GETPASSWORDCHAR:
	case EM_GETRECT:
	case EM_GETTHUMB:
	case EM_GETWORDBREAKPROC:
	case EM_POSFROMCHAR:
	case EM_SETHANDLE:
	case EM_SETMODIFY:
	case EM_SETPASSWORDCHAR:
	case EM_SETRECT:
	case EM_SETRECTNP:
	case EM_SETTABSTOPS:
	case EM_SETWORDBREAKPROC:
	case EM_UNDO:
	case WM_GETFONT:
	case WM_SETFONT:
		// We don't support these methods.
		Assert(false);
		lnRet = LB_ERR;
		return true;

	case EM_GETLIMITTEXT:
		lnRet = GetLimitText();
		return true;

	case FW_EM_GETLINE:
		lnRet = GetLine(wp, (ITsString **)lp);
		return true;

	case EM_GETLINECOUNT:
		lnRet = GetLineCount();
		return true;

	case EM_GETMARGINS:
		lnRet = GetMargins();
		return true;

	case FW_EM_GETSTYLE:
		GetStyle((StrUni *)lp, (COLORREF *)wp);
		return true;

	case EM_GETSEL:
		lnRet = GetSel((int *)wp, (int *)lp);
		return true;

	case EM_LINEFROMCHAR:
		lnRet = LineFromChar(wp);
		return true;

	case EM_LINEINDEX:
		lnRet = LineIndex(wp);
		return true;

	case EM_LINELENGTH:
		lnRet = LineLength(wp);
		return true;

	case EM_LINESCROLL:
		LineScroll(lp, wp);
		return true;

	case FW_EM_REPLACESEL:
		ReplaceSel((ITsString *)lp);
		return true;

	case EM_SCROLL:
		lnRet = ::SendMessage(m_hwnd, WM_VSCROLL, LOWORD(wp), 0);
		return true;

	case EM_SCROLLCARET:
		ScrollCaret();
		return true;

	case EM_SETLIMITTEXT:
		SetLimitText(wp);
		return true;

	case EM_SETMARGINS:
		SetMargins(wp, LOWORD(lp), HIWORD(lp));
		return true;

	case EM_SETREADONLY:
		SetReadOnly(wp);
		return true;

	case EM_SETSEL:
		SetSel(wp, lp);
		return true;

	case FW_EM_SETSTYLE:
		SetStyle((StrUni *)lp, (COLORREF)wp);
		return true;

	case WM_GETTEXTLENGTH:
		lnRet = GetTextLength();
		return true;

	case FW_EM_GETTEXT:
		GetText((ITsString **)lp);
		return true;

	case FW_EM_SETTEXT:
		SetText((ITsString *)lp);
		return true;

	case WM_COPY:
		Copy();
		return true;

	case WM_CUT:
		Cut();
		return true;

	case WM_PASTE:
		Paste();
		return true;

	case WM_HSCROLL:
		if (!OnHScroll(LOWORD(wp), HIWORD(wp), (HWND)lp))
		{
			::SendMessage(::GetParent(m_hwnd), WM_COMMAND,
				MAKEWPARAM(::GetDlgCtrlID(m_hwnd), EN_HSCROLL), (LPARAM)m_hwnd);
		}
		return true;

	case WM_VSCROLL:
		if (!OnVScroll(LOWORD(wp), HIWORD(wp), (HWND)lp))
		{
			::SendMessage(::GetParent(m_hwnd), WM_COMMAND,
				MAKEWPARAM(::GetDlgCtrlID(m_hwnd), EN_VSCROLL), (LPARAM)m_hwnd);
		}
		return true;

	case WM_KILLFOCUS:
		if (!OnKillFocus((HWND)wp))
		{
			::SendMessage(::GetParent(m_hwnd), WM_COMMAND,
				MAKEWPARAM(::GetDlgCtrlID(m_hwnd), EN_KILLFOCUS), (LPARAM)m_hwnd);
		}
		return true;

	case WM_SETFOCUS:
		if (!OnSetFocus((HWND)wp))
		{
			::SendMessage(::GetParent(m_hwnd), WM_COMMAND,
				MAKEWPARAM(::GetDlgCtrlID(m_hwnd), EN_SETFOCUS), (LPARAM)m_hwnd);
		}
		return true;
		// Calling SuperClass here causes two OnSetFocus calls for each OnKillFocus.
		//return SuperClass::FWndProc(wm, wp, lp, lnRet);

	case WM_CHAR:
		fRet = false;
		if (wp == VK_TAB)  // '\t'
		{
			fRet = OnCharTab();
		}
		else if (wp == VK_RETURN) // '\r'
		{
			fRet = OnCharEnter();
		}
		else if (wp == VK_ESCAPE) // '\33'
		{
			fRet = OnCharEscape();
		}
		if (fRet)
			return fRet;
		else
			return SuperClass::FWndProc(wm, wp, lp, lnRet);

	case WM_LBUTTONDOWN:
	case WM_LBUTTONUP:
	case WM_MBUTTONDOWN:
	case WM_MBUTTONUP:
	case WM_RBUTTONDOWN:
	case WM_RBUTTONUP:
	case WM_MOUSEMOVE:
		if (HasToolTip())
		{
			// Notify the tooltip belonging to the parent toolbar of the mouse message.
			Assert(m_hwndToolTip);
			MSG msg;
			msg.hwnd = m_hwnd; // ::GetParent(m_hwnd);
			msg.message = wm;
			msg.wParam = wp;
			msg.lParam = lp;
			::SendMessage(m_hwndToolTip, TTM_RELAYEVENT, 0, (LPARAM)&msg);
		}
		break;

	default:
		break;
	}
	return SuperClass::FWndProc(wm, wp, lp, lnRet);
}
Ejemplo n.º 15
0
void Operation::add()
{
    string sno, sname, sex;
    Gender ssex;
    int sage;
    cout << "请输入学生相关信息:" << endl;
    cout << "学号:"; cin >> sno;
    vector<Student>::iterator it1;
    for(it1 = svec.begin(); it1 != svec.end(); it1++){
        if(it1->sno == sno){
            cout << "该学生信息已存在,请重试!" << endl;
            return ;
        }
    }
    cout << "姓名:"; cin >> sname;
    cout << "性别[男/女]:"; cin >> sex;
    if(sex == "男")
        ssex = MALE;
    else if(sex == "女")
        ssex = FEMALE;
    else{
        cout << "Input Error!!!" << endl;
        return ;
    }
    cout << "年龄:"; cin >> sage;
    Student stu(sno, sname, ssex, sage);
    char ch1;
    while(1){
        cout << "是否继续输入成绩[y/n]?";
        cin >> ch1;
        getchar();
        if(ch1 == 'Y' || ch1 == 'y'){
            char ch2;
            vector< pair<string,float> > sc;
            string cno;
            float score;
            while(1){
                cout << "请输入课程号: "; cin >> cno;
                cout << "请输入成绩: "; cin >> score;

                int flag = 0;
                vector<Course>::iterator it;
                for(it = cvec.begin(); it != cvec.end(); it++){
                    if(it->cno == cno){
                        flag = 1;
                        break;
                    }
                }
                if(flag != 1){
                    cout << "不存在这门课程,请重新输入!" << endl;
                    cout << "是否结束输入成绩[y/n]?";
                    cin >> ch2;
                    if(ch2 == 'Y' || ch2 == 'y')
                        break;
                    else
                       continue;
                }

                sc.push_back(pair<string, float> (cno,score));
                while(1){
                    cout << "是否继续输入成绩[y/n]?";
                    cin >> ch2; getchar();
                    if(ch2 == 'Y' || ch2 == 'y'){
                        break;
                    }
                    else if(ch2 == 'N' || ch2 == 'n'){
                        break;
                    }
                    else{
                        cout << "输入不正确,请重新选择!" << endl;
                    }
                }
                if(ch2 == 'N' || ch2 == 'n') break;
            }
            //保存信息,break
            for(unsigned i = 0; i < sc.size(); i++){
                //fin >> cno >> cscore;
                stu.score += sc[i].second;
                vector<Course>::iterator it;
                for(it = cvec.begin(); it != cvec.end(); it++){
                    if(it->cno == sc[i].first){
                        stu.credit += it->ccredit;
                        Score score(*it, stu, sc[i].second);
                        scvec.push_back(score);
                        break;
                    }
                }
            }
            svec.push_back(stu);
            break;
        }
Ejemplo n.º 16
0
/*----------------------------------------------------------------------------------------------
	Set the list of style objects to the (fake) styles attribute of StText.
	Called from the XML import routine.
----------------------------------------------------------------------------------------------*/
HRESULT WpStylesheet::AddLoadedStyles(HVO * rghvoNew, int chvo, int hvoNextStyle)
{
	int cst;
	CheckHr(m_qsda->get_VecSize(khvoText, kflidStText_Styles, &cst));
	WpDaPtr wpda = dynamic_cast<WpDa *>(m_qsda.Ptr());
	// Note: we are clobbering any existing styles.
	HRESULT hr = wpda->CacheReplace(khvoText, kflidStText_Styles, 0, cst, rghvoNew, chvo);

	m_vhcStyles.Clear();
	bool fFoundNormal= false;
	for (int ihvo = 0; ihvo < chvo; ihvo++)
	{
		HvoClsid hc;
		hc.clsid = kclidStStyle;
		hc.hvo = rghvoNew[ihvo];
		m_vhcStyles.Push(hc);

		SmartBstr sbstrName;
		CheckHr(m_qsda->get_UnicodeProp(hc.hvo, kflidStStyle_Name, &sbstrName));
		StrUni stuName(sbstrName.Chars());
		if (stuName == g_pszwStyleNormal)
			fFoundNormal = true;
	}

	m_hvoNextStyle = max(m_hvoNextStyle, hvoNextStyle);

	if (!fFoundNormal)
		AddNormalParaStyle();

#if 0
	// Old code for deleting only duplicates.

	int cstNew;
	CheckHr(m_qsda->get_VecSize(khvoText, kflidStText_Styles, &cstNew));
	Assert(cstNew == cst + chvo);

	//	If there are any styles with duplicate names, delete the first
	//	(previously existing) one.

	Vector<int> vihvoDelete;
	Vector<StrUni> vstuStyleNames;
	for (ihvo = 0; ihvo < m_vhcStyles.Size(); ihvo++)
	{
		SmartBstr sbstrName;
		CheckHr(m_qsda->get_UnicodeProp(m_vhcStyles[ihvo].hvo, kflidStStyle_Name, &sbstrName));
		StrUni stu(sbstrName.Chars());
		vstuStyleNames.Push(stu);
	}
	Assert(vstuStyleNames.Size() == m_vhcStyles.Size());

	for (ihvo = 0; ihvo < vstuStyleNames.Size() - 1; ihvo++)
	{
		for (int ihvo2 = ihvo + 1; ihvo2 < vstuStyleNames.Size(); ihvo2++)
		{
			if (vstuStyleNames[ihvo] == vstuStyleNames[ihvo2])
			{
				vihvoDelete.Push(ihvo);
				break;
			}
		}
	}

	//	Delete the duplicates; do it backwards so the indices stay valid.
	for (int iihvo = vihvoDelete.Size(); --iihvo >= 0; )
	{
		HVO ihvoToDelete = vihvoDelete[iihvo];
		m_vhcStyles.Delete(ihvoToDelete);
		CheckHr(wpda->CacheReplace(khvoText, kflidStText_Styles, ihvoToDelete, ihvoToDelete+1,
			NULL, 0));
	}

	CheckHr(m_qsda->get_VecSize(khvoText, kflidStText_Styles, &cstNew));
	Assert(cstNew == cst + chvo - vihvoDelete.Size());

#endif

	return hr;
}
Ejemplo n.º 17
0
/*----------------------------------------------------------------------------------------------
	Return the text string that gets shown to the user when this object needs to be displayed.
	This is the method for displaying the name of a single reference. This view shows the
	name for an RnGenericRec consisting of the type of record, hyphen, title, hyphen,
	creation date. "Subevent - Fishing for pirana - 3/22/2001"

	@param pguid Pointer to a database object's assigned GUID.
	@param pptss Address of a pointer to an ITsString COM object used for returning the text
					string.

	@return S_OK, E_POINTER, or E_FAIL.
----------------------------------------------------------------------------------------------*/
STDMETHODIMP CleRecVc::GetStrForGuid(BSTR bstrGuid, ITsString ** pptss)
{
	Assert(false);  // rework

	BEGIN_COM_METHOD;
	ChkComBstrArg(bstrGuid);
	ChkComOutPtr(pptss);

	if (BstrLen(bstrGuid) != 8)
		ReturnHr(E_INVALIDARG);

	CleMainWnd * pcmw = dynamic_cast<CleMainWnd *>(AfApp::Papp()->GetCurMainWnd());
	AssertPtr(pcmw);
	CleLpInfo * plpi = dynamic_cast<CleLpInfo *>(pcmw->GetLpInfo());
	AssertPtr(plpi);

	HVO hvo = plpi->GetDbInfo()->GetIdFromGuid((GUID *)bstrGuid);

	CustViewDaPtr qcvd;
	plpi->GetDataAccess(&qcvd);
	AssertPtr(qcvd);
	int clid;
	HVO hvoOwn;
	int64 ntim;
	ITsStringPtr qtssTitle;
	CheckHr(qcvd->get_IntProp(hvo, kflidCmObject_Class, &clid));
	CheckHr(qcvd->get_ObjectProp(hvo, kflidCmObject_Owner, &hvoOwn));
			// REVIEW KenZ(RandyR) Whey are DN flids in this app?
	CheckHr(qcvd->get_TimeProp(hvo, kflidRnGenericRec_DateCreated, &ntim));
	CheckHr(qcvd->get_StringProp(hvo, kflidRnGenericRec_Title, &qtssTitle));

	int stid;
			// REVIEW KenZ(RandyR) Whey are DN flids in this app?
	if (clid == kclidRnEvent)
	{
		if (pcmw->GetRootObj() == hvoOwn)
			stid = kstidEvent;
		else
			stid = kstidSubevent;
	}
	else if (clid == kclidRnAnalysis)
	{
		if (pcmw->GetRootObj() == hvoOwn)
			stid = kstidAnalysis;
		else
			stid = kstidSubanalysis;
	}
	StrUni stu(stid);
	StrUni stuSep(kstidSpHyphenSp);

	ITsStrFactoryPtr qtsf;
	ITsIncStrBldrPtr qtisb;
	qtsf.CreateInstance(CLSID_TsStrFactory);
	CheckHr(qtsf->GetIncBldr(&qtisb));
	CheckHr(qtisb->Append(stu.Bstr()));

	CheckHr(qtisb->Append(stuSep.Bstr()));
	CheckHr(qtisb->AppendTsString(qtssTitle)); // The title.
	CheckHr(qtisb->Append(stuSep.Bstr()));
	// Leave the date blank if a date doesn't exist.
	if (ntim)
	{
		// Convert the date to a system date.
		SilTime tim = ntim;
		SYSTEMTIME stim;
		stim.wYear = (unsigned short) tim.Year();
		stim.wMonth = (unsigned short) tim.Month();
		stim.wDay = (unsigned short) tim.Date();

		// Then format it to a time based on the current user locale.
		achar rgchDate[50]; // Tuesday, August 15, 2000		mardi 15 août 2000
		::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &stim, NULL, rgchDate, 50);
		stu = rgchDate;
		CheckHr(qtisb->Append(stu.Bstr()));
	}
	CheckHr(qtisb->GetString(pptss));

	return S_OK;

	END_COM_METHOD(g_fact2, IID_IVwViewConstructor)
}
Ejemplo n.º 18
0
/*----------------------------------------------------------------------------------------------
	This is the method for displaying the name of a single reference. This view shows the
	name for an RnGenericRec consisting of the type of record, hyphen, title, hyphen,
	creation date. "Subevent - Fishing for pirana - 3/22/2001"
	@param pvwenv Pointer to the view environment.
	@param hvo The id of the object we are displaying.
	@param frag Identifies the part of the view we are currently displaying.
	@return HRESULT indicating success (S_OK), or failure (E_FAIL).
----------------------------------------------------------------------------------------------*/
STDMETHODIMP CleRecVc::Display(IVwEnv * pvwenv, HVO hvo, int frag)
{
	BEGIN_COM_METHOD;
	ChkComArgPtr(pvwenv);

	Assert(false);  // Is this needed for poss lists?

	switch (frag)
	{
	case kfrRefName:
	case kfrListName:
		{
			SmartBstr bstrClass = L"UnLoaded";
			ITsStringPtr qtss;
			ITsStringPtr qtssTitle;

			// Make sure data is loaded.
			LoadDataFor(pvwenv, hvo, frag);
			AfMainWnd * pafw = AfApp::Papp()->GetCurMainWnd();
			AssertPtr(pafw);
			AfLpInfo * plpi = pafw->GetLpInfo();
			AssertPtr(plpi);
			AfDbInfo * pdbi = plpi->GetDbInfo();
			AssertPtr(pdbi);

#define HYPERLINK_CHANGE
#ifdef HYPERLINK_CHANGE
			// Update the string with the new object.
			GUID uid;
			if (!pdbi->GetGuidFromId(hvo, uid))
				ReturnHr(E_FAIL);

			StrUni stuData;
			OLECHAR * prgchData;
			// Make large enough for a guid plus the type character at the start.
			stuData.SetSize(isizeof(GUID) / isizeof(OLECHAR) + 1, &prgchData);
			*prgchData = kodtNameGuidHot;
			memmove(prgchData + 1, &uid, isizeof(uid));

			ITsPropsFactoryPtr qtpf;
			ITsPropsBldrPtr qtpb;
			ITsTextPropsPtr qttp;
			ITsStrFactoryPtr qtsf;

			qtpf.CreateInstance(CLSID_TsPropsFactory);
			CheckHr(qtpf->GetPropsBldr(&qtpb));
			CheckHr(qtpb->SetIntPropValues(ktptWs, ktpvDefault, pdbi->UserWs()));
			CheckHr(qtpb->SetStrPropValue(ktptObjData, stuData.Bstr()));
			CheckHr(qtpb->GetTextProps(&qttp));
			qtsf.CreateInstance(CLSID_TsStrFactory);
			OLECHAR chObj = kchObject;
			CheckHr(qtsf->MakeStringWithPropsRgch(&chObj, 1, qttp, &qtss));

			CheckHr(pvwenv->OpenSpan());
			// REVIEW KenZ(RandyR) Whey are DN flids in this app?
			int flid = kflidRnGenericRec_Title;
			CheckHr(pvwenv->NoteDependency(&hvo, &flid, 1));
			CheckHr(pvwenv->AddString(qtss)); // The class name.
			CheckHr(pvwenv->CloseSpan());
#else // !HYPERLINK_CHANGE
			int clid;
			HVO hvoOwn;
			int64 ntim;
			int ws = pdbi->UserWs();
			ISilDataAccessPtr qsda;
			CheckHr(pvwenv->get_DataAccess(&qsda));
			AssertPtr(qsda);
			CheckHr(qsda->get_IntProp(hvo, kflidCmObject_Class, &clid));
			CheckHr(qsda->get_ObjectProp(hvo, kflidCmObject_Owner, &hvoOwn));
			// REVIEW KenZ(RandyR) Whey are DN flids in this app?
			CheckHr(qsda->get_TimeProp(hvo, kflidRnGenericRec_DateCreated, &ntim));
			CheckHr(qsda->get_StringProp(hvo, kflidRnGenericRec_Title, &qtssTitle));

			int stid;
			// Sharon! Not needed?
//			if (clid == kclidRnEvent)
//			{
//				if (plpi->GetRnId() == hvoOwn)
//					stid = kstidEvent;
//				else
//					stid = kstidSubevent;
//			}
//			else if (clid == kclidRnAnalysis)
//			{
//				if (plpi->GetRnId() == hvoOwn)
//					stid = kstidAnalysis;
//				else
//					stid = kstidSubanalysis;
//			}
			StrUni stu(stid);
			StrUni stuSep(kstidSpHyphenSp);
			ITsStrFactoryPtr qtsf;
			qtsf.CreateInstance(CLSID_TsStrFactory);
			CheckHr(qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss));

			CheckHr(pvwenv->OpenSpan());
			CheckHr(pvwenv->AddString(qtss)); // The class name.
			CheckHr(qtsf->MakeStringRgch(stuSep.Chars(), stuSep.Length(), ws, &qtss));
			CheckHr(pvwenv->AddString(qtss)); // The separator
			//CheckHr(pvwenv->AddString(qtssTitle)); // The title.
			// The following gives the title of the owning object instead of the ref.
			CheckHr(pvwenv->AddStringProp(kflidRnGenericRec_Title, this)); // The title.
			CheckHr(pvwenv->AddString(qtss)); // The separator
			// Leave the date blank if a date doesn't exist.
			if (ntim)
			{
				// Convert the date to a system date.
				SilTime tim = ntim;
				SYSTEMTIME stim;
				stim.wYear = (unsigned short) tim.Year();
				stim.wMonth = (unsigned short) tim.Month();
				stim.wDay = (unsigned short) tim.Date();

				// Then format it to a time based on the current user locale.
				char rgchDate[50]; // Tuesday, August 15, 2000		mardi 15 août 2000
				::GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &stim, NULL, rgchDate, 50);
				stu = rgchDate;
				CheckHr(qtsf->MakeStringRgch(stu.Chars(), stu.Length(), ws, &qtss));
				CheckHr(pvwenv->AddString(qtss)); // The date.
			}
			CheckHr(pvwenv->CloseSpan());
#endif // HYPERLINK_CHANGE

			break;
		}
	}

	return S_OK;

	END_COM_METHOD(g_fact2, IID_IVwViewConstructor)
}
Ejemplo n.º 19
0
	void MockBackupDelegates::AddOpenDb(const OLECHAR * pszDbName)
	{
		StrUni stu(pszDbName);
		m_vstuOpenDbs.Push(stu);
	}
Ejemplo n.º 20
0
/*----------------------------------------------------------------------------------------------
	The hwnd has been attached.
----------------------------------------------------------------------------------------------*/
void HwMainWnd::PostAttach(void)
{
	StrAppBuf strbT; // Holds temp string

	// Set the default caption text.
	strbT.Load(kstidHelloWorld);
	::SendMessage(m_hwnd, WM_SETTEXT, 0, (LPARAM)strbT.Chars());

	// This creates the main frame window and sets it as the current window. It also
	// creates the rebar and status bar.
	SuperClass::PostAttach();

	const int rgrid[] =
	{
		kridTBarStd,
		kridHwTBarIns,
		kridHwTBarTools,
		kridHwTBarWnd,
	};

	GetMenuMgr()->LoadToolBars(rgrid, SizeOfArray(rgrid));

	// Create the menu bar.
	AfMenuBarPtr qmnbr;
	qmnbr.Create();
	qmnbr->Initialize(m_hwnd, kridAppMenu, kridAppMenu, "Menu Bar");
	m_vqtlbr.Push(qmnbr.Ptr());

	// Create the toolbars.
	AfToolBarPtr qtlbr;

	qtlbr.Create();
	qtlbr->Initialize(kridTBarStd, kridTBarStd, "Standard");
	m_vqtlbr.Push(qtlbr);

	qtlbr.Create();
	qtlbr->Initialize(kridHwTBarIns, kridHwTBarIns, "Insert");
	m_vqtlbr.Push(qtlbr);

	qtlbr.Create();
	qtlbr->Initialize(kridHwTBarTools, kridHwTBarTools, "Tools");
	m_vqtlbr.Push(qtlbr);

	qtlbr.Create();
	qtlbr->Initialize(kridHwTBarWnd, kridHwTBarWnd, "Window");
	m_vqtlbr.Push(qtlbr);

	// Load window settings.
	LoadSettings(NULL, false);

	g_app.AddCmdHandler(this, 1);
	m_qstbr->RestoreStatusText();

	// Create the client window.
	const int kwidChild = 1000;
	WndCreateStruct wcs;
	wcs.InitChild("STATIC", m_hwnd, kwidChild);
	m_qwndHost.Create();
	m_qwndHost->CreateAndSubclassHwnd(wcs);

	Assert(memcmp(&CLSID_SaCtrlEvent, &DIID__DSAEvents, isizeof(GUID)) == 0);

	CComCoClass<SaCtrlEvent>::CreateInstance(&m_qsce);
	IUnknownPtr qunk;
	CheckHr(AtlAxCreateControlEx(L"SA.SACtrl.1", m_qwndHost->Hwnd(), NULL, NULL, &qunk,
		DIID__DSAEvents, (IUnknown *)m_qsce.Ptr()));
	CheckHr(qunk->QueryInterface(DIID__DSA, (void **)&m_qctrl));
	m_qsce->Init(this, m_qctrl);
	StrUni stu(L"baluchi.wav");
	CheckHr(m_qctrl->put_WaveFile(stu.Bstr()));
	CheckHr(m_qctrl->raw_SetGraphs(GRAPH_MAGNITUDE, GRAPH_MAGNITUDE));
	CheckHr(m_qctrl->put_ShowContextMenu(false));
	CheckHr(m_qctrl->put_ShowCursorContextMenu(false));

	::ShowWindow(m_qwndHost->Hwnd(), SW_SHOW);

	g_app.AddCmdHandler(this, 1);
}