// 停止 void CTabSample::OnStop(void) { CButton* iconbutton = NULL; CStatic* iconstatic = NULL; CButton* pButton = NULL; iconstatic =(CStatic*)this->GetDlgItem(IDC_STATIC_LAUX); iconstatic->SetIcon(m_iconLAUXDisconnected); iconstatic = NULL; for (int i=0; i<GraphViewNum; i++) { ProcessMessages(); iconbutton = (CButton*)this->GetDlgItem(m_iButtonIDFDU[i]); iconbutton->SetIcon(m_iconFDUDisconnected); iconbutton = NULL; pButton = (CButton*)GetDlgItem(m_iCheckIDInstrumentFDU[i]); pButton->SetCheck(0); pButton = NULL; pButton = (CButton*)GetDlgItem(m_iCheckIDNoiseFDU[i]); pButton->SetCheck(0); pButton = NULL; } delete iconstatic; delete iconbutton; delete pButton; GetDlgItem(IDC_EDIT_SENDPORT)->EnableWindow(TRUE); GetDlgItem(IDC_CHECK_HEARTBEAT)->EnableWindow(FALSE); }
/** * @brief Handler for WM_INITDIALOG; conventional location to initialize * controls. At this point dialog and control windows exist. */ BOOL ConfirmFolderCopyDlg::OnInitDialog() { theApp.TranslateDialog(m_hWnd); CDialog::OnInitDialog(); // Load warning icon // TODO: we can have per-action icons? HICON icon = AfxGetApp()->LoadStandardIcon(IDI_EXCLAMATION); CStatic * pIcon = (CStatic *) GetDlgItem(IDC_FLDCONFIRM_ICON); pIcon->SetIcon(icon); if (!m_caption.IsEmpty()) SetWindowText(m_caption); // setup handler for resizing this dialog m_constraint.InitializeCurrentSize(this); // configure how individual controls adjust when dialog resizes m_constraint.ConstrainItem(IDC_FLDCONFIRM_FROM_PATH, 0, 1, 0, 0); // grows right m_constraint.ConstrainItem(IDC_FLDCONFIRM_TO_PATH, 0, 1, 0, 0); // grows right // IDC_SAVECLOSING_DISCARDALL doesn't move m_constraint.ConstrainItem(IDYES, 1, 0, 0, 0); // slides right m_constraint.ConstrainItem(IDNO, 1, 0, 0, 0); // slides right m_constraint.DisallowHeightGrowth(); m_constraint.SubclassWnd(); // install subclassing // persist size via registry m_constraint.LoadPosition(_T("ResizeableDialogs"), _T("FolderCopyConfirmDlg"), false); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
// 根据IP地址显示设备断开连接的图标 //************************************ // Method: OnShowDisconnectedIcon // FullName: CInstrumentList::OnShowDisconnectedIcon // Access: protected // Returns: void // Qualifier: // Parameter: unsigned int uiIPAddress //************************************ void CInstrumentList::OnShowDisconnectedIcon(unsigned int uiIPAddress) { CButton* iconbutton = NULL; CStatic* iconstatic = NULL; CButton* pButton = NULL; for (int i=0 ;i<= InstrumentNum; i++) { ProcessMessages(); if (uiIPAddress == (IPSetAddrStart + i * IPSetAddrInterval)) { if (i == 0) { iconstatic =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_LAUX); iconstatic->SetIcon(m_iconLAUXDisconnected); } else { iconbutton = (CButton*)m_pwnd->GetDlgItem(m_iButtonIDFDU[i-1]); iconbutton->SetIcon(m_iconFDUDisconnected); pButton = (CButton*)m_pwnd->GetDlgItem(m_iCheckIDInstrumentFDU[i-1]); pButton->SetCheck(0); } break; } } }
// 删除所有仪器 void CInstrumentList::DeleteAllInstrument(void) { CInstrument* pInstrument = NULL; // 仪器对象指针 POSITION pos = NULL; // 位置 unsigned int uiKey; // 索引键 unsigned int icount = m_oInstrumentMap.GetCount(); if (icount == 0) { return; } pos = m_oInstrumentMap.GetStartPosition(); // 得到索引表起始位置 while(NULL != pos) { pInstrument = NULL; m_oInstrumentMap.GetNextAssoc(pos, uiKey, pInstrument); // 得到仪器对象 if(NULL != pInstrument) { CStatic* icon; if(pInstrument->m_uiIPAddress == 81) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT1); icon->SetIcon(m_iconDisconnected); } else if(pInstrument->m_uiIPAddress == 91) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT2); icon->SetIcon(m_iconDisconnected); } else if(pInstrument->m_uiIPAddress == 101) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT3); icon->SetIcon(m_iconDisconnected); } else if(pInstrument->m_uiIPAddress == 111) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT4); icon->SetIcon(m_iconDisconnected); } DeleteInstrumentFromMap(uiKey); // 重置仪器 pInstrument->OnReset(); // 仪器加在空闲仪器队列尾部 m_olsInstrumentFree.AddTail(pInstrument); m_uiCountFree++; } } }
////////////////// // Initialize dialog: if I loaded a system icon, set it in static control. // BOOL CInputDialog::OnInitDialog() { if (m_hIcon) { CStatic* pStatic = (CStatic*)GetDlgItem(IDICON); ASSERT(pStatic); pStatic->SetIcon(m_hIcon); } return CDialog::OnInitDialog(); }
// 停止 void CTabSample::OnStop(void) { CStatic* icon; icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT1); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT2); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT3); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT4); icon->SetIcon(m_iconDisconnected); GetDlgItem(IDC_EDIT_SENDPORT)->EnableWindow(TRUE); GetDlgItem(IDC_CHECK_HEARTBEAT)->EnableWindow(FALSE); m_oThreadManage.OnStop(); }
// 重置设备按键的图标 void CTabSample::OnResetButtonIcon(void) { CButton* iconbutton = NULL; CStatic* iconstatic = NULL; iconstatic =(CStatic*)this->GetDlgItem(IDC_STATIC_LAUX); iconstatic->SetIcon(m_iconLAUXDisconnected); iconstatic = NULL; for (int i=0; i<InstrumentNum; i++) { ProcessMessages(); iconbutton = (CButton*)this->GetDlgItem(m_iButtonIDFDU[i]); iconbutton->SetIcon(m_iconFDUDisconnected); iconbutton = NULL; } }
/** * @brief Read version info from resource to dialog. */ BOOL CAboutDlg::OnInitDialog() { theApp.TranslateDialog(m_hWnd); CDialog::OnInitDialog(); // Load application icon HICON icon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); if (icon != NULL) { CStatic * pIcon = (CStatic *) GetDlgItem(IDC_ABOUTBOX_ICON); pIcon->SetIcon(icon); } CVersionInfo version(AfxGetResourceHandle()); CString sVersion = version.GetFixedProductVersion(); LangFormatString1(m_strVersion, IDS_VERSION_FMT, sVersion); m_strVersion += _T(" "); m_strVersion += theApp.LoadString(IDS_UNICODE).c_str(); #ifdef WIN64 m_strVersion += _T(" "); m_strVersion += theApp.LoadString(IDS_WINX64).c_str(); #endif CString sPrivateBuild = version.GetPrivateBuild(); if (!sPrivateBuild.IsEmpty()) { LangFormatString1(m_strPrivateBuild, IDS_PRIVATEBUILD_FMT, sPrivateBuild); } CString copyright = version.GetLegalCopyright(); m_ctlCompany.SetWindowText(copyright); m_ctlWWW.m_link = WinMergeURL; UpdateData(FALSE); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
BOOL COpenDlg::OnInitDialog() { __super::OnInitDialog(); AppSettings& s = AfxGetAppSettings(); CRecentFileList& MRU = s.MRU; MRU.ReadList(); m_mrucombo.ResetContent(); for (int i = 0; i < MRU.GetSize(); i++) if (!MRU[i].IsEmpty()) { m_mrucombo.AddString(MRU[i]); } CorrectComboListWidth(m_mrucombo); CRecentFileList& MRUDub = s.MRUDub; MRUDub.ReadList(); m_mrucombo2.ResetContent(); for (int i = 0; i < MRUDub.GetSize(); i++) if (!MRUDub[i].IsEmpty()) { m_mrucombo2.AddString(MRUDub[i]); } CorrectComboListWidth(m_mrucombo2); if (m_mrucombo.GetCount() > 0) { m_mrucombo.SetCurSel(0); } if (::IsClipboardFormatAvailable(CF_UNICODETEXT) && ::OpenClipboard(m_hWnd)) { HGLOBAL hglb = ::GetClipboardData(CF_UNICODETEXT); if (hglb) { LPCTSTR pText = (LPCTSTR)::GlobalLock(hglb); if (pText) { if (AfxIsValidString(pText)) { CString tmpData(CString(pText).MakeLower()); if (PlayerYouTubeCheck(tmpData) || PlayerYouTubePlaylistCheck(tmpData)) { m_mrucombo.SetWindowTextW(pText); } } GlobalUnlock(hglb); } } CloseClipboard(); } m_fns.RemoveAll(); m_path.Empty(); m_path2.Empty(); m_fMultipleFiles = false; m_fAppendPlaylist = FALSE; AddAnchor(m_mrucombo, TOP_LEFT, TOP_RIGHT); AddAnchor(m_mrucombo2, TOP_LEFT, TOP_RIGHT); AddAnchor(IDC_BUTTON1, TOP_RIGHT); AddAnchor(IDC_BUTTON2, TOP_RIGHT); AddAnchor(IDOK, TOP_RIGHT); AddAnchor(IDCANCEL, TOP_RIGHT); AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT); CRect r; GetWindowRect(r); CSize sr = r.Size(); SetMinTrackSize(sr); sr.cx = 1000; SetMaxTrackSize(sr); if (m_hIcon != NULL) { CStatic *pStat = (CStatic*)GetDlgItem(IDC_MAINFRAME_ICON); pStat->SetIcon(m_hIcon); } return TRUE; }
BOOL CLoginDlg::OnInitDialog() { CDialog::OnInitDialog(); // TODO: Add extra initialization here //CString server="192.168.1.200"; //CString server="hzluming.3322.org"; //this->SetDlgItemText(IDC_EDIT_SERVER, server); CFileException error; if ( ! m_fSaveInfo.Open("LogOnInfo.txt", CFile::modeNoTruncate | CFile::modeCreate | CFile::modeReadWrite, &error) ) { CString strError; strError.Format( "Can't open file %s, error = %u\n", "LogOnInfo.txt", error.m_cause ); AfxMessageBox(strError); } else { ULONGLONG nSize = m_fSaveInfo.GetLength(); if (m_fSaveInfo.GetLength() == 0) { CString strLogOnInfo = "default admin 0.0.0.0 8000"; strLogOnInfo.Append("\r\n"); m_fSaveInfo.WriteString(strLogOnInfo); //user strLogOnInfo = "user admin"; strLogOnInfo.Append("\r\n"); m_fSaveInfo.WriteString(strLogOnInfo); //server port strLogOnInfo = "server 0.0.0.0"; strLogOnInfo.Append("\r\n"); m_fSaveInfo.WriteString(strLogOnInfo); //server strLogOnInfo = "port 8000"; strLogOnInfo.Append("\r\n"); m_fSaveInfo.WriteString(strLogOnInfo); m_fSaveInfo.SeekToBegin(); } //Init combox CString strUserDefault, strServerDefault,strPortDefault; CString temp; int pos = 0; m_cboUser.ResetContent(); CString rOneLine; while (m_fSaveInfo.ReadString(rOneLine)) { pos=util::split_next(rOneLine, temp, '\t', 0); if (temp == "default") { pos = util::split_next(rOneLine, strUserDefault, '\t', pos+1); util::TrimSpecialChar(strUserDefault,0xd); pos = util::split_next(rOneLine, strServerDefault, '\t', pos+1); util::TrimSpecialChar(strServerDefault,0xd); pos = util::split_next(rOneLine, strPortDefault, '\t', pos+1); util::TrimSpecialChar(strPortDefault,0xd); //Remove the continue; } if (temp == "user") { pos = util::split_next(rOneLine, temp, '\t', pos+1); while( !temp.IsEmpty() ) { util::TrimSpecialChar(temp,0xd); m_cboUser.AddString(temp); pos = util::split_next(rOneLine, temp, '\t', pos+1); } m_cboUser.SelectString(0,strUserDefault); continue; } if (temp == "server") { pos = util::split_next(rOneLine, temp, '\t', pos+1); while( !temp.IsEmpty() ) { util::TrimSpecialChar(temp,0xd); m_cboServer.AddString(temp); pos = util::split_next(rOneLine, temp, '\t', pos+1); } m_cboServer.SelectString(0,strServerDefault); continue; } if (temp == "port") { pos = util::split_next(rOneLine, temp, '\t', pos+1); while( !temp.IsEmpty() ) { util::TrimSpecialChar(temp,0xd); m_cboPort.AddString(temp); pos = util::split_next(rOneLine, temp, '\t', pos+1); } m_cboPort.SelectString(0,strPortDefault); continue; } } } m_fSaveInfo.Close(); //this->SetDlgItemText(IDC_EDT_PORT, "8000"); //LogOn ICON CStatic* pStatic = (CStatic*)GetDlgItem(IDC_OGON_PIC); //pStatic->ModifyStyle(0xF, SS_BITMAP|SS_CENTERIMAGE); HICON hIcon1 = AfxGetApp()->LoadIcon(IDI_LOGON); pStatic->SetIcon(hIcon1); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE }
void CTabSample::OnInit(void) { m_iGraphViewId[0] = IDC_GRAPHSHOW1; m_iGraphViewId[1] = IDC_GRAPHSHOW2; m_iGraphViewId[2] = IDC_GRAPHSHOW3; m_iGraphViewId[3] = IDC_GRAPHSHOW4; for (int i=0; i<GraphViewNum;i++) { m_dSampleData[i].reserve(10240); } // 输入控件ID m_iMathId[0][0] = IDC_STATIC_AVERAGE1; m_iMathId[0][1] = IDC_STATIC_RMS1; m_iMathId[0][2] = IDC_STATIC_MAX1; m_iMathId[0][3] = IDC_STATIC_MIN1; m_iMathId[1][0] = IDC_STATIC_AVERAGE2; m_iMathId[1][1] = IDC_STATIC_RMS2; m_iMathId[1][2] = IDC_STATIC_MAX2; m_iMathId[1][3] = IDC_STATIC_MIN2; m_iMathId[2][0] = IDC_STATIC_AVERAGE3; m_iMathId[2][1] = IDC_STATIC_RMS3; m_iMathId[2][2] = IDC_STATIC_MAX3; m_iMathId[2][3] = IDC_STATIC_MIN3; m_iMathId[3][0] = IDC_STATIC_AVERAGE4; m_iMathId[3][1] = IDC_STATIC_RMS4; m_iMathId[3][2] = IDC_STATIC_MAX4; m_iMathId[3][3] = IDC_STATIC_MIN4; // 控件选择 for (int k=0; k<GraphViewNum; k++) { m_iSelectObject[k] = 0; m_iSelectObjectNoise[k] = 0; } m_cSelectObjectName[0] = _T("仪器一"); m_cSelectObjectName[1] = _T("仪器二"); m_cSelectObjectName[2] = _T("仪器三"); m_cSelectObjectName[3] = _T("仪器四"); // 得到当前路径 char cSaveToFilePath[MAX_PATH]; GetCurrentDirectory(MAX_PATH, cSaveToFilePath); m_csSaveFilePath = cSaveToFilePath; CScrollBar*pSB =(CScrollBar*)GetDlgItem(IDC_SCROLLBAR_GRAPHVIEW); pSB->SetScrollRange(m_uiScrollBarMin,m_uiScrollBarMax); // 创建绘图控件并设置相关参数 CreateGraph(GraphViewNum, m_iGraphViewId, m_OScopeCtrl); // customize the control SetRange(-2.5, 2.5, 1, GraphViewNum, m_OScopeCtrl) ; SetYUnits("Y", GraphViewNum, m_OScopeCtrl) ; SetXUnits("X", GraphViewNum, m_OScopeCtrl) ; SetBackgroundColor(RGB(0, 0, 64), GraphViewNum, m_OScopeCtrl) ; SetGridColor(RGB(192, 192, 255), GraphViewNum, m_OScopeCtrl) ; SetPlotColor(RGB(255, 255, 255), GraphViewNum, m_OScopeCtrl) ; // 得到本机IP地址 char name[255]; CString ip; PHOSTENT hostinfo; if( gethostname (name, sizeof(name)) == 0) { if((hostinfo = gethostbyname(name)) != NULL) { ip = inet_ntoa(*(struct in_addr*)*hostinfo-> h_addr_list); } } m_oThreadManage.m_HeadFrameSocket.m_csIPSource = ip; m_oThreadManage.m_TailFrameSocket.m_csIPSource = ip; m_oThreadManage.m_TailTimeFrameSocket.m_csIPSource = ip; m_oThreadManage.m_oSysTimeSocket.m_csIPSource = ip; m_oThreadManage.m_ADCDataSocket.m_csIPSource = ip; m_oThreadManage.m_oSysTimeSocket.m_pADCSet = &m_oADCSet; CString str; str.Format("0x%04x", 0x8202); GetDlgItem(IDC_EDIT_SENDPORT)->SetWindowText(str); str.Format("%d", 406); GetDlgItem(IDC_EDIT_ADCSAVEFRAMENB)->SetWindowText(str); m_iconDisconnected = AfxGetApp()->LoadIcon(IDI_ICON1); m_iconConnected = AfxGetApp()->LoadIcon(IDI_ICON2); m_oThreadManage.m_oInstrumentList.m_iconDisconnected = m_iconDisconnected; m_oThreadManage.m_oInstrumentList.m_pwnd = this; m_oThreadManage.m_IPSetSocket.m_iconConnected = m_iconConnected; m_oThreadManage.m_IPSetSocket.m_pwnd = this; // m_oThreadManage.m_ADCDataSocket.m_pwnd = this; m_oThreadManage.m_ADCDataSocket.m_pSelectObject = m_iSelectObject; m_oThreadManage.m_ADCDataSocket.m_pSelectObjectNoise = m_iSelectObjectNoise; for(int i=0; i<GraphViewNum; i++) { m_oThreadManage.m_ADCDataSocket.m_pSampleData[i] = &m_dSampleData[i]; m_oThreadManage.m_ADCDataSocket.m_pOScopeCtrl[i] = &m_OScopeCtrl[i]; m_oThreadManage.m_ADCDataSocket.m_cSelectObjectName[i] = m_cSelectObjectName[i]; } CStatic* icon; icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT1); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT2); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT3); icon->SetIcon(m_iconDisconnected); icon =(CStatic*)this->GetDlgItem(IDC_STATIC_INSTRUMENT4); icon->SetIcon(m_iconDisconnected); m_oThreadManage.OnInit(); OnOpen(); // 监测尾包定时器 SetTimer(4, 1000, NULL); }
// 单个IP地址设置应答帧处理 void CIPSetSocket::ProcIPSetReturnFrameOne(void) { if (ParseIPSetReturnFrame() == FALSE) { return; } // 在索引表中找到该仪器 if (TRUE == m_oInstrumentList->IfIndexExistInMap(m_uiSN)) { // 在索引表中找到该仪器,得到该仪器指针 CInstrument* pInstrument = NULL; if (TRUE == m_oInstrumentList->GetInstrumentFromMap(m_uiSN, pInstrument)) { if (m_uiIPAddress == pInstrument->m_uiIPAddress) { pInstrument->m_bIPSetOK = true; CStatic* icon; if(m_uiIPAddress == 81) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT1); icon->SetIcon(m_iconConnected); } else if(m_uiIPAddress == 91) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT2); icon->SetIcon(m_iconConnected); } else if(m_uiIPAddress == 101) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT3); icon->SetIcon(m_iconConnected); } else if(m_uiIPAddress == 111) { icon =(CStatic*)m_pwnd->GetDlgItem(IDC_STATIC_INSTRUMENT4); icon->SetIcon(m_iconConnected); } // 如果为采集站则自动设置ADC参数 // if (pInstrument->m_uiInstrumentType == 3) // { // m_pADCSet->ADCSetFrameHead(m_uiIPAddress, false); // m_pADCSet->OnSetSine(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // m_pADCSet->OnStopSample(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // m_pADCSet->OnOpenPower(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // Sleep(100); // // m_pADCSet->OnOpenPowerTB(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // Sleep(100); // // m_pADCSet->OnOpenSwitch(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // Sleep(100); // // m_pADCSet->OnOpenSwitchTB(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // Sleep(100); // // m_pADCSet->OnStopSample(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // Sleep(100); // // m_pADCSet->OnADCRegisterWrite(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // Sleep(100); // // m_pADCSet->OnADCRegisterRead(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // // Sleep(100); // // m_pADCSet->OnADCSetReturn(); // SendTo(m_pADCSet->m_cFrameData, 128, m_uiSendPort, IPBroadcastAddr); // } } } } }
void CBidDialog::UpdateBidDisplay(int nPos, int nBid, BOOL bPrompt, BOOL bTentative) { int nTextID = IDC_BID_SOUTH + nPos; int nIconID = IDCI_BID_SOUTH + nPos; // see if we're using text for bids if (!UsingSuitSymbols() || !ISBID(nBid) || bTentative) { // show bid text GetDlgItem(nIconID)->ShowWindow(FALSE); GetDlgItem(nTextID)->ShowWindow(TRUE); CString strTemp; // show text if ((nPos == SOUTH) && (bPrompt)) { SetDlgItemText(nTextID, "??"); } else if (nBid == -2) { SetDlgItemText(nTextID, "?"); } else if (nBid == -1) { SetDlgItemText(nTextID, ""); } else if (bTentative) { strTemp = BidToShortString(nBid) + _T('?'); SetDlgItemText(nTextID, (LPCTSTR)strTemp); } else { // real bid strTemp = BidToShortString(nBid); SetDlgItemText(nTextID, (LPCTSTR)strTemp); } GetDlgItem(nTextID)->UpdateWindow(); } else { // show bid icon GetDlgItem(nTextID)->ShowWindow(FALSE); GetDlgItem(nIconID)->ShowWindow(TRUE); CStatic* pStatic = (CStatic*) GetDlgItem(nIconID); if (ISBID(nBid)) { int nSuit = (nBid-1) % 5; int nLevel = (nBid-1) / 5; pStatic->SetIcon(m_buttonIcons[nSuit][nLevel]); } else { pStatic->SetIcon(NULL); } // pStatic->UpdateWindow(); } /* CString strTemp; // show text if ((nPos == SOUTH) && (bPrompt)) { SetDlgItemText(IDC_BID_SOUTH, "??"); } else if (nBid == -2) { SetDlgItemText(IDC_BID_SOUTH+nPos, "?"); } else if (nBid == -1) { SetDlgItemText(IDC_BID_SOUTH+nPos, ""); } else if (bTentative) { strTemp = BidToShortString(nBid) + _T('?'); SetDlgItemText(IDC_BID_SOUTH+nPos, (LPCTSTR)strTemp); } else { // real bid strTemp = BidToShortString(nBid); // play sound if appropriate if (m_bSpeechEnabled) { CString strDir = theApp.GetValueString(tszProgramDirectory); // CString strPath = strDir + _T("\\Sounds\\") + PositionToString(nPos) + strTemp + _T(".wav"); CString strPath = strDir + _T("\\Sounds\\") + strTemp + _T(".wav"); CFile file; if (file.Open(strPath, CFile::modeRead)) { file.Close(); PlaySound(strPath, NULL, SND_SYNC | SND_NOSTOP | SND_NOWAIT); } } // show bid SetDlgItemText(IDC_BID_SOUTH+nPos, (LPCTSTR)strTemp); } */ }
BOOL CMsgBox::OnInitDialog() { CDialog::OnInitDialog(); GetWindowRect(&m_InitRect); m_LastRect = m_InitRect; if (m_ShowVscroll) { DWORD dwStyle = GetWindowLong(GetDlgItem(IDC_MESSAGE)->m_hWnd, GWL_STYLE); SetWindowLong(GetDlgItem(IDC_MESSAGE)->m_hWnd, GWL_STYLE, dwStyle | WS_VSCROLL); GetDlgItem(IDC_MESSAGE)->SetWindowPos(0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); dwStyle = GetWindowLong(m_hWnd, GWL_STYLE); SetWindowLong(m_hWnd, GWL_STYLE, dwStyle | WS_SYSMENU | WS_MAXIMIZEBOX | WS_THICKFRAME); SetWindowPos(0,0,0,0,0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); } m_Text.Replace(_T("\n"), _T("\r\n")); SetDlgItemText( IDC_MESSAGE, m_Text ); SetWindowText( m_Caption ); if (m_Icon) { HICON hIcon = AfxGetApp()->LoadStandardIcon(m_Icon); CStatic * pStatic = (CStatic *)GetDlgItem(IDC_MSGICON); pStatic->SetIcon( hIcon ); } switch (m_numButtons) { default: case 1: SetDlgItemText( IDC_BUTTON2, m_Button1 ); GetDlgItem(IDC_BUTTON1)->ShowWindow(SW_HIDE); GetDlgItem(IDC_BUTTON3)->ShowWindow(SW_HIDE); GotoDlgCtrl( GetDlgItem(IDC_BUTTON2) ); break; case 2: SetDlgItemText( IDC_BUTTON1, m_Button1 ); SetDlgItemText( IDC_BUTTON3, m_Button2 ); GetDlgItem(IDC_BUTTON2)->ShowWindow(SW_HIDE); GotoDlgCtrl( GetDlgItem(m_DefButton == IDC_BUTTON1 ? IDC_BUTTON1 : IDC_BUTTON3) ); break; case 3: SetDlgItemText( IDC_BUTTON1, m_Button1 ); SetDlgItemText( IDC_BUTTON2, m_Button2 ); SetDlgItemText( IDC_BUTTON3, m_Button3 ); GotoDlgCtrl( GetDlgItem(m_DefButton) ); break; } if (m_lpDontShowAgain) { GetDlgItem(IDC_CHECK_DONT_SHOW_AGAIN)->ShowWindow(SW_SHOWNORMAL); GetDlgItem(IDC_CHECK_DONT_SHOW_AGAIN)->EnableWindow(TRUE); } UpdateData(FALSE); return FALSE; }
// 初始化 void CTabSample::OnInit(void) { // 控件选择 for (int k=0; k<GraphViewNum; k++) { ProcessMessages(); m_iSelectObject[k] = 0; m_iSelectObjectNoise[k] = 0; m_iButtonIDFDU[k] = IDC_BUTTON_FDU1 + k; m_iCheckIDInstrumentFDU[k] = IDC_CHECK_GRAPHVIEW1 + k; m_iCheckIDNoiseFDU[k] = IDC_CHECK_NOISE1 + k; } CString strtmp = _T(""); for (int i=0; i<GraphViewNum; i++) { ProcessMessages(); strtmp.Format(_T("仪器%d"), i+1); char* pchar = strtmp.GetBuffer(0); strcpy_s(m_cSelectObjectName[i],pchar); } // 得到当前路径 char cSaveToFilePath[MAX_PATH]; GetCurrentDirectory(MAX_PATH, cSaveToFilePath); m_csSaveFilePath = cSaveToFilePath; m_oThreadManage.m_oADCDataRecThread.m_pOScopeCtrl = &m_dlgADCData.m_OScopeCtrl; m_dlgADCData.m_ADCDataRecThread = &m_oThreadManage.m_oADCDataRecThread; // 得到本机IP地址 char name[255]; CString ip; PHOSTENT hostinfo; if( gethostname (name, sizeof(name)) == 0) { if((hostinfo = gethostbyname(name)) != NULL) { ip = inet_ntoa(*(struct in_addr*)*hostinfo-> h_addr_list); } } m_oThreadManage.m_HeadFrameSocket.m_csIPSource = ip; m_oThreadManage.m_TailFrameSocket.m_csIPSource = ip; m_oThreadManage.m_TailTimeFrameSocket.m_csIPSource = ip; m_oThreadManage.m_oSysTimeSocket.m_csIPSource = ip; m_oThreadManage.m_oADCDataRecThread.m_csIPSource = ip; m_oThreadManage.m_oSysTimeSocket.m_pADCSet = &m_oADCSet; m_oThreadManage.m_IPSetSocket.m_pADCSet = &m_oADCSet; CString str; str.Format("0x%04x", m_uiSendPort); GetDlgItem(IDC_EDIT_SENDPORT)->SetWindowText(str); str.Format("%d", m_uiADCFileLength); GetDlgItem(IDC_EDIT_ADCSAVEFRAMENB)->SetWindowText(str); m_iconFDUDisconnected = AfxGetApp()->LoadIcon(IDI_ICON1); m_iconFDUConnected = AfxGetApp()->LoadIcon(IDI_ICON2); m_iconLAUXDisconnected = AfxGetApp()->LoadIcon(IDI_ICON3); m_iconLAUXConnected = AfxGetApp()->LoadIcon(IDI_ICON4); m_oThreadManage.m_oInstrumentList.m_iconFDUDisconnected = m_iconFDUDisconnected; m_oThreadManage.m_oInstrumentList.m_iconLAUXDisconnected = m_iconLAUXDisconnected; m_oThreadManage.m_oInstrumentList.m_pwnd = this; m_oThreadManage.m_IPSetSocket.m_iconFDUConnected = m_iconFDUConnected; m_oThreadManage.m_IPSetSocket.m_iconLAUXConnected= m_iconLAUXConnected; m_oThreadManage.m_IPSetSocket.m_pwnd = this; m_oThreadManage.m_HeadFrameSocket.m_pwnd = this; m_oThreadManage.m_oSysTimeSocket.m_pSelectObject = m_iSelectObject; m_oThreadManage.m_oADCDataRecThread.m_pSelectObject = m_iSelectObject; m_oThreadManage.m_IPSetSocket.m_pSelectObject = m_iSelectObject; m_oThreadManage.m_oADCDataRecThread.m_pSelectObjectNoise = m_iSelectObjectNoise; for(int i=0; i<GraphViewNum; i++) { m_oThreadManage.m_oADCDataRecThread.m_cSelectObjectName[i] = m_cSelectObjectName[i]; m_oThreadManage.m_oInstrumentList.m_iButtonIDFDU[i] = m_iButtonIDFDU[i]; m_oThreadManage.m_IPSetSocket.m_iButtonIDFDU[i] = m_iButtonIDFDU[i]; m_oThreadManage.m_oInstrumentList.m_iCheckIDInstrumentFDU[i] = m_iCheckIDInstrumentFDU[i]; m_oThreadManage.m_IPSetSocket.m_iCheckIDInstrumentFDU[i] = m_iCheckIDInstrumentFDU[i]; } CButton* iconbutton = NULL; CStatic* iconstatic = NULL; CButton* pButton = NULL; iconstatic =(CStatic*)this->GetDlgItem(IDC_STATIC_LAUX); iconstatic->SetIcon(m_iconLAUXDisconnected); iconstatic = NULL; for (int i=0; i<GraphViewNum; i++) { ProcessMessages(); iconbutton = (CButton*)this->GetDlgItem(m_iButtonIDFDU[i]); iconbutton->SetIcon(m_iconFDUDisconnected); iconbutton = NULL; pButton = (CButton*)GetDlgItem(m_iCheckIDInstrumentFDU[i]); pButton->SetCheck(0); pButton = NULL; pButton = (CButton*)GetDlgItem(m_iCheckIDNoiseFDU[i]); pButton->SetCheck(0); pButton = NULL; } delete iconstatic; delete iconbutton; delete pButton; m_oThreadManage.OnInit(); OnOpen(); // 监测尾包定时器 SetTimer(4, 1000, NULL); OnDisableButtons(); }
LRESULT CAppOptGeneralPage::OnInitDialog(HWND hwndFocus, LPARAM lParam) { m_wndUILangList.Attach(GetDlgItem(IDC_UILANG)); m_wndDisableAutoPlay.Attach(GetDlgItem(IDC_DISABLE_AUTOPLAY)); int nIndex = 0; CString str = MAKEINTRESOURCE(IDS_LANG_AUTO); nIndex = m_wndUILangList.AddString(str); m_wndUILangList.SetItemData(nIndex, 0); m_wndUILangList.SetCurSel(0); m_wConfigLangID = static_cast<LANGID>(pGetAppConfigDWORD(_T("Language"), 0)); pLoadAvailableLanguageList(m_wndUILangList, m_wConfigLangID); m_wndAlertDisconnect.Attach(GetDlgItem(IDC_ALERT_DISCONNECT)); m_wndAlertReconnect.Attach(GetDlgItem(IDC_ALERT_RECONNECT)); // m_wndRemountOnBoot.Attach(GetDlgItem(IDC_REMOUNT_ON_BOOT)); int AlertDisconnectCheck = pGetAppConfigBOOL(_T("UseDisconnectAlert"), TRUE) ? BST_CHECKED : BST_UNCHECKED; int AlertReconnectCheck = pGetAppConfigBOOL(_T("UseReconnectAlert"), TRUE) ? BST_CHECKED : BST_UNCHECKED; m_wndAlertDisconnect.SetCheck(AlertDisconnectCheck); m_wndAlertReconnect.SetCheck(AlertReconnectCheck); BOOL fSuccess = m_imageList.CreateFromImage( IDB_OPTION_ICONS, 32, 1, CLR_DEFAULT, IMAGE_BITMAP, LR_CREATEDIBSECTION | LR_DEFAULTCOLOR | LR_DEFAULTSIZE | LR_LOADTRANSPARENT); ATLASSERT(fSuccess); CStatic wndUIIcon = GetDlgItem(IDC_UI_ICON); wndUIIcon.SetIcon(m_imageList.GetIcon(0)); CStatic wndAlertIcon = GetDlgItem(IDC_ALERT_ICON); wndAlertIcon.SetIcon(m_imageList.GetIcon(1)); m_wndDisableAutoPlay.EnableWindow(FALSE); m_disableAutoPlay = TriStateUnknown; CComPtr<IAutoPlayConfig> pAutoPlayConfig; HRESULT hr = pAutoPlayConfig.CoCreateInstance(CLSID_CAutoPlayConfig); if (FAILED(hr)) { ATLTRACE("CLSID_CAutoPlayConfig.CreateInstance failed, hr=0x%X\n", hr); } else { DWORD noDriveTypeAutoRun = 0; hr = pAutoPlayConfig->GetNoDriveTypeAutoRun( reinterpret_cast<ULONG_PTR>(HKEY_CURRENT_USER), &noDriveTypeAutoRun); if (FAILED(hr)) { ATLTRACE("IAutoPlayConfig->GetNoDriveTypeAutoRun failed, hr=0x%X\n", hr); } else { // // TODO: We have to put the shield icon here later // //#ifndef IDI_SHIELD //#define IDI_SHIELD MAKEINTRESOURCE(32518) //#endif // HICON hShieldIcon = LoadIcon(NULL, IDI_SHIELD); // m_wndDisableAutoPlay.SendMessage( // BM_SETIMAGE, IMAGE_ICON, reinterpret_cast<LPARAM>(hShieldIcon)); m_wndDisableAutoPlay.EnableWindow(TRUE); if (noDriveTypeAutoRun & AutorunFixedDrive) { m_wndDisableAutoPlay.SetCheck(BST_CHECKED); m_disableAutoPlay = TriStateYes; } else { m_wndDisableAutoPlay.SetCheck(BST_UNCHECKED); m_disableAutoPlay = TriStateNo; } } } return TRUE; }
void CDlgIOTest::CheckIO_IN(unsigned short num) { int i = 0; CStatic *local; // unsigned short ButtonStatus; // GT_ExInpt(&ButtonStatus); unsigned short tempShort = 0x0001; for (i=0;i<16;i++) { switch (i) { case 1: local = &m_iconIN_1; break; case 2: local = &m_iconIN_2; break; case 3: local = &m_iconIN_3; break; case 4: local = &m_iconIN_4; break; case 5: local = &m_iconIN_5; break; case 6: local = &m_iconIN_6; break; case 7: local = &m_iconIN_7; break; case 8: local = &m_iconIN_8; break; case 9: local = &m_iconIN_9; break; case 10: local = &m_iconIN_10; break; case 11: local = &m_iconIN_11; break; case 12: local = &m_iconIN_12; break; case 13: local = &m_iconIN_13; break; case 14: local = &m_iconIN_14; break; case 15: local = &m_iconIN_15; break; case 16: local = &m_iconIN_16; break; default: local = &m_iconIN_1; } if ((num&tempShort)!=0) { local->SetIcon(AfxGetApp()->LoadIcon(IDI_ICON_REDLIGHT)); } else { local->SetIcon(AfxGetApp()->LoadIcon(IDI_ICON_GREENLIGHT)); } tempShort = tempShort <<1; } }