コード例 #1
0
void KG3DAnimationContainer::FillAnimationList(CListBox& ListBox, enuFillListBoxType Type)
{
    ListBox.ResetContent();
    LPCTSTR pszName = NULL;
    for(int i = 0; i < static_cast<int>(m_Clips.size()); i++)
    {

        switch(Type)
        {
        case ENUM_FILL_WITH_ANINAME:
        {
            m_Clips[i]->GetName(&pszName);
            ListBox.InsertString(i, pszName);
            ListBox.SetItemData(i, reinterpret_cast<DWORD_PTR>(m_Clips[i]));
            break;
        }
        case ENUM_FILL_WITH_FILENAME:
        {
            m_Clips[i]->GetPathName(&pszName);
            ListBox.InsertString(i, pszName);
            ListBox.SetItemData(i, reinterpret_cast<DWORD_PTR>(m_Clips[i]));
            break;
        }
        }
    }
}
コード例 #2
0
BOOL CExpressionTreeDlg::OnInitDialog() {
  __super::OnInitDialog();

  m_treeCtrl.substituteControl(this, IDC_TREE_EXPRESSION);

  m_layoutManager.OnInitDialog(this);
  m_layoutManager.addControl(IDC_TREE_EXPRESSION  , RELATIVE_SIZE );
  m_layoutManager.addControl(IDCLOSE              , RELATIVE_X_POS);
  m_layoutManager.addControl(IDC_CHECKEXTENDEDINFO, RELATIVE_X_POS);
  m_layoutManager.addControl(IDC_LIST_SYMBOLTABLE , RELATIVE_Y_POS | RELATIVE_WIDTH);

  m_treeCtrl.showTree(m_node, m_extendedInfo);

  const String treeFormName = m_expr.getTreeFormName();
  const String stateName    = m_expr.getStateName();
  const int    nodeCount    = m_expr.getNodeCount();

  String title = getWindowText(this);
  title += format(_T(" - %s form - state %s. %d nodes")
                 ,treeFormName.cstr()
                 ,stateName.cstr()
                 ,nodeCount
                 );
  setWindowText(this, title);

  CListBox *lb = (CListBox*)GetDlgItem(IDC_LIST_SYMBOLTABLE);
  const ExpressionVariableArray variables = m_expr.getSymbolTable().getAllVariables();
  for(size_t i = 0; i < variables.size(); i++) {
    const ExpressionVariableWithValue &v = variables[i];
    lb->InsertString(-1, v.toString().cstr());
  }
  return TRUE;
}
コード例 #3
0
void CChangeOrderDlg::OnEditRandom() {
  m_editList.shuffle();
  CListBox *lb = getListBox();
  lb->ResetContent();
  for(size_t i = 0; i < m_editList.size(); i++) {
    insertMediaFileIntoListBox(i,m_editList[i]);
  }
  lb->InsertString((int)m_mediaQueue.size(),EMPTYSTRING);
}
コード例 #4
0
/**************************************************************************************
    Function Name    :  vPopulateListBox
    Input(s)         :  CListBox& omListBox,const std::list<std::string> lstItems
    Output           :  void
    Functionality    :  Populates ListBox for the given list of string items.
    Member of        :  CExploreMsgSg
    Author(s)        :  Robin G.K.
    Date Created     :  27.10.2015
    Requirement ID   :  RS_FLX_08_09_10
***************************************************************************************/
void CExploreMsgSg::vPopulateListBox(CListBox& omListBox,const std::list<std::string> lstItems)
{
    int nIndex = 0;
    std::string strItem;
for(auto itr:lstItems)
    {
        omListBox.InsertString(nIndex++,itr.c_str());
    }
}
コード例 #5
0
void CChangeOrderDlg::insertMediaFileIntoListBox(size_t pos, const MediaFile &f) {
  CListBox *lb = getListBox();
  String tmp = format(_T("%-38.38s%-36.36s%-36.36s")
                     ,f.getTitle()
                     ,f.getArtist()
                     ,f.getAlbum()
                     );
  int ret = lb->InsertString((int)pos, tmp.cstr());
}
コード例 #6
0
ファイル: QuoteTesterDlg.cpp プロジェクト: weini2/Capital
LRESULT CQuoteTesterDlg::OnData(WPARAM wParam,LPARAM lParam)
{
	if( wParam == 99 )
	{
		BSTR bstrData = (BSTR)lParam;

		CString strReport( bstrData);

		GetDlgItem(IDC_STATIC_TIME)->SetWindowTextW(strReport); 

		SysFreeString(bstrData);
	
		return 0;
	}
	else if( wParam == 98 )
	{
		BSTR bstrData = (BSTR)lParam;

		CString strReport( bstrData);
	
		CListBox   *pListBox   =   (CListBox *)GetDlgItem(IDC_LIST); 

		pListBox->InsertString(0,strReport);

		SysFreeString(bstrData);
	}
	else if( m_nType == wParam )
	{
		BSTR bstrData = (BSTR)lParam;

		CString strReport( bstrData);
	
		CListBox   *pListBox   =   (CListBox *)GetDlgItem(IDC_LIST); 

		pListBox->InsertString(0,strReport);

		SysFreeString(bstrData);
	
		return 0;
	}
}
コード例 #7
0
ファイル: Model.cpp プロジェクト: DT85/Assimilate
void CModelPropPage::PopulatePCJList(void)
{
	CListBox *pListBox = (CListBox *) GetDlgItem(IDC_LIST_PCJ);
	if (pListBox)
	{
		pListBox->ResetContent();

		for (int i = 0; i<m_PCJList.size(); i++)
		{
			pListBox->InsertString(-1, (LPCSTR) m_PCJList[i]);
		}
	}
}
コード例 #8
0
ファイル: xTerrainVegDlg.cpp プロジェクト: ak4hige/myway3d
void xTerrainVegDlg::_refrushList()
{
	CListBox * list = (CListBox *)GetDlgItem(IDC_TV_List);

	while (list->GetCount())
		list->DeleteString(0);

	for (int i = 0; i < MForest::Instance()->GetVegetationCount(); ++i)
	{
		MVegetation * veg = MForest::Instance()->GetVegetation(i);

		list->InsertString(i, veg->Name.c_str());
	}
}
コード例 #9
0
ファイル: SelectDialog.cpp プロジェクト: bklimt/QueryWizard
void CSelectDialog::OnUpButtonClicked() {
	CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST );
	for ( int i=1; i<chosenList->GetCount(); i++ ) {
		if ( chosenList->GetSel( i ) ) {
			char temp[4000];
			if ( !chosenList->GetSel( i-1 ) ) {
				chosenList->GetText( i, temp );
				chosenList->InsertString( i-1, temp );
				chosenList->SetSel( i-1, TRUE );
				chosenList->DeleteString( i+1 );
			}
		}
	}
}
コード例 #10
0
ファイル: SelectDialog.cpp プロジェクト: bklimt/QueryWizard
void CSelectDialog::OnDownButtonClicked() {
	CListBox* chosenList = (CListBox*)GetDlgItem( IDC_CHOSENLIST );
	for ( int i=chosenList->GetCount()-2; i>=0; i-- ) {
		if ( chosenList->GetSel( i ) ) {
			if ( !chosenList->GetSel( i+1 ) ) {
				char temp[4000];
				chosenList->GetText( i+1, temp );
				chosenList->InsertString( i, temp );
				chosenList->SetSel( i+2, TRUE );
				chosenList->DeleteString( i+2 );
			}
		}
	}
}
コード例 #11
0
BOOL CChangeOrderDlg::OnInitDialog() {
  m_accelTable = LoadAccelerators(theApp.m_hInstance,MAKEINTRESOURCE(IDR_CHANGEORDER_ACCELERATOR));

  for(size_t i = 0; i < m_mediaQueue.size(); i++) {
    insertMediaFile(i,m_mediaQueue[i]);
  }
  CListBox *lb = getListBox();
  lb->InsertString((int)m_mediaQueue.size(),EMPTYSTRING);
  __super::OnInitDialog();

  gotoToListBox();
  if(!m_mediaQueue.isEmpty()) {
    lb->SetSel(0);
  }
  return false;
}
コード例 #12
0
ファイル: DizzyDialog.cpp プロジェクト: Floppy/Vapour
void CDizzyDialog::OnDownButton() 
{
	UpdateData(true);
	CListBox* pListBox = (CListBox*) GetDlgItem(IDC_INPUT_LIST);
	int iOffset = pListBox->GetCurSel();
	if ((iOffset != LB_ERR) && (iOffset != pListBox->GetCount()-1)) {
		CString strCurrent;
		pListBox->GetText(iOffset, strCurrent);
		pListBox->DeleteString(iOffset);
		iOffset++;
		pListBox->InsertString(iOffset, strCurrent);
		pListBox->SetCurSel(iOffset);
		RecalculateRotation();
	}
	UpdateData(false);
}
コード例 #13
0
BOOL DlgGuardFlags::OnInitDialog() 
{
	CDialog::OnInitDialog();
	CListBox* lb;
	
	lb = (CListBox*)GetDlgItem(IDC_GUARD_FLAGS);

	for(int i = 0; i < GuardBitCount(); i++)
	{
		lb->InsertString(i, guard_bits[i].name);
		lb->SetItemData(i, guard_bits[i].bit);
	}
	
	SetFlags();

	return TRUE;
}
コード例 #14
0
void CSaveMovieDialog::OnButtonUp()
{
	CListBox * pListBox = (CListBox *)GetDlgItem(IDC_LIST_BITMAP_FILENAME);
	if ( pListBox->GetSelCount() != 1 )
		return;

	if ( pListBox->GetCurSel() <= 0 )
		return;

	int sel = pListBox->GetCurSel();
	CString currentText;
	pListBox->GetText (sel, currentText );
	pListBox->InsertString(sel-1 , currentText);
	pListBox->DeleteString(sel+1);

	pListBox->SetSel(sel-1, TRUE);
}
コード例 #15
0
ファイル: newshubuiDlg.cpp プロジェクト: rushad/newshub
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;
    }
  }
}
コード例 #16
0
ファイル: AddDlg.cpp プロジェクト: zephyrer/mfc-project
void CAddDlg::OnBnClickedOk()
{
	// 获得主窗口句柄,用来在列表框中增加数据(虽然这样不安全,但个人喜欢)
	CTextCodeConverterDlg* MainDlg = (CTextCodeConverterDlg*)this->GetParent();	
	ASSERT(MainDlg->GetSafeHwnd());

	// 取得主窗口中的列表框句柄
	CListBox* listBox = (CListBox*)MainDlg->GetDlgItem(IDC_LIST1);
	ASSERT(listBox->GetSafeHwnd());

	GetDlgItemText(IDC_EDIT1,m_strEdit);

	// 如果在启动窗口时为修改内容,则删除对应位置数据之后,然后在增加
	if (m_bUpdate == TRUE)
	{
		listBox->DeleteString(listBox->GetCurSel());
		listBox->InsertString(listBox->GetCurSel(),m_strEdit);
	}
	OnOK();
}
コード例 #17
0
void CLoadFailedTextureDialog::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	
	CListBox* pListBox = (CListBox*)GetDlgItem(IDC_LOADFAILED_LIST);

	if (NULL != pListBox)
	{
		int i = 0;
		for (i = 0; i < pListBox->GetCount(); i++)
		{
			pListBox->DeleteString(0);
		}

		for (i = 0; i < (int)m_dwLoadFailedTextureTableCount; i++)
		{
			pListBox->InsertString(i, m_pLoadFailedTextureTable[i].szTextureName);
		}	
	}
	
}
コード例 #18
0
ファイル: xTerrainVegDlg.cpp プロジェクト: ak4hige/myway3d
void xTerrainVegDlg::_AfterLoadScene(Event * sender)
{
	CListBox * list = (CListBox *)GetDlgItem(IDC_TV_List);

	for (int i = 0; i < MForest::Instance()->GetVegetationCount(); ++i)
	{
		MVegetation * veg = MForest::Instance()->GetVegetation(i);

		list->InsertString(i, veg->Name.c_str());
	}

	if (Environment::Instance()->GetTerrain() && MForest::Instance()->GetVegetationBlockCount() == 0)
	{
		Terrain * terrain = Environment::Instance()->GetTerrain();

		const Terrain::Config & config = terrain->GetConfig();
		RectF rect = RectF(0, 0, config.xSize, config.zSize);

		MForest::Instance()->CreateVegetationBlocks(rect, config.xSectionCount, config.zSectionCount);
	}
}
コード例 #19
0
ファイル: DeviceDialog.cpp プロジェクト: dvdrndlph/dactylize
BOOL CDeviceDialog::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	vl_getDeviceList(m_deviceList);

	CListBox* pListBox = (CListBox*)GetDlgItem( IDC_DEVICE_LISTBOX );
	
	if(pListBox)
	{
		pListBox->ResetContent();

		for(int ii = 0;ii < m_deviceList.size();ii++)
		{
			// Store the entry into the list
			pListBox->InsertString(ii, m_deviceList[ii]->getDeviceName());
		}			
	}

	return TRUE;	// return TRUE unless you set the focus to a control
						// EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #20
