Exemplo n.º 1
0
void CTypeLibTreeView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
	if (lHint != NULL || (lHint & UPDF_NOTREEVIEW))
		return ;

	TRACE(_T("OnUpdate\n")) ;
	m_tree.SetRedraw( FALSE ) ;
	BeginWaitCursor() ;

	m_tree.DeleteAllItems() ;
	m_hTypeInfos = NULL ;

	TV_INSERTSTRUCT tvis ;
	tvis.hParent = TVI_ROOT ;
	tvis.hInsertAfter = TVI_FIRST ;
	tvis.item.mask = TVIF_TEXT | TVIF_CHILDREN | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE ;
	tvis.item.iImage = CTreeItem::typeTypeLib ;
	tvis.item.iSelectedImage = tvis.item.iImage + 1 ;

	HRESULT hr = S_OK ;
	CString strError ;
	TRY
	{
		CTypeLibWnd* pFrame = (CTypeLibWnd*)GetParent()->GetParent() ;
		if (pFrame == NULL)
		{
			strError = _T("Internal Application error.");
			AfxThrowMemoryException() ;
		}

		if (pFrame->m_fGroupByKind)
		{
			tvis.item.cChildren = 1 ;
		}
		else
		{
			tvis.item.cChildren = m_ptlb->GetTypeInfoCount() ;
		}

		BSTR    bstrName = NULL ;
		BSTR    bstrDoc = NULL ;
		BSTR    bstrHelp = NULL ;
		DWORD   dwHelpID ;
		hr = m_ptlb->GetDocumentation( MEMBERID_NIL, &bstrName, &bstrDoc, &dwHelpID, &bstrHelp ) ;
		if (FAILED(hr))
		{
			strError = _T("ITypeLib::GetDocumentation failed.") ;
			AfxThrowMemoryException() ;
		}

		#pragma warning (suppress: 6014)
		CTreeItem* pItem = new CTreeItem(&m_tree) ;
		if (pFrame->m_fGroupByKind)
			pItem->m_Type = CTreeItem::typeTypeLib2 ;
		else
			pItem->m_Type = CTreeItem::typeTypeLib ;
		pItem->SetTypeLib( m_ptlb ) ;
		m_ptlb->AddRef() ;
		tvis.item.lParam = (LPARAM)pItem ;

		COLE2CT lpszName(bstrName);
		if (::SysStringLen(bstrDoc) != 0)
		{
			COLE2CT lpszDoc(bstrDoc);
			CString str;
			str.Format( _T("%s (%s)"), lpszName, lpszDoc);
			tvis.item.pszText = str.GetBuffer(0);
			m_hTypeInfos = m_tree.InsertItem( &tvis ) ;
			str.ReleaseBuffer(-1) ;
		}
		else
		{
			tvis.item.pszText = (LPTSTR)lpszName;
			m_hTypeInfos = m_tree.InsertItem( &tvis ) ;
		}

		::SysFreeString( bstrName ) ;
		::SysFreeString( bstrDoc ) ;
		::SysFreeString( bstrHelp ) ;
	}
	CATCH(CException, pException)
	{
	}
	END_CATCH

	if (m_hTypeInfos)
	{
		m_tree.Expand( m_hTypeInfos, TVE_EXPAND ) ;
		//m_tree.SelectItem( m_hTypeInfos ) ;
	}

	m_tree.SetRedraw( TRUE ) ;
	EndWaitCursor() ;
}
void CGyfxyHostView::InitListHeadCtrl(void)
{
	int i =0;
	int iStrLen = 0;
	HRESULT hr= S_OK;
	_variant_t  str;
	CStringArray ColNameArray;
	BeginWaitCursor() ;
	try
	{ 
		_RecordsetPtr Rs ;
		CString strSQL;
		Rs.CreateInstance("ADODB.Recordset");
		strSQL = _T("select * from 工业分析仪数据");
		if(Rs->State==adStateOpen)
			Rs->Close();
		//IADORecordBindingPtr pIRB(pRsIED);
		hr = Rs->Open(strSQL.AllocSysString(),
			theApp.pConn.GetInterfacePtr(),
			adOpenStatic,
			adLockOptimistic,
			-1);	
		TESTHR(hr);
		//得到所有字段名称
		GetAllFieldName(Rs,&ColNameArray); 
		SetRedraw(FALSE);
		//清除所有数据
		DWORD ExStyle = m_ListCtrl.GetExtendedStyle() ;
		m_ListCtrl.SetExtendedStyle(ExStyle| LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);//
		m_ListCtrl.EnableToolTips(TRUE); 
		m_ListCtrl.DeleteAllItems();
		//清除所有标题
		do
		{
			m_ListCtrl.DeleteColumn(0);
		}
		while(m_ListCtrl.GetHeaderCtrl()->GetItemCount()>0); 
		//////////////////////////////////////////////////////////// 
		//写字段标题
		CRect rect;
		m_ListCtrl.GetWindowRect(&rect);

		int w = rect.Width() - 2;
		int i;
		int total_cx = 0;
		LV_COLUMN lvcolumn;
		memset(&lvcolumn, 0, sizeof(lvcolumn));

		w = w - ::GetSystemMetrics(SM_CXVSCROLL);	// width of vertical scroll bar

		// add columns
		for (i = 0;i<ColNameArray.GetSize() ; i++)
		{ 

			lvcolumn.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_TEXT | LVCF_WIDTH;
			lvcolumn.pszText = (TCHAR*)(LPCTSTR)ColNameArray.GetAt(i);
			lvcolumn.fmt =  LVCFMT_CENTER;

			lvcolumn.iSubItem = i;
			lvcolumn.cx = (i==ColNameArray.GetSize()-1) ? w - total_cx - 2 : (w * 8) / 64;
			total_cx += lvcolumn.cx;
			m_ListCtrl.InsertColumn(i, &lvcolumn);
		}

		///////////////////////////////////////////////////////////////
		int rowcnt = pRdb->attrib.m_btMaxSampleCnt;
		for(int i=0;i<rowcnt;i++)        //增加24个样品
		{			
			m_ListCtrl.InsertItem(i,_T(""));		
			//增加样位好
			CString str(_T("")) ;
			str.Format(_T("%d"),i+1);
			m_ListCtrl.SetItemText(i,1,str);
			//增加Edit CheckBox
			m_ListCtrl.SetEdit(i, 0); 
			m_ListCtrl.SetItemText(i,0,_T("样品编号"));

		}
		
		/////////////////////////////////////////////////////////////
		// create the image list from bitmap resource
		VERIFY(m_ListCtrl.m_cImageList.Create(18, 18, ILC_COLOR24, 3, 1));
		CBitmap bm;
		bm.LoadBitmap(IDB_CHECKBOXES);
		m_ListCtrl.m_cImageList.Add(&bm, RGB(255, 0, 255));
		m_ListCtrl.m_HeaderCtrl.SetImageList(&m_ListCtrl.m_cImageList);
		////CheckBox
		HDITEM hditem;
		TCHAR szText[40];
		hditem.pszText = szText;
		hditem.cchTextMax = 40;
		for (i = 0; i < m_ListCtrl.m_HeaderCtrl.GetItemCount(); i++)
		{
			hditem.mask = HDI_IMAGE | HDI_FORMAT|HDI_TEXT;
			m_ListCtrl.m_HeaderCtrl.GetItem(i, &hditem);
			hditem.fmt |=  HDF_IMAGE;
			if(CString(szText)==_T("水分")
				||CString(szText)==_T("挥发分")
				||CString(szText)==_T("灰分"))  
				hditem.iImage = XHEADERCTRL_UNCHECKED_IMAGE;
			else
				hditem.iImage = XHEADERCTRL_NO_IMAGE;

			m_ListCtrl.m_HeaderCtrl.SetItem(i, &hditem);
		} 
		//////////////////////////////////////设置字体高度
		CFont* pFont = (CFont*)m_ListCtrl.GetFont();
		if (pFont) {
			LOGFONT lf;
			pFont->GetLogFont(&lf);
			lf.lfHeight = -16;
			m_listFont.CreateFontIndirect(&lf);
			m_ListCtrl.SetFont(&m_listFont);
		} 
		///////////////////////////////////////////////////
		SetRedraw(TRUE);                    

	}
	catch(_com_error &e)
	{
		dump_com_error(e);
	}
	EndWaitCursor();
}
void T3000_Default_MainView::OnBnClickedApplybutton()
{
    int m_nListenPort=0;
    BeginWaitCursor();
    //m_nListenPort	
    CString strText;
    m_ListenPort.GetWindowText(strText);
    if(!strText.IsEmpty())
        m_nListenPort=_wtoi(strText);
    if(m_nListenPort>=12767)
    {
        AfxMessageBox(_T("The listen port number is too big, please change it."));
        return;
    }
    if(m_nListenPort<=0)
    {
        AfxMessageBox(_T("The listen port number must be greater than 0!"));
        return;
    }
    write_one(g_tstat_id,75,m_nListenPort);
    product_register_value[75]=m_nListenPort;
    BYTE address1,address2,address3,address4;
    m_ipaddress.GetAddress(address1,address2,address3,address4);

    int sel = m_ip_model.GetCurSel ();
     write_one(g_tstat_id,61,sel);

    int CO2_NET_MODBUS_IP_ADDRESS_GHOST_START = 62 ;
    int n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START,address1);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START+1,address2);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START+2,address3);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_IP_ADDRESS_GHOST_START+3,address4);
    int CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START = 66;
    m_Subnet_Mask.GetAddress(address1,address2,address3,address4);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+0,address1);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+1,address2);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+2,address3);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_SUBNET_MASK_ADDRESS_GHOST_START+3,address4);
    m_GatewayAddress.GetAddress(address1,address2,address3,address4);
    int CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START =   70;
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START,address1);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START+1,address2);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START+2,address3);
    n=write_one(g_tstat_id,CO2_NET_MODBUS_GATEWAY_ADDRESS_GHOST_START+3,address4);
    int CO2_NET_MODBUS_ENABLE_GHOST = 76;
    n=write_one(g_tstat_id,CO2_NET_MODBUS_ENABLE_GHOST,1);

    Sleep(5*1000);



    CMainFrame* pPraent=(CMainFrame*)GetParent();

    CString strBuilding,strSubBuilding;
    strBuilding=pPraent->m_strCurMainBuildingName;
    strSubBuilding=pPraent->m_strCurSubBuldingName;
    CString strIP,strPort;
    strPort.Format(_T("%d"),product_register_value[75]);
    // BYTE address1,address2,address3,address4;
    m_ipaddress.GetAddress(address1,address2,address3,address4);
    strIP.Format(_T("%d.%d.%d.%d"),address1,address2,address3,address4);
    if(g_CommunicationType==1)//TCP
    {
       /* int nPort;
        nPort=_wtoi(strPort);*/
        //m_strIP=build_info.strIp; 
        g_CommunicationType=1;
        SetCommunicationType(g_CommunicationType);
        BOOL bOk=FALSE;
        bOk=Open_Socket2(strIP,m_nListenPort);
        CString strInfo;

        strInfo.Format((_T("Open IP:%s successful")),strIP);//prompt info;
        SetPaneString(1,strInfo);
        if(bOk)
        {
            try
			{
			CppSQLite3DB SqliteDBBuilding;
			CppSQLite3Table table;
			CppSQLite3Query q;
			SqliteDBBuilding.open((UTF8MBSTR)g_strCurBuildingDatabasefilePath);


                CString strSql;
                //strSql.Format(_T("update Building set Ip_Address='%s' where Ip_Address='%s'"),strIP,pPraent->m_strIP);
                //t_pCon->Execute(strSql.GetString(),NULL,adCmdText);

                // ¸Änode
                CString strSID;

                strSID.Format(_T("%d"), get_serialnumber());
                strSql.Format(_T("update ALL_NODE set Bautrate='%s',Com_Port='%s' where Serial_ID='%s'"),strIP,strPort,strSID); //bautrate ·ÅIP
                SqliteDBBuilding.execDML((UTF8MBSTR)strSql);

                SqliteDBBuilding.closedb();

            }
            catch(_com_error *e)
            {
                AfxMessageBox(e->ErrorMessage());
            }

            pPraent->m_strIP=strIP;
            pPraent->ScanTstatInDB();

        }
        else
        {

        }



    }
    EndWaitCursor();
}
Exemplo n.º 4
0
void CSettingDlg::OnCompress() 
{
	CString			fullpathname, filename, errmsg, compname, compfullpath;
	DWORD dwsize;
	CFile file;
	std::string		addfilename;
	_VERSION_INFO* pInfo = NULL;

	UpdateData(TRUE);

	int count = m_FileList.GetCount();
	if( count == 0 ) return;

	BeginWaitCursor();
	compname.Format("patch%.4d.zip", m_nVersion );
	compfullpath.Format("%s\\%s", m_strDefaultPath, compname);
	
	set<int>::iterator Iter;

	while( !m_RepackingVersionList.empty() ) {
		Iter = m_RepackingVersionList.begin();
		m_RepackingVersionList.erase(Iter);
	}

	m_ZipArchive.Open(compfullpath, CZipArchive::create);

	SetDlgItemText(IDC_STATUS, "Compressing..");

	for(int i=0; i<count; i++ ) {
		m_FileList.GetText( i, filename );

		fullpathname = m_strDefaultPath;
		fullpathname += filename;
		if( !file.Open( fullpathname, CFile::modeRead ) ) {
			errmsg.Format("%s File Open Fail", filename);
			AfxMessageBox(errmsg);
			continue;
		}
		dwsize = file.GetLength();
		file.Close();
		
		if(!m_ZipArchive.AddNewFile(fullpathname, m_strDefaultPath, -1, dwsize)) {
			errmsg.Format("%s File Compress Fail", filename);
			AfxMessageBox(errmsg);
			continue;
		}
		m_Progress.SetPos(i*100/count);

		addfilename = (const char*)(LPCTSTR)filename;
		pInfo = m_pMain->m_VersionList.GetData(addfilename);
		if( pInfo )
			m_RepackingVersionList.insert(pInfo->sHistoryVersion);
	}
	SetDlgItemText(IDC_STATUS, "Compressed");

	m_ZipArchive.Close();

	if( !m_bCompressOption ) {	// Current Version 만 압축
		if( !m_RepackingVersionList.empty() )
			RepackingHistory();
	}

	m_Progress.SetPos(100);

	EndWaitCursor();
}
Exemplo n.º 5
0
void CAcctHierDlg::BuildAcct()  
//Builds the hierarchy with the accounts in the tree.  Stores the External Ids in m_textAlaBuf, the 
//parents in m_iParents and the account numbers in m_iParentLoc all with respective indices for later use.
//m_tvstruct is a structure of attributes for a particular element in the tree.  This function called by 
//default from Oninitdialog() and each one of the different view modes.

