mrDarker
2025-05-12 d256f84735b75529a640ca61384c3c55b557fce9
SourceCode/Bond/Servo/LogDlg.cpp
@@ -154,12 +154,30 @@
   // 内容
   m_logEdit.SetMaxLineCount(20);
   m_logEdit.SetMaxLineCount(500);
   m_logEdit.SetLimitText(-1);
   InitRxWindow();
   std::thread([this]() {
      constexpr int nMaxWaitMs = 3000;  // 最多等待 3 秒
      constexpr int nStepMs = 1;        // 每次等待 1ms
      int nElapsed = 0;
      while (nElapsed < nMaxWaitMs) {
         if (theApp.m_model.getObservable() != nullptr) {
            InitRxWindow();
            return;
         }
         std::this_thread::sleep_for(std::chrono::milliseconds(nStepMs));
         nElapsed += nStepMs;
      }
      // 超时也可以发消息记录下日志
      TRACE(_T("InitRxWindow 超时,未执行\n"));
   }).detach();
   Resize();
   return TRUE;  // return TRUE unless you set the focus to a control
@@ -170,14 +188,18 @@
{
   CDialogEx::OnSize(nType, cx, cy);
   if (GetDlgItem(IDC_EDIT_LOG) == nullptr) return;
   Resize();
}
void CLogDlg::Resize()
{
   int x, y, y2, temp;
   CRect rcClient, rcItem;
   CWnd* pItem;
   GetClientRect(&rcClient);
   y = 0;
   x = 12;
   x = 8;
   pItem = GetDlgItem(IDC_BUTTON_LEVEL);
   pItem->GetWindowRect(&rcItem);
   ScreenToClient(&rcItem);
@@ -185,6 +207,7 @@
   x += rcItem.Width();
   x += 18;
   y2 = rcItem.bottom;
   y2 += 8;
   pItem = GetDlgItem(IDC_BUTTON_INCLUDE);
   pItem->GetWindowRect(&rcItem);
@@ -203,9 +226,9 @@
   pItem->GetWindowRect(&rcItem);
   pItem->MoveWindow(x, y + (temp - rcItem.Height()) / 2, rcItem.Width(), rcItem.Height());
   x = 12;
   x = 8;
   pItem = GetDlgItem(IDC_EDIT_LOG);
   pItem->MoveWindow(x, y2, rcClient.Width() - 24, rcClient.Height() - 5 - y2);
   pItem->MoveWindow(x, y2, rcClient.Width() - 16, rcClient.Height() - 5 - y2);
}
void CLogDlg::OnDestroy()