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

📄 mod_rssimdlg.cpp

📁 mod_RSsim
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top            
                         {CResizer::eProportional, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eFixed,IDC_MAIN, CResizer::eBottom}},// bottom             
   {IDC_STATION46,       {CResizer::eProportional, IDC_RULER, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top            
                         {CResizer::eProportional, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eFixed,IDC_MAIN, CResizer::eBottom}},// bottom             
   {IDC_STATION47,       {CResizer::eProportional, IDC_RULER, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top            
                         {CResizer::eProportional, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eFixed,IDC_MAIN, CResizer::eBottom}},// bottom             
   {IDC_STATION48,       {CResizer::eProportional, IDC_RULER, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top            
                         {CResizer::eProportional, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eFixed,IDC_MAIN, CResizer::eBottom}},// bottom             
   {IDC_STATION49,       {CResizer::eProportional, IDC_RULER, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top            
                         {CResizer::eProportional, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eFixed,IDC_MAIN, CResizer::eBottom}},// bottom             
   {IDC_STATION50,       {CResizer::eProportional, IDC_RULER, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top
                         {CResizer::eProportional, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eFixed,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDC_STATION51,       {CResizer::eProportional, IDC_RULER, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top
                         {CResizer::eProportional, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eFixed,IDC_MAIN, CResizer::eBottom}},// bottom
   

   {IDC_VSCROLLSTATIONS, {CResizer::eFixed, IDC_RULER, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top
                         {CResizer::eFixed, IDC_RULER, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom

   //comms debug view
   {IDC_COMMSLIST,       {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eFixed, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom}},// bottom

   {IDC_TRAININGSIM,     {CResizer::eFixed, IDC_MAIN, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDB_TOGGLEDISP,      {CResizer::eFixed, IDC_MAIN, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDC_PAUSECOMMS,      {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDC_TRACKCOMMS,      {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDC_CLEARCOMMS,      {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDC_SHOWCOMMSTIME,      {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   // modem status lamps
   {IDC_LAMPCTS,         {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDC_LAMPDSR,         {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom
   {IDC_LAMPRING,        {CResizer::eFixed, IDC_MAIN, CResizer::eLeft},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eTop},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight,IDC_MAIN, CResizer::eBottom}},// bottom

   {IDC_DRAG,            {CResizer::eFixed, IDC_MAIN, CResizer::eRight},   // left side
                         {CResizer::eFixed, IDC_MAIN, CResizer::eBottom},    // top
                         {CResizer::eWidth, IDC_MAIN, CResizer::eRight},  // right side
                         {CResizer::eHeight, IDC_MAIN, CResizer::eBottom}} // bottom
};


// --------------------------------------- OnInitDialog ------------------------
BOOL CMOD_simDlg::OnInitDialog()
{
CString tickText;
BOOL ret;

	CDialog::OnInitDialog();

   CSplashWnd::EnableSplashScreen(TRUE);
   CSplashWnd::m_splashShowDelay = 1;
   CSplashWnd::ShowSplashScreen(this); 	
      
   m_dragCorner.SubclassDlgItem(IDC_DRAG, this);
   m_dragCorner.SetCornerType(CDragSizerBmp::CORNER_BOTTOMRIGHT, IDB_DRAGSE, TRUE);

   CMenu* pSysMenu = GetSystemMenu(FALSE);
   SetupMySystemMenu(pSysMenu);
	
   const nSize = sizeof(s_bi)/sizeof(s_bi[0]);
   //Second we initialize resizer with this array. 
   //At the same time it will store the original controls positions.
   m_resizer.Init(m_hWnd, NULL, s_bi, nSize);

   m_hAccel = ::LoadAccelerators(AfxGetResourceHandle(), 
                                 m_lpszTemplateName); 
   ASSERT(m_hAccel);
	// TODO: Add extra initialization here
   // load user settings from registry
   LoadApplicationSettings();

   // set mem sizes
   PLCMemory.SetSize(GetNumMemoryAreas());
   SetMemAreaSizes();
   m_listCtrlData.SubclassDlgItem(IDC_DATALIST, this);
   // set display to Hex
   SetAddressFormatHex(m_appSettingAdressHex);
   CheckRadioButton(IDC_VIEWHEX, IDC_VIEWDEC, (IsAddressFormatHex() ? IDC_VIEWHEX : IDC_VIEWDEC));


   // set protcol selection in the list-box
   m_protocolCombo.SetCurSel(m_selectedProtocol);

   //IDC_DATAFORMAT
   FillCharCBox(&m_dataFormatCombo, PLCDataFormatsTable, &ViewerFormatNames[1], sizeof(PLCDataFormatsTable)/sizeof(PLCDataFormatsTable[0]), m_listCtrlData.GetViewFormat());

   m_vScrollBarStations.SetScrollRange(0, MAX_SCROLLINDEX, FALSE);
   // set up the tick-boxes
   for (int stationIndex=0;stationIndex<STATIONTICKBOXESMAX;stationIndex++) 
   {
      //tickText.Format("%02d", stationIndex);
      if (stationIndex < STATIONTICKBOXES)
      {
         ret = m_microTicks[stationIndex].SubclassDlgItem(IDC_STATION00+stationIndex, this);
         //colors
         m_microTicks[stationIndex].SetCheckedColor(m_mTickColorEnabled);
         m_microTicks[stationIndex].SetUnCheckedColor(m_mTickColorDisabled);
         m_microTicks[stationIndex].SetActiveColor(m_mTickColorActive);
         m_microTicks[stationIndex].SetInactiveColor(m_mTickColorInactive);

         m_microTicks[stationIndex].SetTextColor(m_mTickColorText);
         m_microTicks[stationIndex].SetUnCheckedTextColor(m_mTickDisColorText);
         m_microTicks[stationIndex].SetBorderWidth(2);

      }
      
      m_microTicksCountDown[stationIndex] = 0;        // tick-box coloring
      m_microTicksBackState[stationIndex] = FALSE;    // inactive/recently active
      m_microTicksEnableState[stationIndex] = (m_startAsOff ? FALSE : TRUE);
   }

   // RX/TX diodes
   m_lampRX.SubclassDlgItem(IDC_LAMPRX ,this);
   m_lampTX.SubclassDlgItem(IDC_LAMPTX ,this);
   m_lampTraining.SubclassDlgItem(IDC_PLANTSIM, this);
   m_lampCTS.SubclassDlgItem(IDC_LAMPCTS, this);
   m_lampDSR.SubclassDlgItem(IDC_LAMPDSR, this);
   m_lampRING.SubclassDlgItem(IDC_LAMPRING, this);


   m_lampRX.SetupLamp(500);
   m_lampTX.SetupLamp(500);

   m_lampTraining.SetONcolor(RGB(0,200,0)); // set the ON color for this lamp to be GREEN
   m_lampTraining.SetOFFcolor(RGB(0,110,0));

   // start the comms side
   InitiateCommsProcessors(m_selectedProtocol);
   OnSelchangeProtocol();  // update icon

   //m_listCtrlData.SetAreaDisplayed(m_startUpRegisterArea);
   OnSelchangeComboArea();
   //SetupListViewControl(10);//NUMBER_LISTCOLS);

   //TOOLTIPS START
   m_ToolTip.Create (this);
   m_ToolTip.Activate (TRUE);

   CWnd*    pWnd = GetWindow (GW_CHILD);
   while (pWnd)
   {
       int nID = pWnd->GetDlgCtrlID ();
       if (nID != -1)
       {
           m_ToolTip.AddTool (pWnd, pWnd->GetDlgCtrlID ());
       }
       pWnd = pWnd->GetWindow (GW_HWNDNEXT);
   }
   //TOOLTIPS END

   ConfigureStationButtons();

   SetupMyToolBar();

   // Animation and updates timer
   SetTimer(0, 500, NULL);

   // load registers if we have to now.
   if (m_autoLoad)
      PostMessage(wm_LoadRegisters); //calls OnLoad();

   SetDisplayToggleButton();
//   SetDlgItemText(IDB_TOGGLEDISP, (m_registerShow ?"Comms":"Registers"));
   SetDlgItemText(IDC_TRACKCOMMS, (m_commsTobottom? "Stop tracking" : "Track comms"));
   SetDlgItemText(IDC_PAUSECOMMS, (m_paused? "Resume" : "Pause"));


   CRect rect;
   DWORD x=0,y=0;

   {
   CString registryPath;
   DRegKey key;

      m_appSettingAdressHex = m_listCtrlData.IsAddressFormatHex();
      // Save the baud rate etc
      registryPath = APPREGISTRY_SETTINGSKEY;
      key.Open(DRegKey::local_machine, registryPath);
      key.QueryValue("WindowPositionX", &x);//(rect.left+ rect.right<<16)); 
      key.QueryValue("WindowPositionY", &y);//(rect.top+ rect.bottom<<16)); 
      rect.left = x & 0xFFFF;
      rect.right = x >> 16;
      rect.top = y & 0xFFFF;
      rect.bottom = y >> 16;
   }
   if (x && y)
   {
   int cx,cy;
      CWnd *pTop = FindWindow(SIMULATOR_WINDOW_CLASSNAME, NULL);
      cx = GetSystemMetrics(SM_CXFULLSCREEN);
      cy = GetSystemMetrics(SM_CYFULLSCREEN);
      // figure out how to cascade later once we have some time.

      //while ((pTop)&&(pTop->m_hWnd == m_hWnd))
      //   pTop = pTop->GetWindow(GW_HWNDNEXT);

      //if (pTop)
      //{
      //   // other copy, move our asses
      //   pTop->GetWindowRect(&rect);
      //   rect.left += 12;
      //   rect.right+=12;
      //   rect.top+=12;
      //   rect.bottom +=12;
      //}
      if ((rect.left >=0) && (rect.right <= cx) && (rect.top >=0) && (rect.bottom <= cy))
         SetWindowPos(&CWnd::wndTop, rect.left, rect.top, rect.right-rect.left, rect.bottom-rect.top, SWP_SHOWWINDOW);

   }
   // tell the splash screen to close by sending a click
   //PostMessage(WM_NCLBUTTONDOWN,0,0);  

	return TRUE;  // return TRUE  unless you set the focus to a control
} // OnInitDialog


// ----------------------------------- SetMemAreaSizes -------------------------
// set up how many bits/registers each modbus type has got
void CMOD_simDlg::SetMemAreaSizes()
{
   switch (m_selectedProtocol)
   {
      case PROTOCOL_SELMOD232:
      case PROTOCOL_SELMODETH:

⌨️ 快捷键说明

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