{
	int					iAccountCategory;
	int					iLookChildren;
	int					iParentId;
	int					Index=0;
	int					iGalParent;
	int					is_business; //CAMqa78557
	GAL_ACCTSELECTION	lpSelectedObjects=NULL;
	GAL_ACCTSELECTION	lpCurrentObject=NULL;
	/*DENqa20465*/
	GAL_ACCTCATEGORY_KEY AcctCategory=NULL; 
    GAL_ACCTCATEGORY lpSelectedObj=NULL;
	/*DENqa20465*/
	/* CAMqa83432 */
	m_textAlaBuf = new TCHAR[m_iMaxAlaProducts][GAL_PPCOMPONENTELEM_DESCRIPTION_TEXT_LEN ];
	m_rghItem = new HTREEITEM[m_iMaxAlaProducts];
	m_iParents = new int[m_iMaxAlaProducts];
	m_iParentLoc = new int[m_iMaxAlaProducts];
	memset( m_textAlaBuf,0,sizeof( m_textAlaBuf) * m_iMaxAlaProducts);
	memset( m_iParentLoc,0, sizeof(int) * m_iMaxAlaProducts);
	memset( m_iParents,0, sizeof(int) * m_iMaxAlaProducts); 
	m_TreeHier.DeleteAllItems();
	m_TreeHier.SetImageList( m_pimagelist, TVSIL_NORMAL );
	iLookChildren = 0 ;
	iParentId = 0;
	m_iParsedItem = 0;
	m_iMaxAccounts = 0;
	BeginWaitCursor();
	m_iParentLoc[iLookChildren ]= m_iCIRoot ;
	//Get all the accounts in hierarchy based on hierarchy id
	while ( m_iParentLoc[ iLookChildren ] != 0 )
	{
		if ( m_iParsedItem != 0 )
		{
			iParentId = m_iParentLoc[ iLookChildren++ ] ;
		}
		if (galHierListAcctSelection(m_hAPI, 
									 iParentId, 
									 m_iHierId, 
									 &m_nSelectedObjects, 
									 &lpSelectedObjects, 
									 &m_lpError ) != GAL_FAILURE )
		{

			// bail gracefully if there's more than FIND_ROW_COUNT accounts
			if (m_nSelectedObjects > m_iMaxAlaProducts)
			{
				CGuiMsg::GuiMessage( GUIMSG_ACCOUNT_HIERARCHY_TOO_LARGE);
				galDeleteObjects(lpSelectedObjects);
				return;
			}

			//Loop through the retrieved list and add each element into the tree
			for ( lpCurrentObject = lpSelectedObjects;  lpCurrentObject;
			lpCurrentObject = ( GAL_ACCTSELECTION ) galNextObject( lpCurrentObject ))
			{

				galGetAcctSelection_account_no( lpCurrentObject, &m_iAccountNo, &m_lpError );
				galGetAcctSelection_server_id( lpCurrentObject, &iGalParent, &m_lpError);
				galGetAcctSelection_external_id( lpCurrentObject, m_textExtId, &m_lpError );
				galGetAcctSelection_bill_company(lpCurrentObject, m_textCoName , &m_lpError);
				galGetAcctSelection_account_category( lpCurrentObject, &iAccountCategory, &m_lpError );
				/*DENqa20465*/
			   if ((AcctCategory = (GAL_ACCTCATEGORY_KEY) malloc(sizeof(GAL_ACCTCATEGORY_KEY))) == NULL)
			   {
                   GuiError(__FILE__, __LINE__, "Could not allocate memory for account category key.");
				   return;
         	   }
	
				AcctCategory->account_category = iAccountCategory;
				if(galSelectAcctCategory(GetHandle(),AcctCategory,&lpSelectedObj,&m_lpError)== GAL_FAILURE )
				{
					GuiError(__FILE__, __LINE__, "Error occured during 'select acct category' task.");
					delete AcctCategory;
					return;
				}
				else
				{
					if(galGetAcctCategory_is_business(lpSelectedObj,&is_business,&m_lpError)== GAL_FAILURE )
					{
						GuiError(__FILE__, __LINE__, "Error occured during 'is_business' task.");  
						delete AcctCategory;
						galDeleteObjects(lpSelectedObj);
						return;
					}
				}

				delete AcctCategory;
				galDeleteObjects(lpSelectedObj);
   				/*DENqa20465*/
				m_iParents[m_iParsedItem] = iGalParent;
				m_iParentLoc[m_iParsedItem] = m_iAccountNo;
				m_iMaxAccounts++;
				//Set the Parent of the particular element of tree	
				if (iGalParent == NULL)
				{ 
					m_tvstruct.hParent =  NULL ; 
				}				
				else
				{
					for ( int iPIndex = 0; iGalParent != m_iParentLoc[iPIndex]; iPIndex++ );
					m_tvstruct.hParent = m_rghItem[ iPIndex ];
				}  
				m_tvstruct.hInsertAfter = TVI_LAST;
				strncpy(m_textAlaBuf[m_iParsedItem],m_textExtId,GAL_PPCOMPONENTELEM_DESCRIPTION_TEXT_LEN);
				strcat (m_textExtId, "      " );
				//If the account is residential then get first and last name otherwise get company name
				//Start of CAMqa78557
				//if ( iAccountCategory == RESIDENTIAL )
				if (!is_business) 
				//End of CAMqa78557
				{	
					/* Begin DENqa06670 */
					TCHAR textFirstName[GAL_ACCTEXTID_BILL_FIRST_NAME_LEN ];
					TCHAR textLastName[GAL_ACCTEXTID_BILL_LAST_NAME_LEN];
					/*End DENqa06670 */
					galGetAcctSelection_bill_lname(lpCurrentObject, textLastName, &m_lpError);
					galGetAcctSelection_bill_fname(lpCurrentObject, textFirstName, &m_lpError);
					strcat( m_textExtId, textLastName );
					if (!ArbI18N::IsChinese())//DENqa30280
					{
						strcat(m_textExtId, ArbI18N::translateToUTF8(GetArborLabels()->GetNameSeparator()));
					}
					strcat(m_textExtId, textFirstName);
				}  
				else
				{
					galGetAcctSelection_bill_company(lpCurrentObject, m_textCoName , &m_lpError);
					strcat( m_textExtId, m_textCoName );
				}
				
				char tempExtId[GAL_SISELECTION_EXTERNAL_ID_LEN*2];
				strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));
				m_tvstruct.item.pszText = tempExtId;					  
				m_tvstruct.item.mask = TVIF_TEXT | TVIF_IMAGE |TVIF_SELECTEDIMAGE ;
				m_tvstruct.item.iImage = 6;//Bitmap index returned from Add function in oninitdialog
				m_tvstruct.item.iSelectedImage = 6;
				m_rghItem[m_iParsedItem]= m_TreeHier.InsertItem( &m_tvstruct );
				m_TreeHier.EnsureVisible( m_rghItem[m_iParsedItem] );
				//Save the tree address of the element within Custinfo and highlight that item
				if ( m_iAccountNo == m_iCIRoot )
				{
					m_pInAcct = m_rghItem[m_iParsedItem];				      
					m_TreeHier.SelectItem( m_rghItem[m_iParsedItem] );
				}

				m_iParsedItem++;			  

			}
			if( lpSelectedObjects )
				galDeleteObjects(lpSelectedObjects);
			lpSelectedObjects = NULL;
		}  
		else
		  GuiError(__FILE__, __LINE__,
			   "Could not set Account List.");
	}
	UpdateData( FALSE ); 	

	EndWaitCursor();

}
Exemplo n.º 6
0
void CAcctHierDlg::BuildPkgComp( int iParentIndex)
//From BuildPkgs this function is called after buildacct to add the components to 
//the appropriate package already in the tree.  
{ 
	int		bAddUnattachedComp=FALSE;
	GAL_PPCOMPONENTSEL   lpSelectedObjects=NULL;
	GAL_PPCOMPONENTSEL	lpCurrentObject=NULL;
	TV_INSERTSTRUCT		tvstruct;

	BeginWaitCursor();
	//camqa92934 
	char alacarte[80];
	memset(alacarte,0,80) ;
	strcpy(alacarte,ArbI18N::translateToUTF8(GetIntlString(IDS_ALL_A_LA_CARTE))) ;

 
	//Get the list of Components based on m_iPackageInstance and m_iPackageInstance fro database
	if ( galListPPComponentSel(m_hAPI, bAddUnattachedComp, &m_iPackageInstance, &m_iPackageInstanceServ, 
			&m_nSelectedObjects, &lpSelectedObjects, &m_lpError,alacarte) != GAL_FAILURE )
	{
		// bail gracefully if there's more than FIND_ROW_COUNT package instances
		if (m_nSelectedObjects > m_iMaxAlaProducts)
		{
			CGuiMsg::GuiMessage( GUIMSG_HIERARCHY_PACKAGE_COMPONENTS_UNDISPLAYABLE);
			galDeleteObjects(lpSelectedObjects);
			return;
		}

		//Loop through list of components extracted from database
		for ( lpCurrentObject = lpSelectedObjects;  lpCurrentObject;
			lpCurrentObject = ( GAL_PPCOMPONENTSEL ) galNextObject( lpCurrentObject ))
		{
			//Add all components to the tree setting attributes first
			galGetPPComponentSel_display_value( lpCurrentObject, m_textExtId, &m_lpError);
			//CAMqa58078
                        galGetPPComponentSel_status(lpCurrentObject,&m_iComponentStatus, &m_lpError);
                        //CAMqa58078
			tvstruct.hParent = m_rghItem[ iParentIndex-1 ];
			tvstruct.hInsertAfter = TVI_LAST;
			char tempExtId[GAL_SISELECTION_EXTERNAL_ID_LEN*2];
			strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));
			//CAMqa58078
                    if  (m_iComponentStatus == 2)
					{
                        strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));//CAMqa72212
						tvstruct.item.pszText = strcat(tempExtId,GetIntlString(IDS_DISCONNECTED)); //CAMqa84527
					    
					}
                        else
			tvstruct.item.pszText = 	tempExtId;				  
			tvstruct.item.mask = TVIF_TEXT | TVIF_IMAGE |TVIF_SELECTEDIMAGE;
			tvstruct.item.iImage = 12;//Bitmap index returned from Add function in oninitdialog
			tvstruct.item.iSelectedImage = 12;
			m_rghItem[m_iParsedItem]= m_TreeHier.InsertItem( &tvstruct );
			m_TreeHier.EnsureVisible( m_rghItem[m_iParsedItem] );
			m_iParsedItem++;
		}      
		if( lpSelectedObjects )
			galDeleteObjects(lpSelectedObjects);
		lpSelectedObjects = NULL;
	}
	else
	      GuiError(__FILE__, __LINE__,
		       "Could not set Component List.");

	EndWaitCursor();
}
Exemplo n.º 7
0
 void CAcctHierDlg::BuildPkgs()  
 //Called by OnOrgPpkgsMode after Buildacct to add the Packages to the appropriate accounts 
 //already in the tree
 {	 
	
	int                   *iPackageId=NULL;
	GAL_PRODUCTPKGS       lpSelectedObjects=NULL;
	GAL_PRODUCTPKGS			  lpCurrentObject=NULL;

	BeginWaitCursor();
	//Loop for all accounts in the tree
	for ( int index = 0 ; m_iParentLoc[index] != 0; index++ ) 
	{
		m_lpFSC = galNewFilterSortCriteria( GAL_PRODUCTPKGS_TYPE );  
		//Extract the  product packages out of the database for each account
		if ( galListProductPkgs(m_hAPI, 
								m_lpFSC, 
								m_iHierId, 
								&m_iParentLoc[index], 
							    iPackageId, 
								&m_nSelectedObjects, 
								&lpSelectedObjects, 
								&m_lpError) != GAL_FAILURE )
		{
			// bail gracefully if there's more than FIND_ROW_COUNT service instances
			if (m_nSelectedObjects > m_iMaxAlaProducts)
			{
				CGuiMsg::GuiMessage( GUIMSG_HIERARCHY_PACKAGES_UNDISPLAYABLE);
				galDeleteObjects(lpSelectedObjects);
				return;
			}

			//Loop for all packages for each account and add them into tree 
			for ( lpCurrentObject = lpSelectedObjects;  lpCurrentObject;
					lpCurrentObject = ( GAL_PRODUCTPKGS ) galNextObject( lpCurrentObject ))
			{
				galGetProductPkgs_display_value(lpCurrentObject, m_textExtId, &m_lpError );
				galGetProductPkgs_package_instance_id(lpCurrentObject, &m_iPackageInstance , &m_lpError);
				galGetProductPkgs_package_instance_id_serv(lpCurrentObject, &m_iPackageInstanceServ, &m_lpError);
				//CAMqa58078
                                galGetProductPkgs_package_status(lpCurrentObject, &m_ipackagestatus,&m_lpError);
                                //CAMqa58078
				m_tvstruct.hParent = m_rghItem[ index ];
				m_tvstruct.hInsertAfter = TVI_LAST;
				char tempExtId[GAL_SISELECTION_EXTERNAL_ID_LEN*2];
				strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));
				//CAMqa58078
                                if  (m_ipackagestatus == 2)
								{
									strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));//CAMqa72212
									m_tvstruct.item.pszText =       strcat(tempExtId,GetIntlString(IDS_DISCONNECTED)); //CAMqa84527
								    
								}
                                else
                                //CAMqa58078
				m_tvstruct.item.pszText = 	tempExtId;				  
				m_tvstruct.item.mask = TVIF_TEXT | TVIF_IMAGE |TVIF_SELECTEDIMAGE ;
				m_tvstruct.item.iImage = 0;//Bitmap index returned from Add function in oninitdialog
				m_tvstruct.item.iSelectedImage = 0;
				m_rghItem[m_iParsedItem]= m_TreeHier.InsertItem( &m_tvstruct );
				m_TreeHier.EnsureVisible( m_rghItem[m_iParsedItem] );
				m_iParsedItem++;
				if ( m_iBuildComponents )
					BuildPkgComp ( m_iParsedItem );
			}      
			if( lpSelectedObjects )
				galDeleteObjects(lpSelectedObjects);   
			lpSelectedObjects = NULL;
		}	       
		else
			GuiError(__FILE__, __LINE__, 
				 "Could not set Account Product Packages from Data Base.");
		galDeleteFilterSortCriteria(m_lpFSC);   
		//		  if( lpSelectedObjects )
		//			  galDeleteObjects(lpSelectedObjects);   
		//		  lpSelectedObjects = NULL;
	}
	// TODO: Add your control notification handler code here

	UpdateData( FALSE );    
	EndWaitCursor();
 }