0
ファイル: WinComicsDlg.cpp プロジェクト: Evanthx/comics
UINT RunComics(LPVOID pParam)
{
	CWinComicsDlg* theDialog = (CWinComicsDlg*)pParam;
	CListBox* listbox = &theDialog->m_StatusList;
	ComicMaker comics(listbox);
	bool UpdatesAvailable = comics.Runner();

	listbox->InsertString(0,"Done!  Lauching Web Browser.");
	//launch the web browser
	ShellExecute(GetDesktopWindow(), "open",
		ComicOutFile, NULL, NULL, SW_SHOW);
	
	if (UpdatesAvailable)
	{
		ShellExecute(GetDesktopWindow(), NULL,
			"ComicUpdater.exe", NULL, NULL, SW_SHOW);
	}

	
	theDialog->SendMessage(WM_CLOSE);
	return(0);
}
コード例 #21
0
ファイル: xSceneOpenDlg.cpp プロジェクト: ak4hige/myway3d
BOOL xSceneOpenDlg::OnInitDialog()
{
    if (!CDialog::OnInitDialog())
        return FALSE;

    CListBox * list = (CListBox *)GetDlgItem(IDC_SceneOpen_Floder);

    ResourceGroup * rg = ResourceManager::Instance()->GetResourceGroup();

    ResourceGroup::ArchiveVisitor v = rg->GetArchives();

    int index = 0;
    while (!v.Endof())
    {
        const TString128 & floder = (*v.Cursor())->GetName();

        list->InsertString(index, floder.c_str());

        ++v;
    }

    return TRUE;
}
コード例 #22
0
ファイル: DizzyDialog.cpp プロジェクト: Floppy/Vapour
void CDizzyDialog::OnAddButton() 
{
	UpdateData(true);
	CListBox* pListBox = (CListBox*) GetDlgItem(IDC_INPUT_LIST);
	CAxisRotation inputRotation;
	bool bValidString = inputRotation.ParseString(m_strInput);
	if (bValidString) {
		int iOffset = pListBox->GetCurSel();
		if (iOffset != LB_ERR) {
			pListBox->InsertString(iOffset+1,m_strInput);
			pListBox->SetCurSel(iOffset+1);
		}	
		else {
			pListBox->AddString(m_strInput);
			pListBox->SetCurSel(pListBox->GetCount()-1);
		}
		RecalculateRotation();
		m_strInput = "";
		UpdateData(false);
	}
	else {
		::AfxMessageBox("Input must be a valid axis-angle rotation!");
	}
}
コード例 #23
0
ファイル: ToolBrushDialog.cpp プロジェクト: YunHsiao/Echo
BOOL CToolBrushDialog::OnInitDialog()
{
	CDialog::OnInitDialog();

	// 获取自身的宽高
	GetWindowRect(&m_rWndRect);
	m_rWndRect.right  -= m_rWndRect.left;
	m_rWndRect.bottom -= m_rWndRect.top;

	// 添加LIST控件项
	CListBox* list = (CListBox*)GetDlgItem(IDC_BRUSHLIST);
	for(int i(0);i < 10;++i)
	{
		CString str = _T("");
		str.Format(L"%d",i);
		list->InsertString(i,str.GetBuffer());
	}

	tinyxml2::XMLDocument File;
	if(File.LoadFile("Res/ButtonStr.xml"))
	{
		AfxMessageBox(L"Res/ButtonStr.xml 文件加载失败!");
		return FALSE;
	}

	tinyxml2::XMLElement* tRoot = File.FirstChildElement();
	tinyxml2::XMLElement* tName = tRoot->FirstChildElement();
	int tabNum = atoi(tName->FirstChild()->Value());

	// 初始化标签
	for(int i(0);i<tabNum;++i)
	{
		tName = tName->NextSiblingElement();
		WCHAR str[MAX_PATH] = {0};
		LPCSTR buff = tName->Attribute("str");
		MultiByteToWideChar(CP_ACP,0,buff,-1,str,(int)strlen(buff)+1);
		m_Tab.InsertItem(i,str);
	}

	// 字符串的初始化
	// 画刷层字符串
	tinyxml2::XMLElement* tTemp = tName->NextSiblingElement();
	m_nBrushMaxNum = atoi(tTemp->FirstChild()->Value());

	for(int i(0);i < m_nBrushMaxNum;++i)
	{
		tTemp = tTemp->NextSiblingElement();
		WCHAR str[MAX_PATH] = {0};
		LPCSTR buff = tTemp->Attribute("str");
		MultiByteToWideChar(CP_ACP,0,buff,-1,str,(int)strlen(buff)+1);
		m_pStrBrush[i] = str;
	}

	// NPC层字符串
	tTemp = tTemp->NextSiblingElement();
	m_nNpcMaxNum = atoi(tTemp->FirstChild()->Value());

	for(int i(0);i < m_nNpcMaxNum;++i)
	{
		tTemp = tTemp->NextSiblingElement();
		WCHAR str[MAX_PATH] = {0};
		LPCSTR buff = tTemp->Attribute("str");
		MultiByteToWideChar(CP_ACP,0,buff,-1,str,(int)strlen(buff)+1);
		m_pStrNpc[i] = str;
	}

	// 怪物层字符串
	tTemp = tTemp->NextSiblingElement();
	m_nMonsterMaxNum = atoi(tTemp->FirstChild()->Value());

	for(int i(0);i < m_nMonsterMaxNum;++i)
	{
		tTemp = tTemp->NextSiblingElement();
		WCHAR str[MAX_PATH] = {0};
		LPCSTR buff = tTemp->Attribute("str");
		MultiByteToWideChar(CP_ACP,0,buff,-1,str,(int)strlen(buff)+1);
		m_pStrMonster[i] = str;
	}

	// 碰撞层字符串
	tTemp = tTemp->NextSiblingElement();
	m_nCollMaxNum = atoi(tTemp->FirstChild()->Value());

	for(int i(0);i < m_nCollMaxNum;++i)
	{
		tTemp = tTemp->NextSiblingElement();
		WCHAR str[MAX_PATH] = {0};
		LPCSTR buff = tTemp->Attribute("str");
		MultiByteToWideChar(CP_ACP,0,buff,-1,str,(int)strlen(buff)+1);
		m_pStrColl[i] = str;
	}

	// 触发层字符串
	tTemp = tTemp->NextSiblingElement();
	m_nTrigMaxNum = atoi(tTemp->FirstChild()->Value());

	for(int i(0);i < m_nTrigMaxNum;++i)
	{
		tTemp = tTemp->NextSiblingElement();
		WCHAR str[MAX_PATH] = {0};
		LPCSTR buff = tTemp->Attribute("str");
		MultiByteToWideChar(CP_ACP,0,buff,-1,str,(int)strlen(buff)+1);
		m_pStrTrig[i] = str;
	}

	// 设置默认层
	ProcBrushState();

	ShowWindow(SW_SHOW);
	UpdateWindow();

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
コード例 #24
0
ファイル: WelcomePowEditor.cpp プロジェクト: twilson-sf/diplo
void PSWelcomePowEditor::OnOK() 
{
	UpdateData();
	// If no power is selected and the choice was 'Modify', error.
	if (m_strSelectedPow == "" && 
		(m_nSelection == 1 || m_nSelection == 2))
	{
		MessageBox(L"Please select a power to continue.", L"DipSheet", MB_ICONEXCLAMATION);
		return;
	}

	PSPower* pCurPow = NULL;
	switch(m_nSelection)
	{
	case 0:// New
		{
		pCurPow = new PSPower;
		PSPowProp dlg;
		dlg.SetTitle(_T("New Power"));
		dlg.SetColor(::GetSysColor(COLOR_BTNFACE));
		dlg.m_strName = "";
		if (dlg.DoModal() == IDOK)
		{
			pCurPow->SetColor(dlg.GetColor());
			TG.AddPower(pCurPow);
			CListBox* pLB = (CListBox*)GetDlgItem(IDC_PROV_LIST);
			pLB->InsertString(-1, pCurPow->m_strName);
		}
		else 
			delete pCurPow;
		break;
		}
	case 1:// Modify
		{
		pCurPow = new PSPower(TG.GetPower(m_strSelectedPow));
		PSPowProp dlg;
		dlg.SetTitle(pCurPow->m_strName);
		dlg.SetColor(pCurPow->GetColor());
		dlg.m_strName = pCurPow->m_strName;
		if (dlg.DoModal() == IDOK)
		{
			pCurPow->SetColor(dlg.GetColor());
			TG.DeletePower(TG.GetPower(m_strSelectedPow));
			TG.AddPower(pCurPow);
			CListBox* pLB = (CListBox*)GetDlgItem(IDC_PROV_LIST);
			pLB->DeleteString(pLB->GetCurSel());
			pLB->InsertString(-1, pCurPow->m_strName);
		}
		else
			delete pCurPow;
		break;
		}
	case 2:// Remove
		pCurPow = TG.GetPower(m_strSelectedPow);
		ASSERT(pCurPow);
		if (MessageBox(L"Are you sure you wish to delete " + m_strSelectedPow + "?", L"DipSheet", MB_YESNO) == IDYES)
		{
			TG.DeletePower(pCurPow);
			CListBox* pLB = (CListBox*)GetDlgItem(IDC_PROV_LIST);
			pLB->DeleteString(pLB->GetCurSel());
		}
		return;
	default:
		ASSERT(0);
	}
}
コード例 #25
0
int CMessageEditorDlg::update(int num)
{
	char *ptr, buf[4096];
	int i, node, fnode;
	CListBox *list;

	UpdateData(TRUE);
	if (num >= 0)
	{
		ptr = (char *) (LPCTSTR) m_message_name;
		for (i=0; i<Num_messages; i++)
			if ((i != num) && (!stricmp(m_message_name, Messages[i].name)))
				break;

		if (i == Num_messages) {  // update name if no conflicts, otherwise keep old name
			update_sexp_references(Messages[num].name, ptr, OPF_MESSAGE);
			string_copy(Messages[num].name, m_message_name, NAME_LENGTH - 1);

			list = (CListBox *) GetDlgItem(IDC_MESSAGE_LIST);
			list->DeleteString(num);
			list->InsertString(num, m_message_name);
		}

		string_copy(Messages[num].message, m_message_text, MESSAGE_LENGTH - 1);
		if (Messages[num].avi_info.name)
			free(Messages[num].avi_info.name);

		ptr = (char *) (LPCTSTR) m_avi_filename;
		if (!ptr || !strlen(ptr))
			Messages[num].avi_info.name = NULL;
		else
			Messages[num].avi_info.name = strdup(ptr);

		if (Messages[num].wave_info.name)
			free(Messages[num].wave_info.name);

		ptr = (char *) (LPCTSTR) m_wave_filename;
		if (!ptr || !strlen(ptr))
			Messages[num].wave_info.name = NULL;
		else
			Messages[num].wave_info.name = strdup(ptr);

		// update the persona to the message.  We subtract 1 for the "None" at the beginning of the combo
		// box list.
		Messages[num].persona_index = m_persona - 1;

		if (m_tree.query_false()) {
			if (m_event_num >= 0) {  // need to delete event
				i = m_event_num;
				free_sexp2(Mission_events[i].formula);
				Assert(i < Num_mission_events);
				while (i < Num_mission_events - 1) {
					Mission_events[i] = Mission_events[i + 1];
					i++;
				}

				Num_mission_events--;
				m_event_num = -1;
			}

		} else {
			if (m_event_num >= 0)
				free_sexp2(Mission_events[m_event_num].formula);
			
			else {
				if (Num_mission_events == MAX_MISSION_EVENTS) {
					MessageBox("You have reached the limit on mission events.\n"
						"Can't add an event to send this message.");

					goto exit;
				}

				Assert(Num_mission_events < MAX_MISSION_EVENTS);
				m_event_num = Num_mission_events++;
				string_copy(Mission_events[m_event_num].name, m_message_name, NAME_LENGTH - 1);
				Mission_events[m_event_num].repeat_count = 1;
				Mission_events[m_event_num].interval = 1;
				Mission_events[m_event_num].score = 0;
				Mission_events[m_event_num].chain_delay = -1;
				Mission_events[m_event_num].objective_text = NULL;
				Mission_events[m_event_num].objective_key_text = NULL;
			}

			fnode = m_tree.save_tree();
			ptr = (char *) (LPCTSTR) m_message_name;
			node = alloc_sexp(ptr, SEXP_ATOM, SEXP_ATOM_STRING, -1, -1);
			((CComboBox *) GetDlgItem(IDC_PRIORITY))->GetLBText(m_priority, buf);
			node = alloc_sexp(buf, SEXP_ATOM, SEXP_ATOM_STRING, -1, node);
			((CComboBox *) GetDlgItem(IDC_SENDER))->GetLBText(m_sender, buf);
			node = alloc_sexp(buf, SEXP_ATOM, SEXP_ATOM_STRING, -1, node);
			node = alloc_sexp("send-message", SEXP_ATOM, SEXP_ATOM_OPERATOR, -1, node);
			node = alloc_sexp("", SEXP_LIST, SEXP_ATOM_LIST, node, -1);
			node = alloc_sexp("", SEXP_LIST, SEXP_ATOM_LIST, fnode, node);
			node = alloc_sexp("when", SEXP_ATOM, SEXP_ATOM_OPERATOR, -1, node);
			Mission_events[m_event_num].formula = node;
		}
	}

exit:
	if (query_modified())
		set_modified();

	modified = 0;
	return 0;
}
コード例 #26
0
ファイル: TT3Dlg.cpp プロジェクト: 12019/TT3
int msgarrvd(void *context, char *topicName, int topicLen, MQTTClient_message *message)
{
	//char cS[100];
	char * pBuffer = (char *)malloc(message->payloadlen + 1);
	char * pHash = (char *)malloc(20);
	char * pEnoch = (char *)malloc(20);
	
	//strncpy_s(cS, (char *)message->payload, min(message->payloadlen, sizeof(cS)));
	strncpy(pBuffer, (char *)message->payload, message->payloadlen);
	//cS[message->payloadlen] = 0x0;
	*(pBuffer+message->payloadlen) = 0x0;

	CWnd *tA = theApp.GetMainWnd();
	
	// Adjust counter
	CTT3Dlg *tA2 = (CTT3Dlg *)tA;
	//check if alert must play
	if (tA2->iAlert > 0) {
		// find substring match
		int i = 0;
		char * pAnswer;
		while (i < tA2->iAlert) {
			if (!strcmp(tA2->ALERTME[i][0], "1")) {
				if (strstr(pBuffer, tA2->ALERTME[i][1])) {
					Beep(atoi(tA2->ALERTME[i][2]), atoi(tA2->ALERTME[i][3]));
					// run exe
					char * cmdline = (char *)malloc(2000);
					PROCESS_INFORMATION processInformation;
					STARTUPINFO startupInfo;
					memset(&processInformation, 0, sizeof(processInformation));
					memset(&startupInfo, 0, sizeof(startupInfo));
					startupInfo.cb = sizeof(startupInfo);

					strcpy(cmdline, tA2->ALERTME[i][4]);
					if (strlen(cmdline) > 0) {
						strcat(cmdline, " ");
						strcat(cmdline, topicName);
						strcat(cmdline, ",");
						strcat(cmdline, pBuffer);
						if (!CreateProcess(NULL, cmdline, NULL, NULL, false, 0, NULL, NULL, &startupInfo, &processInformation)) {
							char * pErrMsg = (char *)malloc(500);
							strcpy(pErrMsg, "Unknown application ");
							strcat(pErrMsg, tA2->ALERTME[i][4]);
							MessageBox(NULL, pErrMsg, "Alert Error", MB_OK);
							free(pErrMsg);
						}
					}
				}
			}
			i++;
		}
	}
	CListCtrl *pListctrl = (CListCtrl *)tA->GetDlgItem(IDC_LIST3);
	CButton *pButton1 = (CButton*) tA->GetDlgItem(IDC_CHECK4);

	tA->SetDlgItemInt(IDC_EDIT14, ++tA2->iReceived,FALSE);
	tA->SetDlgItemInt(IDC_EDIT18, tA2->iReceived - tA2->iReceivedRemoved, FALSE);

	// Check maximum messages allowed in listbox
	
	if (pButton1->GetCheck() == BST_CHECKED) {
		int iMaxAllowed  = tA->GetDlgItemInt(IDC_EDIT13,NULL,FALSE);
		int iCurrentRows = pListctrl->GetItemCount();
		while (iCurrentRows >= iMaxAllowed) {
			// Delete oldest one
			pListctrl->DeleteItem(iCurrentRows - 1);
			tA2->iReceivedRemoved++;
			iCurrentRows--;
		}
		tA->SetDlgItemInt(IDC_EDIT15, tA2->iReceivedRemoved,FALSE);
		tA->SetDlgItemInt(IDC_EDIT18, tA2->iReceived - tA2->iReceivedRemoved,FALSE);
	}

	LVITEM lvi;
	
	lvi.mask = LVIF_TEXT;
	lvi.iItem = 0;
	
	lvi.iSubItem = 0;
	_itoa(iHash++, pHash, 10);
	lvi.pszText = pHash;
	pListctrl->InsertItem(&lvi);
	
	lvi.iSubItem = 1;
	time_t timer = time(NULL);
	lvi.pszText = ctime(&timer);
	pListctrl->SetItem(&lvi);

	lvi.iSubItem = 2;
	lvi.pszText = topicName;
	pListctrl->SetItem(&lvi);

	lvi.iSubItem = 3;
	lvi.pszText = pBuffer;
	pListctrl->SetItem(&lvi);

	lvi.iSubItem = 4;
	itoa(timer, pEnoch, 10);
	lvi.pszText = pEnoch;
	pListctrl->SetItem(&lvi);

	pListctrl->SetColumnWidth(0, LVSCW_AUTOSIZE);
	pListctrl->SetColumnWidth(1, LVSCW_AUTOSIZE);
	pListctrl->SetColumnWidth(3, LVSCW_AUTOSIZE);

	// Set Column width for topic
	int iTW = pListctrl->GetStringWidth(topicName);
	if (iTW > tA2->iTopicWidth && iTW < 400) {
		tA2->iTopicWidth = iTW;
		pListctrl->SetColumnWidth(2, iTW+15);
	}

	//Beep on receive if checkbox selected
	pButton1 = (CButton*) tA->GetDlgItem(IDC_CHECK2);
	if (pButton1->GetCheck() == BST_CHECKED) {
		Beep(300, 200);
	} 

	// See if topic is in subscriptions list
	CListBox *pListbox = (CListBox *)tA->GetDlgItem(IDC_LIST1);
	if (pListbox->FindStringExact(0, topicName) == LB_ERR) {
		pListbox->InsertString(0, topicName);
		tA->SetDlgItemText(IDC_EDIT11, "Consider saving setup");
	}
	
	free(pHash); free(pEnoch); free(pBuffer);
	MQTTClient_freeMessage(&message);
    MQTTClient_free(topicName);
	
    return 1;
}
コード例 #27
0
int event_editor::save_message(int num)
{
	char *ptr;
	int i, conflict = 0;
	CListBox *list;

	UpdateData(TRUE);
	if (num >= 0) {
		ptr = (char *) (LPCTSTR) m_message_name;
		for (i=0; i<Num_builtin_messages; i++){
			if (!stricmp(m_message_name, Messages[i].name)) {
				conflict = 1;
				break;
			}
		}

		for (i=0; i<m_num_messages; i++){
			if ((i != num) && (!stricmp(m_message_name, m_messages[i].name))) {
				conflict = 1;
				break;
			}
		}

		if (!conflict) {  // update name if no conflicts, otherwise keep old name
			string_copy(m_messages[num].name, m_message_name, NAME_LENGTH - 1);

			list = (CListBox *) GetDlgItem(IDC_MESSAGE_LIST);
			list->DeleteString(num);
			list->InsertString(num, m_message_name);
		}

		string_copy(m_messages[num].message, m_message_text, MESSAGE_LENGTH - 1);
		lcl_fred_replace_stuff(m_messages[num].message, MESSAGE_LENGTH);
		if (m_messages[num].avi_info.name){
			free(m_messages[num].avi_info.name);
		}

		ptr = (char *) (LPCTSTR) m_avi_filename;
		if ( !ptr || !VALID_FNAME(ptr) ) {
			m_messages[num].avi_info.name = NULL;
		} else {
			m_messages[num].avi_info.name = strdup(ptr);
		}

		if (m_messages[num].wave_info.name){
			free(m_messages[num].wave_info.name);
		}

		ptr = (char *) (LPCTSTR) m_wave_filename;
		if ( !ptr || !VALID_FNAME(ptr) ) {
			m_messages[num].wave_info.name = NULL;
		} else {
			m_messages[num].wave_info.name = strdup(ptr);
		}

		// update the persona to the message.  We subtract 1 for the "None" at the beginning of the combo
		// box list.
		m_messages[num].persona_index = m_persona - 1;

		if(m_message_team >= MAX_TVT_TEAMS){
			m_messages[num].multi_team = -1;
			m_message_team = -1;
		} else {
			m_messages[num].multi_team = m_message_team;
		}

		// possible TODO: auto-update event tree references to this message if we renamed it.
	}

	return 0;
}
コード例 #28
0
ファイル: AnimPicker.cpp プロジェクト: DT85/Assimilate
void CAnimPicker::FillListBoxes()
{
	// fill in the enum list boxes...
	//
	CListBox* boxLegs = (CListBox*)GetDlgItem(IDC_LIST_LEGS);
	CListBox* boxTorso= (CListBox*)GetDlgItem(IDC_LIST_TORSO);
	CListBox* boxBoth = (CListBox*)GetDlgItem(IDC_LIST_BOTH);
	CListBox* boxFace = (CListBox*)GetDlgItem(IDC_LIST_FACE);
	CListBox* boxVM = (CListBox*)GetDlgItem(IDC_LIST_VM);
	boxLegs->ResetContent();
	boxTorso->ResetContent();
	boxBoth->ResetContent();
	boxFace->ResetContent();
	boxVM->ResetContent();

	CModel* theModel = ghAssimilateView->GetDocument()->GetCurrentUserSelectedModel();
	ASSERT(theModel);
	if (theModel)
	{
		for (int i=0; ; i++)
		{
			LPCSTR p = ((CAssimilateApp*)AfxGetApp())->GetEnumEntry(i);	
			if (!p)
				break;

			CString string = p;			

			if (theModel->AnimEnumInUse(p))
			{
				if (m_bFilterOutUsed)
					continue;
				string.Insert(0,sEnumUsedString);
			}			

			if (IsEnumSeperator(p))
			{
				string = StripSeperatorStart(p);
				string.Insert(0,sEnumSeperatorString_Prefix);
				string+=sEnumSeperatorString_Suffix;
			}

			CListBox* listBoxPtr = NULL;		
			switch (GetEnumTypeFromString(p))	// note (p), *not* (string)
			{			
				case ET_BOTH:	listBoxPtr = boxBoth;	break;
				case ET_TORSO:	listBoxPtr = boxTorso;	break;
				case ET_LEGS:	listBoxPtr = boxLegs;	break;
				case ET_FACE:	listBoxPtr = boxFace;	break;
				case ET_VM:		listBoxPtr = boxVM;		break;
				default:		ASSERT(0);				break;	
			}
			if (listBoxPtr)
			{
				// keep an index to the original enum for comment-diving reasons...
				//
				int iIndex = listBoxPtr->InsertString(-1,string);
				listBoxPtr->SetItemData(iIndex,(DWORD)p);
			}
		}
	}
}