void CDlgReplaceBox::BuildSearchList()
{
	// Build the list box
	CListBox* theListBox = (CListBox*) GetDlgItem( FINDGET_LIST );
	theListBox->ResetContent();

	// Ensure the string is in Lower case for searching
	m_search_string.MakeLower();

	CLibraryCollection::FillMatchingSymbols( theListBox, m_search_string, NULL );

	// Try and find the selected symbol in the list
	int i;
	for (i = 0; i < theListBox->GetCount(); i++)
	{
		if (theListBox->GetItemDataPtr( i ) == m_Symbol)
		{
			theListBox->SetCurSel( i );
			break;
		}
	}
	if (i == theListBox->GetCount())
	{
		m_Symbol = NULL;
		GetDlgItem( IDC_SHOW_SYMBOL )->RedrawWindow();
	}
}
Exemple #2
0
void CNewsHubDlg::OnBnClickedSend()
{
  CListBox* pRunningClients = (CListBox*)GetDlgItem(IDC_RUNNING_CLIENTS);

  int row = pRunningClients->GetCurSel();
  if (row == LB_ERR)
  {
    MessageBox(_T("Please select one of running clients to send message through"), _T("No client selected"), MB_OK);
    return;
  }

  CEdit* pMessage = (CEdit*)GetDlgItem(IDC_MESSAGE);
  CString message;
  pMessage->GetWindowText(message);

  ClientLoop* clientLoop = (ClientLoop*)pRunningClients->GetItemDataPtr(row);
  unsigned int messageId = clientLoop->nextMessageId();
  clientLoop->Queue()->AddMessage(messageId, std::string(CT2CA(message)));

  CListBox* pSentMessages = (CListBox*)GetDlgItem(IDC_SENT_MESSAGES);
  NewsHub::TcpClient* tcpClient = (NewsHub::TcpClient*)clientLoop->Client();
  CString str;
  str.Format(_T("(To: %s:%d msgId:%d): %s"), 
    CString(tcpClient->Host().c_str()), tcpClient->Port(), messageId, message);

  row = pSentMessages->AddString(str);

  MessageInfo* messageInfo = new MessageInfo;
  messageInfo->queue = clientLoop->Queue();
  messageInfo->messageId = messageId;
  pSentMessages->SetItemDataPtr(row, messageInfo);

  pSentMessages->SetCurSel(row);
}
void CDlgReplaceBox::OnSelchangeList() 
{
	CListBox*	theListBox 	= (CListBox*) GetDlgItem( FINDGET_LIST );
	int			WhichItem 	= theListBox->GetCurSel();

 	if (WhichItem != LB_ERR)
	{
		m_Symbol = static_cast<CLibraryStoreSymbol *>(theListBox->GetItemDataPtr( WhichItem ));
		GetDlgItem( IDC_SHOW_SYMBOL )->RedrawWindow();
	}		
}
Exemple #4
0
void CNewsHubDlg::OnBnClickedServerFinish()
{
  CListBox* pRunningServers = (CListBox*)GetDlgItem(IDC_RUNNING_SERVERS);
  
  int row = pRunningServers->GetCurSel();
  if (row != LB_ERR)
  {
    ServerLoop* serverLoop = (ServerLoop*)pRunningServers->GetItemDataPtr(row);
    delete serverLoop;
    pRunningServers->DeleteString(row);
  }
}
Exemple #5
0
void CNewsHubDlg::onClose()
{
  CListBox* pRunningServers = (CListBox*)GetDlgItem(IDC_RUNNING_SERVERS);
  for (int i = 0; i < pRunningServers->GetCount(); ++i)
  {
    ServerLoop* serverLoop = (ServerLoop*)pRunningServers->GetItemDataPtr(i);
    delete serverLoop;
  }

  CListBox* pRunningClients = (CListBox*)GetDlgItem(IDC_RUNNING_CLIENTS);
  for (int i = 0; i < pRunningClients->GetCount(); ++i)
  {
    ClientLoop* clientLoop = (ClientLoop*)pRunningClients->GetItemDataPtr(i);
    delete clientLoop;
  }

  CListBox* pSentMessages = (CListBox*)GetDlgItem(IDC_SENT_MESSAGES);
  for (int i = 0; i < pSentMessages->GetCount(); ++i)
  {
    MessageInfo* messageInfo = (MessageInfo*)pSentMessages->GetItemDataPtr(i);
    delete messageInfo;
  }
}
Exemple #6
0
bool CFanmotorDlg::GetActiveBridge(CString& BridgeID)
{
    CListBox* listBoxBridges = (CListBox*)GetDlgItem(IDC_BRIDGE_LISTBOX);
    listBoxBridges->SetCurSel(0);
	BridgeID = L"";
	if (listBoxBridges->GetCurSel() < 0) 
	{
		DisplayInforMessageBox((LPCWSTR)L"Error", L"Select Active BRIDGE!");
		return false;
	}
    CBridgeInfo* bridgeInfo = (CBridgeInfo*)listBoxBridges->GetItemDataPtr(listBoxBridges->GetCurSel());
	BridgeID = bridgeInfo->BridgeID;
	return true;
}
Exemple #7
0
void CNewsHubDlg::MessageDelivered(NewsHub::ClientQueueThreadLoop* queue, const NewsHub::Socket & socket, const unsigned int messageId, const std::string & message)
{
  CListBox* pSentMessages = (CListBox*)GetDlgItem(IDC_SENT_MESSAGES);
  for (int i = 0; i < pSentMessages->GetCount(); ++i)
  {
    MessageInfo* messageInfo = (MessageInfo*)pSentMessages->GetItemDataPtr(i);
    if ((messageInfo->queue == queue) && (messageInfo->messageId == messageId))
    {
      CString str;
      pSentMessages->GetText(i, str);
      pSentMessages->DeleteString(i);
      pSentMessages->InsertString(i, str + _T(": Delivered"));
      pSentMessages->SetItemDataPtr(i, messageInfo);
      pSentMessages->SetCurSel(i);
      break;
    }
  }
}
Exemple #8
0
void CFanmotorDlg::RemoveBridgeEvent(BSTR BridgeID)
{
	int i;
	CListBox* listBoxBridges = (CListBox*)GetDlgItem(IDC_BRIDGE_LISTBOX);
	CBridgeInfo* bridgeInfo = NULL;
	
	for (i=0; i<listBoxBridges->GetCount(); i++)
	{
		bridgeInfo = (CBridgeInfo*)listBoxBridges->GetItemDataPtr(i);
		if (bridgeInfo->BridgeID == BridgeID) break;
	}
	if (i == listBoxBridges->GetCurSel())
	{
		CListBox* listBoxDevices = (CListBox*)GetDlgItem(IDC_DEVICE_LISTBOX);
		listBoxDevices->ResetContent();
//		ResetPowerSettings();
//		ResetSpeedSettings();
	}
	if ((i>=0)&&(i<=listBoxBridges->GetCount()))
	{
		delete bridgeInfo;
		listBoxBridges->DeleteString(i);
	}
}