void CNetworkControllView::OnBnClickedButtonUpdatetimeserver()
{
	BeginWaitCursor();

	BOOL bSyncSuccess = FALSE;
	CComboBox* pCbx = (CComboBox*)GetDlgItem(IDC_COMBO_TIMESERVERLIST);
	CString strTimeServer;
	//pCbx->GetLBText(pCbx->GetCurSel(), strTimeServer);
	pCbx->GetWindowText(strTimeServer);

	CString strTips = _T("NC is synchronizing internet time server, please wait.");
	SetPaneString(1, strTips);



	USES_CONVERSION;
	LPCSTR szIP = W2A(strTimeServer);
	struct hostent* pHost = NULL;
	SOCKADDR_IN sockaddr;
	//TestFunc(strTimeServer);

	//return;
	//////////////////////////////////////////////////////////////////////////
	if(isalpha(szIP[0]))  // by domain name
	{
	
		pHost = gethostbyname(szIP);
		if(pHost != NULL)
		{
			sockaddr.sin_addr.S_un.S_addr = (*(DWORD*)pHost->h_addr_list[0]);
		}
		else
		{
			AfxMessageBox(_T("Time synchronization needs in the internet, please check your net work settings."));
			return;
		}

	}
	else // by ip
	{		
		sockaddr.sin_addr.S_un.S_addr =inet_addr(szIP);
	}
	// write to nc
	int n=write_one(g_tstat_id,178, BYTE(sockaddr.sin_addr.S_un.S_un_b.s_b1 ));
	n=write_one(g_tstat_id,179,BYTE(sockaddr.sin_addr.S_un.S_un_b.s_b2 ));
	n=write_one(g_tstat_id,180,BYTE(sockaddr.sin_addr.S_un.S_un_b.s_b3 ));
	n=write_one(g_tstat_id,181,BYTE(sockaddr.sin_addr.S_un.S_un_b.s_b4 ));

	n=write_one(g_tstat_id,177,6); // 命令寄存器,同步命令

	Sleep(5000);  // 等待NC 同步
	AddNewTimeServer(strTimeServer);

	int nCount = 0;
	while(nCount < 5)
	{
		int nRet = Read_One(m_IDaddress, 199);
		if(nRet == 1)
		{
			bSyncSuccess = TRUE;
			break;
		}
		nCount++;
		Sleep(1000);
	}

	if (bSyncSuccess)
	{
		strTips = _T("NC synchronize internet time server success.");		
	}
	else
	{
		strTips = _T("NC synchronize internet time server failed.");		
	}
	AfxMessageBox(strTips);
	SetPaneString(1, strTips);


	EndWaitCursor();
	
}
Exemplo n.º 9
0
void GravadorControllerDlg::OnBnClickedGravar()
{
	DWORD dwTimeGravacao;

	dwTimeGravacao = GetTickCount();
	// desabilita todos os botões
	ControlaBotoes(FALSE, FALSE, FALSE);

	BeginWaitCursor();
	if (!bTentandoDeNovo)
		m_eBox.SetWindowText(_T(""));
	ShowMess(_T("Iniciando gravação. Aguarde"));

	multiPlex.SetaInterfaceST(TRUE);

	multiPlex.ControlaLeds(ldAMARELO);
	SetLed(ledAMARELO);

	CString cS;
	if (bTentandoDeNovo)
	{
		nTentativas++;
		cS.Format(_T("Tentativa número: %d."), nTentativas);
		ShowMess(cS);
	}

	BOOL bResultFinal;

	bResultFinal = TRUE;

	if (cS.GetLength() > 0)
		ShowMess(cS);

	multiPlex.SetaInterfaceST(TRUE);

	if (bResultFinal)
	{
		nContOk++;
		cS.Format(_T("%d"), nContOk);
		m_sTestados.SetWindowText(cS);

		multiPlex.ControlaLeds(ldVERDE);
		SetLed(ledVERDE_OK);
	}
	else
	{
		multiPlex.ControlaLeds(ldVERMELHO);
		SetLed(ledVERMELHO);
	}

	if ( bResultFinal )
		adm.AtualizaDadosPrn(&dadosImpressora);


	if (bResultFinal)
	{
		impressora.ImprimeEtiqueta(TRUE, &dadosImpressora, TRUE);


		BOOL bFim;
		adm.AtualizaInfo(nContOk, nContErros, &bFim);

		nTentativas = 0;

		ProcessaFimDeProducao(bFim);

		bTentandoDeNovo = FALSE;
	}
	else
	{
		// habilita botão parar e tenta de novo
		ControlaBotoes(TRUE, TRUE, FALSE);
		bTentandoDeNovo = TRUE;
	}

	EndWaitCursor();

	m_debugLog.Log(LOG_INFO, _T("Tempo total de gravacao (ms): %d"), GetTickCount() - dwTimeGravacao);
}
Exemplo n.º 10
0
/////////////////////////////////////////////////////////////////////////////
// CApp initialization
BOOL CApp::InitInstance()
{
	//check scanner	key
	if(IsMonacoSCAN())
		mhasDongle = TRUE;
	else
		mhasDongle = FALSE;

	mhasDongle = TRUE;
	if(!mhasDongle)
	{
		AfxMessageBox("Can't find the programed key, please make sure the key is programed correctly and attached to the parallel port.");

		return FALSE;
	}

	// CG: The following block was added by the Splash Screen component.
	{
		CCommandLineInfo cmdInfo;
		ParseCommandLine(cmdInfo);

		CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
	}
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the main registry key under which our settings are stored.
	SetRegistryKey( _T("Monaco Systems") );
	// Note: MFC automatically puts the name of the app as another level,
	// unless you use the code below to reset the default m_pszProfileName
	// First free the string allocated by MFC at CWinApp startup.
	// The string is allocated before InitInstance is called.
	free((void*)m_pszProfileName);
	// The CWinApp destructor will free the memory.
	m_pszProfileName = _tcsdup(_T("MonacoSCAN\\1.0"));

	// All profile reading and writing should use the version as the "section"
	// e.g. WriteProfileString("Settings\\SubHeading", "entry", "name");

	// Register any ActiveX controls
	BeginWaitCursor();
	char szFolder[255];
	GetSystemDirectory(szFolder, sizeof(szFolder));
	CString szPath;
	szPath = szFolder;
	szPath += "\\imw32o30.ocx";
	RegisterServer((LPCSTR)szPath, FALSE/*bSilent*/, FALSE/*bUnregister*/);
	szPath = szFolder;
	szPath += "\\label.ocx";
	RegisterServer((LPCSTR)szPath, FALSE/*bSilent*/, FALSE/*bUnregister*/);
	EndWaitCursor();

	CMainDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
Exemplo n.º 11
0
BOOL CApp::InitInstance()
{
	//check scanner
	if(IsColorGenie())
		mhasDongle = TRUE;
	else
		mhasDongle = FALSE;

	mhasDongle = TRUE;

	// CG: The following block was added by the Splash Screen component.
	{
		CCommandLineInfo cmdInfo;
		ParseCommandLine(cmdInfo);

		CSplashWnd::EnableSplashScreen(cmdInfo.m_bShowSplash);
	}
	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	// Change the main registry key under which our settings are stored.
	SetRegistryKey( _T("Monaco Systems") );
	// Note: MFC automatically puts the name of the app as another level,
	// unless you use the code below to reset the default m_pszProfileName
	// First free the string allocated by MFC at CWinApp startup.
	// The string is allocated before InitInstance is called.
	free((void*)m_pszProfileName);
	// The CWinApp destructor will free the memory.
	m_pszProfileName = _tcsdup(_T("ColorGenie\\1.0"));

	// All profile reading and writing should use the version as the "section"
	// e.g. WriteProfileString("Settings\\SubHeading", "entry", "name");

	//no MRU list will be maintained
	//LoadStdProfileSettings(0);  // Load standard INI file options (including MRU)
	LoadStdProfileSettings(9);  // Load standard INI file options (including MRU)

	// Register any ActiveX controls
	BeginWaitCursor();
	char szFolder[255];
	GetSystemDirectory(szFolder, sizeof(szFolder));
	CString szPath;
	szPath = szFolder;
	szPath += "\\msflxgrd.ocx";
	UINT i = RegisterServer((LPCSTR)szPath, FALSE/*bSilent*/, FALSE/*bUnregister*/);
	EndWaitCursor();

	// Register the application's document templates.  Document templates
	//  serve as the connection between documents, frame windows and views.

//	To switch back to an SDI app,
//	1.) uncomment the folowing code,
//	2.) base CMainFrame off of CFrameWnd (not CMDIFrameWnd)
//	3.) remove the CChildFrame class (no longer needed)
//	4.) get rid of the extra menu resource IDR_ICCTYPE
//	CSingleDocTemplate* pDocTemplate = new CSingleDocTemplate(
//		IDR_MAINFRAME,
//		RUNTIME_CLASS(CProfileDoc),
//		RUNTIME_CLASS(CMainFrame),       // main SDI frame window
//		RUNTIME_CLASS(CProfileView));
	CMultiDocTemplate* pDocTemplate = new CMultiDocTemplate(
		IDR_ICCTYPE,
		RUNTIME_CLASS(CProfileDoc),
		RUNTIME_CLASS(CChildFrame),      // custom MDI frame window
		RUNTIME_CLASS(CProfileView));
	AddDocTemplate(pDocTemplate);

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;
	m_pMainWnd = pMainFrame;

	// Parse command line for standard shell commands, DDE, file open
	CCommandLineInfo cmdInfo;
	cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;
	ParseCommandLine(cmdInfo);

	// Dispatch commands specified on the command line
	if (!ProcessShellCommand(cmdInfo))
		return FALSE;

	// The one and only window has been initialized, so show and update it.
	m_pMainWnd->ShowWindow(SW_SHOW);
	m_pMainWnd->UpdateWindow();

	m_pMainWnd->DragAcceptFiles( TRUE );

	//load icc files for showing the reference colors
	mhasCmm	= LoadCmm();
	if(!mhasCmm)
		AfxMessageBox(IDS_ERR_NO_CMM);

	return TRUE;
}
Exemplo n.º 12
0
BOOL CWordPadDoc::DoSave(LPCTSTR pszPathName, BOOL bReplace /*=TRUE*/)
	// Save the document data to a file
	// pszPathName = path name where to save document file
	// if pszPathName is NULL then the user will be prompted (SaveAs)
	// note: pszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = pszPathName;
	int nOrigDocType = m_nDocType;  //saved in case of SaveCopyAs or failure

	//  newName     bWrite  type    result
	//  empty       TRUE    -       SaveAs dialog
	//  empty       FALSE   -       SaveAs dialog
	//  notempty    TRUE    -       nothing
	//  notempty    FALSE   W6      warn (change to wordpad, save as, cancel)
	//  notempty    FALSE   other   warn (save as, cancel)

	BOOL bModified = IsModified();

	ScanForConverters();

	BOOL bSaveAs = FALSE;
	if (newName.IsEmpty())
		bSaveAs = TRUE;
	else if (!doctypes[m_nDocType].bWrite)
	{
		if (m_nDocType == RD_WINWORD6)
		{
			//      DWORD nHelpIDs[] =
			//      {
			//          0, 0
			//      };
			int nRes = CButtonDialog::DisplayMessageBox(
				MAKEINTRESOURCE(IDS_WORD6_WARNING), AfxGetAppName(),
				MAKEINTRESOURCE(IDS_WORD6_WARNING_BUTTONS),
				MB_ICONQUESTION, 1, 2);
			if (nRes == 0) // Save
				SetDocType(RD_WORDPAD, TRUE);
			else if (nRes == 2) // Cancel
				return FALSE;
			else
				bSaveAs = TRUE;
			// else save as
		}
		else //
		{
			if (AfxMessageBox(IDS_SAVE_UNSUPPORTED,
				MB_YESNO | MB_ICONQUESTION) != IDYES)
			{
				return FALSE;
			}
			else
				bSaveAs = TRUE;
		}
	}

	if (m_lpRootStg == NULL && IsTextType(m_nDocType) &&
		!GetView()->IsFormatText())
	{
		// formatting changed in plain old text file
		DWORD nHelpIDs[] =
		{
			0, IDH_WORDPAD_WORD6FILE,
			0, IDH_WORDPAD_FORMATTED,
			0, IDH_WORDPAD_TEXTFILE,
			0, 0
		};
		CString str;
		AfxFormatString1(str, IDS_SAVE_FORMAT_TEXT, GetTitle());
		int nRes = CButtonDialog::DisplayMessageBox(str,
			MAKEINTRESOURCE(AFX_IDS_APP_TITLE),
			MAKEINTRESOURCE(IDS_TF_BUTTONS), MB_ICONQUESTION, 0, 3, nHelpIDs);
		if (nRes == 3)
			return FALSE;
		int nDocType = (nRes == 0) ? RD_DEFAULT:    //Word 6
					(nRes == 1) ? RD_RICHTEXT : //RTF
					RD_TEXT;                    //text
		if (IsTextType(m_nDocType) && nDocType != RD_TEXT)
			SetDocType(nDocType, TRUE);
		if (nDocType != RD_TEXT)
			bSaveAs = TRUE;
	}

	GetView()->GetParentFrame()->RecalcLayout();
	if (bSaveAs)
	{
		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
			int iBad = newName.FindOneOf(_T(" #%;/\\"));    // dubious filename
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			newName += GetExtFromType(m_nDocType);
		}

		int nDocType = m_nDocType;
		if (!theApp.PromptForFileName(newName,
			bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY,
			OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, &nDocType))
		{
			SetDocType(nOrigDocType, TRUE);
			return FALSE;       // don't even try to save
		}
		SetDocType(nDocType, TRUE);
	}

	BeginWaitCursor();
	if (!OnSaveDocument(newName))
	{
		if (pszPathName == NULL)
		{
			// be sure to delete the file
			TRY
			{
				CFile::Remove(newName);
			}
			CATCH_ALL(e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs\n");
			}
			END_CATCH_ALL
		}
		// restore orginal document type
		SetDocType(nOrigDocType, TRUE);
		EndWaitCursor();
		return FALSE;
	}
