⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpiconfigdlg.cpp

📁 MPICH是MPI的重要研究,提供了一系列的接口函数,为并行计算的实现提供了编程环境.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
	    sprintf(pszStr, "lset hosts=%s", hoststring);	    WriteString(sock, pszStr);	}	if (m_bTempChk)	{	    sprintf(pszStr, "lset temp=%s", m_pszTempDir);	    WriteString(sock, pszStr);	}	if (m_bLaunchTimeoutChk)	{	    sprintf(pszStr, "lset timeout=%d", m_nLaunchTimeout);	    WriteString(sock, pszStr);	}	WriteString(sock, "done");	easy_closesocket(sock);    }    SetGreenLight();    SetCursor(hOldCursor);    if (m_bShowHostConfig)	GetHostConfig(NULL);}#elsevoid CMPIConfigDlg::OnSetBtn(){    DWORD dwThreadID;    UpdateData();    m_hSetBtnThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)SetBtnThread, this, 0, &dwThreadID);}#endifvoid CMPIConfigDlg::OnSetOneBtn() {    int i;    char pszStr[4096];    char hoststring[4096] = "";    char host[100];    SOCKET sock;    CString sHost;    int num_hosts;    UpdateData();    num_hosts = m_host_list.GetCount();    if (num_hosts == 0)	return;    if (m_bHostsChk == FALSE && m_bTempChk == FALSE && m_bLaunchTimeoutChk == FALSE)	return;        int index = m_host_list.GetCurSel();    if (index == LB_ERR)	return;    m_host_list.GetText(index, sHost);    if (m_bNeedPassword)    {	if (m_bUseDefault)	    strcpy(m_pszPhrase, MPD_DEFAULT_PASSPHRASE);	else	    strcpy(m_pszPhrase, m_password);    }    SetYellowLight();    HCURSOR hOldCursor = SetCursor( LoadCursor(NULL, IDC_WAIT) );        // Create the host list    QVS_Container qvs;    for (i=0; i<num_hosts; i++)    {	if (m_host_list.GetText(i, host) == LB_ERR)	{	    SetRedLight();	    SetCursor(hOldCursor);	    MessageBox("GetText failed", "Error", MB_OK);	    return;	}	qvs.encode_string(host);    }    qvs.output_encoded_string(hoststring, 4096);        if (ConnectToHost(sHost, m_nPort, m_pszPhrase, &sock))    {	if (m_bHostsChk)	{	    sprintf(pszStr, "lset hosts=%s", hoststring);	    WriteString(sock, pszStr);	}	if (m_bTempChk)	{	    sprintf(pszStr, "lset temp=%s", m_pszTempDir);	    WriteString(sock, pszStr);	}	if (m_bLaunchTimeoutChk)	{	    sprintf(pszStr, "lset timeout=%d", m_nLaunchTimeout);	    WriteString(sock, pszStr);	}	WriteString(sock, "done");	easy_closesocket(sock);    }    else    {	SetRedLight();	SetCursor(hOldCursor);	if (m_bShowHostConfig)	    GetHostConfig(NULL);	return;    }    SetGreenLight();    SetCursor(hOldCursor);    if (m_bShowHostConfig)	GetHostConfig(NULL);}LRESULT CMPIConfigDlg::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) {    if (message == WM_USER + 2)    {	GetHostConfig(NULL);    }    if (message == WM_USER + 3)    {	m_set_btn.EnableWindow(FALSE);	m_set_one_btn.EnableWindow(FALSE);	m_edit_add_btn.EnableWindow(FALSE);    }    if (message == WM_USER + 4)    {	m_set_btn.EnableWindow();	m_set_one_btn.EnableWindow();	m_edit_add_btn.EnableWindow();    }    return CDialog::WindowProc(message, wParam, lParam);}void CMPIConfigDlg::OnEditAddBtn() {    UpdateData();        if (m_hostname.GetLength() != 0)    {		CString str;	int n = m_host_list.GetCount();	if (n != LB_ERR)	{	    bool bFound = false;	    for (int i=0; i<n; i++)	    {		m_host_list.GetText(i, str);		if (str.CompareNoCase(m_hostname) == 0)		{		    bFound = true;		    //break;		}	    }	    if (!bFound)	    {		m_host_list.InsertString(-1, m_hostname);	    }	}    }}int CMPIConfigDlg::OnVKeyToItem(UINT nKey, CListBox* pListBox, UINT nIndex) {    if (*pListBox == m_host_list)    {	if (nKey == VK_DELETE)	{	    int index = m_host_list.GetCurSel();	    if (index != LB_ERR)	    {		m_host_list.DeleteString(index);		if (m_host_list.SetCurSel(index) == LB_ERR)		    m_host_list.SetCurSel(index-1);		SetRedLight();	    }	}    }	return CDialog::OnVKeyToItem(nKey, pListBox, nIndex);}void CMPIConfigDlg::OnClose() {    if (m_hSetBtnThread)    {	TerminateThread(m_hSetBtnThread, -1);	m_hSetBtnThread = NULL;    }    easy_socket_finalize();	CDialog::OnClose();}void CMPIConfigDlg::OnSize(UINT nType, int cx, int cy) {    CDialog::OnSize(nType, cx, cy);    if (nType != SIZE_MINIMIZED)    {	if (m_nMinWidth <= cx || m_nMinHeight <= cy)	{	    if (cx < m_nMinWidth)		cx = m_nMinWidth;	    if (cy < m_nMinHeight)		cy = m_nMinHeight;	    r1Static.Resize(cx, cy);	    rList.Resize(cx, cy);	    rOk.Resize(cx, cy);	    rCancel.Resize(cx, cy);	    	    rHostConfig.Resize(cx, cy);	    	    Invalidate();	}    }}void CMPIConfigDlg::OnPhraseRadio() {    m_bUseDefault = false;    m_pwd_ctrl.EnableWindow();    SetRedLight();}void CMPIConfigDlg::OnDefaultPwdRadio() {    m_bUseDefault = true;    m_pwd_ctrl.EnableWindow(FALSE);    SetRedLight();}void CMPIConfigDlg::OnTempChk() {    UpdateData();        if (m_bTempChk)	m_TempEdit.EnableWindow();    else	m_TempEdit.EnableWindow(FALSE);    SetRedLight();}void CMPIConfigDlg::OnTimeoutChk() {    UpdateData();        if (m_bLaunchTimeoutChk)	m_LaunchTimeoutEdit.EnableWindow();    else	m_LaunchTimeoutEdit.EnableWindow(FALSE);    SetRedLight();}void CMPIConfigDlg::SetRedLight(){    m_stoplight_red.ShowWindow(SW_SHOW);    m_stoplight_yellow.ShowWindow(SW_HIDE);    m_stoplight_green.ShowWindow(SW_HIDE);}void CMPIConfigDlg::SetGreenLight(){    m_stoplight_red.ShowWindow(SW_HIDE);    m_stoplight_yellow.ShowWindow(SW_HIDE);    m_stoplight_green.ShowWindow(SW_SHOW);}void CMPIConfigDlg::SetYellowLight(){    m_stoplight_red.ShowWindow(SW_HIDE);    m_stoplight_yellow.ShowWindow(SW_SHOW);    m_stoplight_green.ShowWindow(SW_HIDE);}void CMPIConfigDlg::OnShowHostChk() {    UpdateData();    m_host_config_edit.EnableWindow(m_bShowHostConfig);    if (m_bShowHostConfig)	GetHostConfig(NULL);}void CMPIConfigDlg::OnSelchangeHostList() {    UpdateData();    if (m_bShowHostConfig)    {	CString host;	int index = m_host_list.GetCurSel();	if (index != LB_ERR)	{	    m_host_list.GetText(index, host);	    GetHostConfig(host);	}    }}void CMPIConfigDlg::GetHostConfig(const char *host){    CString sHost;    SOCKET sock;    char pszStr[MAX_CMD_LENGTH] = "mpd not installed";    UpdateData();    if (host == NULL)    {	int index = m_host_list.GetCurSel();	if (index == LB_ERR)	    return;	m_host_list.GetText(index, sHost);    }    else	sHost = host;    if (m_bNeedPassword)    {	if (m_bUseDefault)	    strcpy(m_pszPhrase, MPD_DEFAULT_PASSPHRASE);	else	    strcpy(m_pszPhrase, m_password);    }        HCURSOR hOldCursor = SetCursor( LoadCursor(NULL, IDC_WAIT) );        if (ConnectToHost(sHost, m_nPort, m_pszPhrase, &sock))    {	WriteString(sock, "config");	ReadString(sock, pszStr);	WriteString(sock, "done");	easy_closesocket(sock);		m_host_config = sHost + ":\n";	m_host_config += pszStr;	m_host_config.Replace("\n", "\r\n");    }    else    {	m_host_config = sHost + ":\r\n" + pszStr;    }        SetCursor(hOldCursor);    UpdateData(FALSE);}void CMPIConfigDlg::OnSelectBtn() {    CFindHostsDlg dlg;    if (dlg.DoModal() == IDOK)    {	QVS_Container qvs;	char str[100];	m_host_list.ResetContent();	qvs.decode_string((char*)(LPCTSTR)dlg.m_encoded_hosts);	if (qvs.first(str, 100))	{	    m_host_list.AddString(str);	    while (qvs.next(str, 100))	    {		m_host_list.AddString(str);	    }	}    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -