void CPropPage_Groups::OnButtonRemove() 
{
	int k;
	CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_LIST_GROUPS);

	int nSelected = pListCtrl->GetSelectedCount();

	if(nSelected == 0)
	{
		CString strResourceBundleString;
		strResourceBundleString.LoadString(IDS_NO_NEWSGROUP_SELECTED);
		AfxMessageBox(LPCTSTR(strResourceBundleString), MB_ICONINFORMATION); 
		return;
	}

	TCHAR szTT[64];
	sprintf(szTT, "Delete %d selected newsgroups from list?", nSelected);

	if(AfxMessageBox(szTT, MB_ICONQUESTION | MB_OKCANCEL) == IDOK)
	{
		int nCount = pListCtrl->GetItemCount();
		for(k = nCount; k >= 0; k--)
		{
			if(pListCtrl->GetItemState(k, LVIS_SELECTED) == LVIS_SELECTED)
				pListCtrl->DeleteItem(k);
		}
	}
	SetModified(TRUE);
}
Example #2
0
//
//	This is a utility function used to move items from the resource list 
//	to the dependency list and visa versa.
//
BOOL MoveItem(int nSelect, CListCtrl &FromListCtrl, CListCtrl &ToListCtrl)
{
	BOOL bResult = FALSE;
	if(nSelect>=0)
	{
		LV_ITEM lvToItem;
		CString szText;

		// Get the item (Name) clicked on:
		szText = FromListCtrl.GetItemText(nSelect, 0);
		// Add the same item (Name) to the other list:
		int i = ToListCtrl.GetItemCount();
		lvToItem.mask=LVIF_TEXT;
		lvToItem.iItem=i;
		lvToItem.iSubItem=0;
		lvToItem.pszText=szText.GetBuffer();
		int index = ToListCtrl.InsertItem(&lvToItem);
		// Get the sub-item (Resource type) of the item clicked on:
		szText = FromListCtrl.GetItemText(nSelect, 1);
		// Add the same sub-item (Resource type) to the other list:
		lvToItem.mask=LVIF_TEXT;
		lvToItem.iItem=index;
		lvToItem.iSubItem=1;
		lvToItem.pszText=szText.GetBuffer();
		ToListCtrl.SetItem(&lvToItem);
		// Delete the item from the list:
		FromListCtrl.DeleteItem(nSelect);
		bResult = TRUE;
	}

	return bResult;
}
Example #3
0
void COrderManagerDlg::DeleteOrder(CString strMenu)
{
	CListCtrl* OrderList = (CListCtrl*)this->GetDlgItem(IDC_LIST_ORDERMGR_ORDERS);
	
	for (int i = 0; i < OrderList->GetItemCount(); i++)
	{
		if (strMenu == OrderList->GetItemText(i, 0))
		{
			int nMenuCount = ::_ttoi(OrderList->GetItemText(i, 1));
			nMenuCount--;
			if (nMenuCount == 0)
			{
				OrderList->DeleteItem(i);
				UpdateTotalPrice();
				UpdateData(FALSE);
				break;
			}

			CString strMenuCount;
			strMenuCount.Format(_T("%d"), nMenuCount);
			OrderList->SetItemText(i, 1, strMenuCount);
			UpdateTotalPrice();
			UpdateData(FALSE);
			return;
		}
	}
}
void CLryEDBQryView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	
	
	CListCtrl  *ListCtrl = (CListCtrl  *)&GetListCtrl();
	CLryEDBQryDoc *pDoc = (CLryEDBQryDoc *)GetDocument();
	CLryEDBQryDoc::CRowObj *rowInfo;
	int i;
	switch(lHint)
	{
	case 0:
		FillList();			//填写表格
		break;
	case 1:
		try
		{
			i = pDoc->Rs->AbsolutePosition-1;
			ListCtrl->EnsureVisible(i,TRUE);		
		}
		catch(_com_error &e)
		{
			dump_com_error(e);
		}
		break;
	case 2:
		rowInfo = (CLryEDBQryDoc::CRowObj*)pHint;
		ListCtrl->DeleteItem(rowInfo->RowNO);
		ListCtrl->Update(rowInfo->RowNO);
		break;
	default:
		break;
	}	
	
}
void CModulePropertiesDlg::OnBnClickedSongRemove()
{
	ASSERT(m_iSelectedSong != -1);

	CListCtrl *pSongList = static_cast<CListCtrl*>(GetDlgItem(IDC_SONGLIST));
	CMainFrame *pMainFrame = static_cast<CMainFrame*>(GetParentFrame());
	unsigned Count = m_pDocument->GetTrackCount();
	CString TrackTitle;

	if (Count == 1)
		return; // Single track

	// Display warning first
	if (AfxMessageBox(IDS_SONG_DELETE, MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL)
		return;

	pSongList->DeleteItem(m_iSelectedSong);
	m_pDocument->RemoveTrack(m_iSelectedSong);
	m_pDocument->UpdateAllViews(NULL, UPDATE_TRACK);

	Count = m_pDocument->GetTrackCount();	// Get new track count

	// Redraw track list
	for (unsigned int i = 0; i < Count; ++i) {
		TrackTitle.Format(_T("#%02i %s"), i + 1, m_pDocument->GetTrackTitle(i).GetString());
		pSongList->SetItemText(i, 0, TrackTitle);
	}

	if (m_iSelectedSong == Count)
		SelectSong(m_iSelectedSong - 1);
	else
		SelectSong(m_iSelectedSong);
}
Example #6
0
// Parameters:	iOldRowCount is needed when a row may have been added or deleted, so that
//				current rowCount() would not be the right number to remove
void CWListRowItem::removeFromListCtrl(CListCtrl &clc, int iOldRowCount)
{
	int iRow = getRow(clc);
	int iRowCount = (iOldRowCount<1)?rowCount():iOldRowCount;

	for(int i=0; i< iRowCount; i++) // jdh dec 98 found bug here: was i<rowCount()
		clc.DeleteItem(iRow);
}
void CBrowser::RemoveBitmap ( int iIndex )
{
	CListCtrl*	pList = NULL;

	if ( ( pList = ( CListCtrl* ) GetDlgItem ( IDC_PREVIEW_LIST ) ) == NULL )
			return;

	pList->DeleteItem ( iIndex );
}
Example #8
0
void CLESampleGuiDlg::OnBnClickedStop()
{
	signed char s;
	// TODO: 在此添加控件通知处理程序代码
	// unregister callback
	BleUnregisterScanCallback();
	// stop scanning and check status
	BleEnableScan(false, 0x1);
	printf("Set scan disable\n");
	BleIsScanning(&s);
	printf("Is Scanning: %d\n", s);

	
	printf("Test Scan Callback OK");

	CListCtrl* lst = (CListCtrl*)pThis->GetDlgItem(IDC_DEVICE_LIST);
	int nIndex = lst->GetItemCount();
	for (int i=nIndex-1; i>=0; i--)
		lst->DeleteItem(i);
}
Example #9
0
void CHistoryDlg::OnButtonHistDelSel() 
{
	CListCtrl* pListCtrl = (CListCtrl*) GetDlgItem(IDC_LIST_HISTORY);

	int nCount = pListCtrl->GetItemCount();
	int nSelected = pListCtrl->GetSelectedCount();

	TCHAR szTT[64];
	sprintf(szTT, "Delete the %d selected items from the history file?", nSelected);

	CDeleteHistoryConfirmDlg Dlg;
	strcpy(Dlg.m_szText, szTT);

	if(Dlg.DoModal() == IDCANCEL)
		return;

	// Delete items from list; start with highest index and work down..
	int k;
	DWORD dwFilePos;

	CFile theHistoryFile;
	CFileException cfe;

	if(theHistoryFile.Open("HISTORY.DAT", CFile::modeWrite, &cfe) == FALSE)
	{
		TRACE("CHistoryDlg::BuildHistoryFileStats() - File Not Opened\n");
		CString strResourceBundleString;
		strResourceBundleString.LoadString(IDS_HISTORY_ERROR_OPENING_FILE);
		AfxMessageBox(LPCTSTR(strResourceBundleString), MB_ICONSTOP);
		return;
	}

	BOOL bDELETED = TRUE;

	try
	{
		for(k = nCount - 1; k >= 0; k--)
		{
			if(pListCtrl->GetItemState(k, LVIS_SELECTED) == LVIS_SELECTED)
			{
				dwFilePos = pListCtrl->GetItemData(k);
				theHistoryFile.Seek(dwFilePos, CFile::begin);
				theHistoryFile.Write(&bDELETED, sizeof(BOOL));
				pListCtrl->DeleteItem(k);
				++m_nDeleted;
			}
		}
	}
	catch(CFileException* e)
	{
		TCHAR szErrorMessage[1024];
		TCHAR szErrorInfo[768];
		e->GetErrorMessage(szErrorInfo, 760);
		sprintf(szErrorMessage, "Error Processing HISTORY.DAT!\r\n\r\n%s", szErrorInfo);
		e->Delete();
		AfxMessageBox(szErrorMessage, MB_ICONEXCLAMATION);
	}

	theHistoryFile.Close();

	UpdateButtons();
	
}
Example #10
0
File: ALERT.cpp Project: 12019/TT3
void ALERT::OnBnClickedButton1()    // Delete
{
	CListCtrl *pListctrl = (CListCtrl *)GetDlgItem(IDC_LIST1);
	pListctrl->DeleteItem(pListctrl->GetSelectionMark());
}
Example #11
0
File: TT3Dlg.cpp Project: 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;
}