Exemplo n.º 13
0
BOOL CDialogStrVars::OnInitDialog() 
{
	BeginWaitCursor();
	POSITION pos;
	CStringVar* pStrVarCur;
	CMainFrame* pMainFrame = (CMainFrame*) AfxGetMainWnd();	
	CNLB_BldrDoc* pDoc;
	int iStrVarCount;
	CString strVarBodyToSetInLV;
	CString strCR;
	CString strCRSymbolic;

	CDialog::OnInitDialog();	

	HICON hIconNew = AfxGetApp()->LoadIcon(IDR_STRVAR);	// Уничтожать иконку, созданную LoadIcon, вроде не надо.
	CString lpszColumnHeading;	// Имя колонки ListView

	//Установим стили для ListView...
	m_lstStrVars.SetExtendedStyle(LVS_EX_LABELTIP | 
									   LVS_EX_FULLROWSELECT | 
									   LVS_EX_GRIDLINES);
	
	//Делаем колонки ListView...
	lpszColumnHeading.LoadString(IDS_UITXT_LV_STRVAR_NAME);		
	m_lstStrVars.InsertColumn(0,
		(LPCTSTR) lpszColumnHeading,LVCFMT_LEFT,
		ILVSTRVARS_COL0_WIDTH,
		0);

	lpszColumnHeading.LoadString(IDS_UITXT_LV_STRVAR_BODY);		
	m_lstStrVars.InsertColumn(1,
		(LPCTSTR) lpszColumnHeading,LVCFMT_LEFT,
		ILVSTRVARS_COL1_WIDTH,
		0);
	
	m_ImListStrVars.Create(GetSystemMetrics(SM_CXSMICON), 
								GetSystemMetrics(SM_CYSMICON), 
								ILC_COLORDDB, 
								1, 
								1);
	m_iIconPos = m_ImListStrVars.Add(hIconNew);
	m_pImListStrVarsOld = m_lstStrVars.SetImageList(&m_ImListStrVars, LVSIL_SMALL);	

	if (pMainFrame)
	{
		pDoc = (CNLB_BldrDoc*) pMainFrame->GetActiveDocument();
		ASSERT_VALID(pDoc);
		if (pDoc)
		{			
			iStrVarCount = pDoc->m_lstStrVars.GetCount();
			pos = pDoc->m_lstStrVars.GetHeadPosition();			
			for (int i = 0; i < iStrVarCount; i++)
			{
				pStrVarCur = pDoc->m_lstStrVars.GetAt(pos);
				m_lstStrVars.InsertItem(LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT,
						i,
						pStrVarCur->Get_strStrVarName(),
						0,
						0,
						m_iIconPos,
						(LPARAM) pStrVarCur);		
				strVarBodyToSetInLV = pStrVarCur->Get_strStrVarBody();
				strCR.LoadString(IDS_CR);
				strCRSymbolic.LoadString(IDS_CR_SYMBOLIC);
				strVarBodyToSetInLV.Replace(strCR, strCRSymbolic);
				m_lstStrVars.SetItemText(i, 1, strVarBodyToSetInLV);
				pDoc->m_lstStrVars.GetNext(pos);
			}

			m_btnEditStrVar.EnableWindow(FALSE);
			m_btnDeleteStrVar.EnableWindow(FALSE);
		}
	}
	
	EndWaitCursor();
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 14
0
extern "C" BOOL EditPrint(HWND hwnd,LPCWSTR pszDocTitle,LPCWSTR pszPageFormat)
{

  // Don't print empty documents
  if (SendMessage(hwnd,SCI_GETLENGTH,0,0) == 0) {
    MsgBox(MBWARN,IDS_PRINT_EMPTY);
    return TRUE;
  }

  int startPos;
  int endPos;

  HDC hdc;

  RECT rectMargins;
  RECT rectPhysMargins;
  RECT rectSetup;
  POINT ptPage;
  POINT ptDpi;

  //RECT rectSetup;

  TEXTMETRIC tm;

  int headerLineHeight;
  HFONT fontHeader;

  int footerLineHeight;
  HFONT fontFooter;

  WCHAR dateString[256];

  DOCINFO di = {sizeof(DOCINFO), 0, 0, 0, 0};

  LONG lengthDoc;
  LONG lengthDocMax;
  LONG lengthPrinted;

  struct RangeToFormat frPrint;

  int pageNum;
  BOOL printPage;

  WCHAR pageString[32];

  HPEN pen;
  HPEN penOld;

  PRINTDLG pdlg = { sizeof(PRINTDLG), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  pdlg.hwndOwner = GetParent(hwnd);
  pdlg.hInstance = g_hInstance;
  pdlg.Flags = PD_USEDEVMODECOPIES | PD_ALLPAGES | PD_RETURNDC;
  pdlg.nFromPage = 1;
  pdlg.nToPage = 1;
  pdlg.nMinPage = 1;
  pdlg.nMaxPage = 0xffffU;
  pdlg.nCopies = 1;
  pdlg.hDC = 0;
  pdlg.hDevMode = hDevMode;
  pdlg.hDevNames = hDevNames;

  startPos = SendMessage(hwnd,SCI_GETSELECTIONSTART,0,0);;
  endPos = SendMessage(hwnd,SCI_GETSELECTIONEND,0,0);

  if (startPos == endPos) {
    pdlg.Flags |= PD_NOSELECTION;
  } else {
    pdlg.Flags |= PD_SELECTION;
  }
  if (0) {
    // Don't display dialog box, just use the default printer and options
    pdlg.Flags |= PD_RETURNDEFAULT;
  }
  if (!PrintDlg(&pdlg)) {
    return TRUE; // False means error...
  }

  hDevMode = pdlg.hDevMode;
  hDevNames = pdlg.hDevNames;

  hdc = pdlg.hDC;

  // Get printer resolution
  ptDpi.x = GetDeviceCaps(hdc, LOGPIXELSX);    // dpi in X direction
  ptDpi.y = GetDeviceCaps(hdc, LOGPIXELSY);    // dpi in Y direction

  // Start by getting the physical page size (in device units).
  ptPage.x = GetDeviceCaps(hdc, PHYSICALWIDTH);   // device units
  ptPage.y = GetDeviceCaps(hdc, PHYSICALHEIGHT);  // device units

  // Get the dimensions of the unprintable
  // part of the page (in device units).
  rectPhysMargins.left = GetDeviceCaps(hdc, PHYSICALOFFSETX);
  rectPhysMargins.top = GetDeviceCaps(hdc, PHYSICALOFFSETY);

  // To get the right and lower unprintable area,
  // we take the entire width and height of the paper and
  // subtract everything else.
  rectPhysMargins.right = ptPage.x            // total paper width
                          - GetDeviceCaps(hdc, HORZRES) // printable width
                          - rectPhysMargins.left;        // left unprintable margin

  rectPhysMargins.bottom = ptPage.y            // total paper height
                           - GetDeviceCaps(hdc, VERTRES)  // printable height
                           - rectPhysMargins.top;        // right unprintable margin

  // At this point, rectPhysMargins contains the widths of the
  // unprintable regions on all four sides of the page in device units.

  // Take in account the page setup given by the user (if one value is not null)
  if (pagesetupMargin.left != 0 || pagesetupMargin.right != 0 ||
          pagesetupMargin.top != 0 || pagesetupMargin.bottom != 0) {

    // Convert the hundredths of millimeters (HiMetric) or
    // thousandths of inches (HiEnglish) margin values
    // from the Page Setup dialog to device units.
    // (There are 2540 hundredths of a mm in an inch.)

    WCHAR localeInfo[3];
    GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_IMEASURE, localeInfo, 3);

    if (localeInfo[0] == L'0') {  // Metric system. L'1' is US System
      rectSetup.left = MulDiv (pagesetupMargin.left, ptDpi.x, 2540);
      rectSetup.top = MulDiv (pagesetupMargin.top, ptDpi.y, 2540);
      rectSetup.right  = MulDiv(pagesetupMargin.right, ptDpi.x, 2540);
      rectSetup.bottom  = MulDiv(pagesetupMargin.bottom, ptDpi.y, 2540);
    } else {
      rectSetup.left  = MulDiv(pagesetupMargin.left, ptDpi.x, 1000);
      rectSetup.top  = MulDiv(pagesetupMargin.top, ptDpi.y, 1000);
      rectSetup.right  = MulDiv(pagesetupMargin.right, ptDpi.x, 1000);
      rectSetup.bottom  = MulDiv(pagesetupMargin.bottom, ptDpi.y, 1000);
    }

    // Dont reduce margins below the minimum printable area
    rectMargins.left  = max(rectPhysMargins.left, rectSetup.left);
    rectMargins.top  = max(rectPhysMargins.top, rectSetup.top);
    rectMargins.right  = max(rectPhysMargins.right, rectSetup.right);
    rectMargins.bottom  = max(rectPhysMargins.bottom, rectSetup.bottom);
  } else {
    rectMargins.left  = rectPhysMargins.left;
    rectMargins.top  = rectPhysMargins.top;
    rectMargins.right  = rectPhysMargins.right;
    rectMargins.bottom  = rectPhysMargins.bottom;
  }

  // rectMargins now contains the values used to shrink the printable
  // area of the page.

  // Convert device coordinates into logical coordinates
  DPtoLP(hdc, (LPPOINT)&rectMargins, 2);
  DPtoLP(hdc, (LPPOINT)&rectPhysMargins, 2);

  // Convert page size to logical units and we're done!
  DPtoLP(hdc, (LPPOINT) &ptPage, 1);

  headerLineHeight = MulDiv(8,ptDpi.y, 72);
  fontHeader = CreateFont(headerLineHeight,
                          0, 0, 0,
                          FW_BOLD,
                          0,
                          0,
                          0, 0, 0,
                          0, 0, 0,
                          L"Arial");
  SelectObject(hdc, fontHeader);
  GetTextMetrics(hdc, &tm);
  headerLineHeight = tm.tmHeight + tm.tmExternalLeading;

  if (iPrintHeader == 3)
    headerLineHeight = 0;

  footerLineHeight = MulDiv(7,ptDpi.y, 72);
  fontFooter = CreateFont(footerLineHeight,
                          0, 0, 0,
                          FW_NORMAL,
                          0,
                          0,
                          0, 0, 0,
                          0, 0, 0,
                          L"Arial");
  SelectObject(hdc, fontFooter);
  GetTextMetrics(hdc, &tm);
  footerLineHeight = tm.tmHeight + tm.tmExternalLeading;

  if (iPrintFooter == 1)
    footerLineHeight = 0;

  di.lpszDocName = pszDocTitle;
  di.lpszOutput = 0;
  di.lpszDatatype = 0;
  di.fwType = 0;
  if (StartDoc(hdc, &di) < 0) {
    DeleteDC(hdc);
    if (fontHeader)
      DeleteObject(fontHeader);
    if (fontFooter)
      DeleteObject(fontFooter);
    return FALSE;
  }

  // Get current date...
  SYSTEMTIME st;
  GetLocalTime(&st);
  GetDateFormat(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&st,NULL,dateString,256);

  // Get current time...
  if (iPrintHeader == 0)
  {
    WCHAR timeString[128];
    GetTimeFormat(LOCALE_USER_DEFAULT,TIME_NOSECONDS,&st,NULL,timeString,128);
    lstrcat(dateString,L" ");
    lstrcat(dateString,timeString);
  }

  // Set print color mode
  int printColorModes[5] = {
    SC_PRINT_NORMAL,
    SC_PRINT_INVERTLIGHT,
    SC_PRINT_BLACKONWHITE,
    SC_PRINT_COLOURONWHITE,
    SC_PRINT_COLOURONWHITEDEFAULTBG };
  SendMessage(hwnd,SCI_SETPRINTCOLOURMODE,printColorModes[iPrintColor],0);

  // Set print zoom...
  SendMessage(hwnd,SCI_SETPRINTMAGNIFICATION,(WPARAM)iPrintZoom,0);

  lengthDoc = SendMessage(hwnd,SCI_GETLENGTH,0,0);
  lengthDocMax = lengthDoc;
  lengthPrinted = 0;

  // Requested to print selection
  if (pdlg.Flags & PD_SELECTION) {
    if (startPos > endPos) {
      lengthPrinted = endPos;
      lengthDoc = startPos;
    } else {
      lengthPrinted = startPos;
      lengthDoc = endPos;
    }

    if (lengthPrinted < 0)
      lengthPrinted = 0;
    if (lengthDoc > lengthDocMax)
      lengthDoc = lengthDocMax;
  }

  // We must substract the physical margins from the printable area
  frPrint.hdc = hdc;
  frPrint.hdcTarget = hdc;
  frPrint.rc.left = rectMargins.left - rectPhysMargins.left;
  frPrint.rc.top = rectMargins.top - rectPhysMargins.top;
  frPrint.rc.right = ptPage.x - rectMargins.right - rectPhysMargins.left;
  frPrint.rc.bottom = ptPage.y - rectMargins.bottom - rectPhysMargins.top;
  frPrint.rcPage.left = 0;
  frPrint.rcPage.top = 0;
  frPrint.rcPage.right = ptPage.x - rectPhysMargins.left - rectPhysMargins.right - 1;
  frPrint.rcPage.bottom = ptPage.y - rectPhysMargins.top - rectPhysMargins.bottom - 1;
  frPrint.rc.top += headerLineHeight + headerLineHeight / 2;
  frPrint.rc.bottom -= footerLineHeight + footerLineHeight / 2;
  // Print each page
  pageNum = 1;

  while (lengthPrinted < lengthDoc) {
    printPage = (!(pdlg.Flags & PD_PAGENUMS) ||
                 (pageNum >= pdlg.nFromPage) && (pageNum <= pdlg.nToPage));

    wsprintf(pageString, pszPageFormat, pageNum);

    if (printPage) {

      // Show wait cursor...
      BeginWaitCursor();

      // Display current page number in Statusbar
      StatusUpdatePrintPage(pageNum);

      StartPage(hdc);

      SetTextColor(hdc, RGB(0,0,0));
      SetBkColor(hdc, RGB(255,255,255));
      SelectObject(hdc, fontHeader);
      UINT ta = SetTextAlign(hdc, TA_BOTTOM);
      RECT rcw = {frPrint.rc.left, frPrint.rc.top - headerLineHeight - headerLineHeight / 2,
                  frPrint.rc.right, frPrint.rc.top - headerLineHeight / 2};
      rcw.bottom = rcw.top + headerLineHeight;

      if (iPrintHeader < 3)
      {
        ExtTextOut(hdc, frPrint.rc.left + 5, frPrint.rc.top - headerLineHeight / 2,
                      /*ETO_OPAQUE*/0, &rcw, pszDocTitle,
                      lstrlen(pszDocTitle), NULL);
      }

      // Print date in header
      if (iPrintHeader == 0 || iPrintHeader == 1)
      {
        SIZE sizeInfo;
        SelectObject(hdc,fontFooter);
        GetTextExtentPoint32(hdc,dateString,lstrlen(dateString),&sizeInfo);
        ExtTextOut(hdc, frPrint.rc.right - 5 - sizeInfo.cx, frPrint.rc.top - headerLineHeight / 2,
                      /*ETO_OPAQUE*/0, &rcw, dateString,
                      lstrlen(dateString), NULL);
      }

      if (iPrintHeader < 3)
      {
        SetTextAlign(hdc, ta);
        pen = CreatePen(0, 1, RGB(0,0,0));
        penOld = (HPEN)SelectObject(hdc, pen);
        MoveToEx(hdc, frPrint.rc.left, frPrint.rc.top - headerLineHeight / 4, NULL);
        LineTo(hdc, frPrint.rc.right, frPrint.rc.top - headerLineHeight / 4);
        SelectObject(hdc, penOld);
        DeleteObject(pen);
      }
    }

    frPrint.chrg.cpMin = lengthPrinted;
    frPrint.chrg.cpMax = lengthDoc;

    lengthPrinted = SendMessage(hwnd,SCI_FORMATRANGE,printPage,(LPARAM)&frPrint);

    if (printPage) {
      SetTextColor(hdc, RGB(0,0,0));
      SetBkColor(hdc, RGB(255,255,255));
      SelectObject(hdc, fontFooter);
      UINT ta = SetTextAlign(hdc, TA_TOP);
      RECT rcw = {frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 2,
                  frPrint.rc.right, frPrint.rc.bottom + footerLineHeight + footerLineHeight / 2};

      if (iPrintFooter == 0)
      {
        SIZE sizeFooter;
        GetTextExtentPoint32(hdc,pageString,lstrlen(pageString),&sizeFooter);
        ExtTextOut(hdc, frPrint.rc.right - 5 - sizeFooter.cx, frPrint.rc.bottom + footerLineHeight / 2,
                      /*ETO_OPAQUE*/0, &rcw, pageString,
                      lstrlen(pageString), NULL);

        SetTextAlign(hdc, ta);
        pen = ::CreatePen(0, 1, RGB(0,0,0));
        penOld = (HPEN)SelectObject(hdc, pen);
        SetBkColor(hdc, RGB(0,0,0));
        MoveToEx(hdc, frPrint.rc.left, frPrint.rc.bottom + footerLineHeight / 4, NULL);
        LineTo(hdc, frPrint.rc.right, frPrint.rc.bottom + footerLineHeight / 4);
        SelectObject(hdc, penOld);
        DeleteObject(pen);
      }

      EndPage(hdc);
    }
    pageNum++;

    if ((pdlg.Flags & PD_PAGENUMS) && (pageNum > pdlg.nToPage))
      break;
  }

  SendMessage(hwnd,SCI_FORMATRANGE, FALSE, 0);

  EndDoc(hdc);
  DeleteDC(hdc);
  if (fontHeader)
    DeleteObject(fontHeader);
  if (fontFooter)
    DeleteObject(fontFooter);

  // Reset Statusbar to default mode
  StatusSetSimple(hwndStatus,FALSE);

  // Remove wait cursor...
  EndWaitCursor();

  return TRUE;
}
Exemplo n.º 15
0
void CAcctHierDlg::BuildEquip()  
{
	GAL_ERROR							hError;
	GAL_SISELECTION				lpSelectedObjects=NULL;
	GAL_SISELECTION				lpCurrentObject=NULL;

	BeginWaitCursor();
	for ( int index = 0 ; m_iParentLoc[ index ] != 0; index++ ) 
	{
		m_lpFSC = galNewFilterSortCriteria(GAL_SISELECTION_TYPE);
		if (galFilterSISelection_account_no( m_lpFSC, m_iParentLoc[ index ], GAL_FILTER_EQUAL, &hError) == GAL_FAILURE )
		{
		  GuiError(__FILE__, __LINE__, 
			   "Error in galFilterSISelection.");
		}
		if (galListSISelection(m_hAPI, 
							   m_lpFSC, "", m_iParentLoc[ index ], //DENqa09491
							   &m_nSelectedObjects, 
							   &lpSelectedObjects, 
							   &hError) != GAL_FAILURE)
		{
			// bail gracefully if there's more than FIND_ROW_COUNT service instances
			if (m_nSelectedObjects > m_iMaxAlaProducts)
			{
				CGuiMsg::GuiMessage( GUIMSG_HIERARCHY_SERVICE_INSTANCES_UNDISPLAYABLE);
				galDeleteObjects(lpSelectedObjects);
				return;
			}

			for ( lpCurrentObject = lpSelectedObjects;  
				  lpCurrentObject;
				  lpCurrentObject = ( GAL_SISELECTION ) galNextObject( lpCurrentObject ))
			{
				galGetSISelection_external_id(lpCurrentObject, m_textExtId, &hError );
				galGetSISelection_account_no( lpSelectedObjects, &m_iAccountNo, &hError);
				 //CAMqa58078
                                galGetSISelection_equip_status(lpCurrentObject, &m_iEquipStatus, &hError);
                                //CAMqa58078
				m_tvstruct.hParent = m_rghItem[ index ];
				m_tvstruct.hInsertAfter = TVI_LAST;
				char tempExtId[GAL_SISELECTION_EXTERNAL_ID_LEN*2];
				strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));
				 //CAMqa58078
                                if (m_iEquipStatus == 2 )
								{
									strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));//CAMqa72212
									m_tvstruct.item.pszText = strcat(tempExtId, GetIntlString(IDS_DISCONNECTED)); //CAMqa84527
									
								}
                                /*else if(m_iEquipStatus > 0 )
								{
									strcpy(tempExtId, ArbI18N::translateFromUTF8(m_textExtId));//CAMqa72212
									m_tvstruct.item.pszText = strcat(tempExtId, GetIntlString(IDS_DISCONNECTION_REQ)); //CAMqa84527
									
								}*/
                                else
                                //CAMqa58078 
				m_tvstruct.item.pszText = tempExtId;					  
				m_tvstruct.item.mask = TVIF_TEXT | TVIF_IMAGE |TVIF_SELECTEDIMAGE;
				m_tvstruct.item.iImage = 3; //Bitmap index returned from Add function in oninitdialog
				m_tvstruct.item.iSelectedImage = 3;
				m_rghItem[m_iParsedItem]= m_TreeHier.InsertItem( &m_tvstruct );
				m_TreeHier.EnsureVisible( m_rghItem[m_iParsedItem] );
				m_iParsedItem++;
			}
		  if( lpSelectedObjects )
			  galDeleteObjects(lpSelectedObjects);   
		  lpSelectedObjects = NULL;
		}
		else
		  GuiError(__FILE__, __LINE__,
			   "Could not set Account List.");
		galDeleteFilterSortCriteria(m_lpFSC);
	}

	UpdateData( FALSE ); 
	EndWaitCursor();

}
/////////////////////////////////////////////////////////////////////////////
// CLryEDBQryView message handlers
void CLryEDBQryView::FillList()
{
	int iStrLen = 0;
	int i		= 0;
	_variant_t  str;
	CStringArray ColNameArray;
	BeginWaitCursor() ;
	try
	{
		CLryEDBQryDoc* pDoc  = (CLryEDBQryDoc*)GetDocument();
		_RecordsetPtr pRs = pDoc->Rs;
			//得到所有字段名称
		GetAllFieldName(pRs,&ColNameArray);
		
		CListCtrl * ListCtrl = (CListCtrl  *)&GetListCtrl(); 
		ListCtrl->SetRedraw(FALSE);
		//清除所有数据
		
		ListCtrl->DeleteAllItems();
		//清除所有标题
		do
		{
			ListCtrl->DeleteColumn(0);
		}
		while(ListCtrl->GetHeaderCtrl()->GetItemCount()>0); 
		//写字段标题
		for(i=ColNameArray.GetSize()-1;i>=0;i--)
		{
			CDC *pDC = GetDC();
			iStrLen	= pDC->GetTextExtent(ColNameArray.GetAt(i)).cx*2;				
			ListCtrl->InsertColumn(0,ColNameArray.GetAt(i),LVCFMT_CENTER,iStrLen ,-1);
			ReleaseDC(pDC);	
		}
		//
		LONG RecordCount = 0;
		RecordCount = pRs->GetRecordCount();
		ListCtrl->SetItemCount(RecordCount);

		if(RecordCount>0)
		{
			if(!pRs->adoEOF)
				pRs->MoveLast();
				
			while(!pRs->BOF)
			{		
				for(i=0;i<pRs->Fields->Count;i++)
				{
					str = pRs->GetCollect((_bstr_t)ColNameArray.GetAt(i));
					if(i==0)
						ListCtrl->InsertItem(0,VariantToStr(str));
					else
						ListCtrl->SetItemText(0,i,VariantToStr(str));
				}
				pRs->MovePrevious();
			}  
			pDoc->MoveFirst();
		}
		ListCtrl->SetRedraw(TRUE); 
		pDoc->UpdateAllViews(this);
	}
	catch(_com_error &e)
	{
		dump_com_error(e);
	}
	EndWaitCursor();
}
void CNetworkControllView::OnBnClickedApplybutton()
{
	if(!CheckSettingChanged()) // if setting changed,return TRUE
	{
		return; // unchanged, don't write register
	}

	if(g_NetWorkLevel==1)
		return;
	BeginWaitCursor();
	//m_nListenPort	
	CString strText;
	m_listenPortEdit.GetWindowText(strText);
	if(!strText.IsEmpty())
		m_nListenPort=_wtoi(strText);
	if(m_nListenPort>=12767)
	{
		AfxMessageBox(_T("The listen port number is too big, please change it."));
		return;
	}
	if(m_nListenPort<=0)
	{
		AfxMessageBox(_T("The listen port number must be greater than 0!"));
		return;
	}
	write_one(g_tstat_id,120,m_nListenPort);
	BYTE address1,address2,address3,address4;
	m_ip_addressCtrl.	GetAddress(address1,address2,address3,address4);
	int n=write_one(g_tstat_id,107,address1);
	n=write_one(g_tstat_id,108,address2);
	n=write_one(g_tstat_id,109,address3);
	n=write_one(g_tstat_id,110,address4);
	m_subnet_addressCtrl.GetAddress(address1,address2,address3,address4);
	write_one(g_tstat_id,111,address1);
	write_one(g_tstat_id,112,address2);
	write_one(g_tstat_id,113,address3);
	write_one(g_tstat_id,114,address4);
	m_gateway_addressCtrl.GetAddress(address1,address2,address3,address4);
	write_one(g_tstat_id,115,address1);
	write_one(g_tstat_id,116,address2);
	write_one(g_tstat_id,117,address3);
	write_one(g_tstat_id,118,address4);
	write_one(g_tstat_id,131,1);
	Sleep(1000);//Sleep(10000); // ???
	write_one(g_tstat_id,133,1);
	Sleep(5000);	//Sleep(5000); // wait for nc restart

	CMainFrame* pPraent=(CMainFrame*)GetParent();
	//pPraent->ReFresh();

	/*
	unsigned short variable[13]={0};
	int nRet=Read_Multi(g_tstat_id,variable,106,13,3);/////////////////////////read
	m_ipModelComBox.SetCurSel(variable[0]);
	m_ip_addressCtrl.SetAddress(variable[1],variable[2],variable[3],variable[4]);
	m_subnet_addressCtrl.SetAddress(variable[5],variable[6],variable[7],variable[8]);
	m_gateway_addressCtrl.SetAddress(variable[9],variable[10],variable[11],variable[12]);

*/
	
	CString strBuilding,strSubBuilding;
	strBuilding=pPraent->m_strCurMainBuildingName;
	strSubBuilding=pPraent->m_strCurSubBuldingName;
	CString strIP,strPort;
	strPort.Format(_T("%d"),multi_register_value[120]);
	m_ip_addressCtrl.GetAddress(address1,address2,address3,address4);
	strIP.Format(_T("%d.%d.%d.%d"),address1,address2,address3,address4);
	if(g_CommunicationType==1)//TCP
	{
		int nPort;
		nPort=_wtoi(strPort);
		//m_strIP=build_info.strIp; 
		g_CommunicationType=1;
		SetCommunicationType(g_CommunicationType);
		BOOL bOk=FALSE;
		bOk=Open_Socket2(strIP,nPort);
		CString strInfo;

		strInfo.Format((_T("Open IP:%s successful")),strIP);//prompt info;
		SetPaneString(1,strInfo);
		if(bOk)
		{
			_ConnectionPtr t_pCon;//for ado connection
			t_pCon.CreateInstance(_T("ADODB.Connection"));
			t_pCon->Open(g_strDatabasefilepath.GetString(),_T(""),_T(""),adModeUnknown);
			CString strSql;
			strSql.Format(_T("update Building set Ip_Address='%s' where Ip_Address='%s'"),strIP,pPraent->m_strIP);
			t_pCon->Execute(strSql.GetString(),NULL,adCmdText);

			// 改node
			CString strSID;
			strSID.Format(_T("%d"), m_nSerialNum);
			strSql.Format(_T("update ALL_NODE set Bautrate='%s' where Serial_ID='%s'"),strIP, strSID); //bautrate 放IP
			t_pCon->Execute(strSql.GetString(),NULL,adCmdText);




			if(t_pCon->State)
				t_pCon->Close();
			pPraent->m_strIP=strIP;
			pPraent->ScanTstatInDB();

		}
		else
		{

		}



/*
		_ConnectionPtr t_pCon;//for ado connection
		t_pCon.CreateInstance(_T("ADODB.Connection"));
		t_pCon->Open(g_strDatabasefilepath.GetString(),_T(""),_T(""),adModeUnknown);
		CString strSql;
		strSql.Format(_T("update Building set Ip_Address='%s',Ip_Port='%s' where Main_BuildingName='%s' and Building_Name='%s'"),strIP,strPort,strBuilding,strSubBuilding);
		t_pCon->Execute(strSql.GetString(),NULL,adCmdText);
		if(t_pCon->State)
			t_pCon->Close();
		pPraent->OnConnect();
		*/
	}
	//write_one(g_tstat_id,131,1);
	Fresh();
	EndWaitCursor();

}