Example #1
0
void CMainDialog::OnEditChange(UINT wNotifyCode, int wID, HWND hWndCtl)
{
	ATLTRACE(_T("OnEditChange %d,%d,%d\n"), wNotifyCode, wID, hWndCtl);
	CEdit wndEdit(hWndCtl);
	int endPos = wndEdit.GetLimitText();
	if (wndEdit.GetWindowTextLength() == endPos)
	{
		int startChar = 0, endChar = 0;
		wndEdit.GetSel(startChar, endChar);
		if (startChar == endPos)
		{
			ATLTRACE(_T("Goto next\n"), wNotifyCode, wID, hWndCtl);
			CWindow wndNext = GetNextDlgTabItem(hWndCtl);
			wndNext.SetFocus();
			CEdit wndNextEdit = wndNext;
			wndNextEdit.SetSel(0, -1);
		}
	}
}
Example #2
0
VOID
CGeneralPage::UpdateData()
{
	m_pDevice->UpdateStatus();
	m_pDevice->UpdateInfo();

	HCURSOR hWaitCursor = AtlLoadSysCursor(IDC_WAIT);
	HCURSOR hSavedCursor = SetCursor(hWaitCursor);

	m_edtDevName.SetWindowText(m_pDevice->GetName());
	CString strDevId = m_pDevice->GetStringId();

	CString strFmtDevId;
	m_edtDevId.SetWindowText(
		pCreateDelimitedDeviceId(
			strFmtDevId, 
			strDevId, 
			m_chConcealed));

	if (GENERIC_WRITE & m_pDevice->GetGrantedAccess()) {

		CString str;
		str.LoadString(IDS_WRITE_KEY_PRESENT);
		m_edtDevWriteKey.SetWindowText(str);

		CString strButton;
		strButton.LoadString(IDS_REMOVE_WRITE_KEY);
		m_butAddRemoveDevWriteKey.SetWindowText(strButton);

	} else {

		CString str;
		str.LoadString(IDS_WRITE_KEY_NONE);
		m_edtDevWriteKey.SetWindowText(str);

		CString strButton;
		strButton.LoadString(IDS_ADD_WRITE_KEY);
		m_butAddRemoveDevWriteKey.SetWindowText(strButton);
	}

	CString strStatus;

	pDeviceStatusString(strStatus, 
		m_pDevice->GetStatus(),
		m_pDevice->GetLastError());

	m_edtDevStatus.SetWindowText(strStatus);

	DWORD nUnitDevs = m_pDevice->GetUnitDeviceCount();
	if (0 == nUnitDevs) {

		CEdit wndEdit(GetDlgItem(IDC_UNITDEVICE_TYPE));
		CString str;
		str.LoadString(IDS_UNITDEVICE_NONE);
		wndEdit.SetWindowText(str);

	} else if (1 == nUnitDevs) {

		ndas::UnitDevice* pUnitDev = m_pDevice->GetUnitDevice(0);

		UpdateUnitDeviceData(pUnitDev);

		GenerateLogDevTree(pUnitDev);

		pUnitDev->Release();

	} else {

		//
		// TODO: Handle multiple unit devices
		//
		ndas::UnitDevice* pUnitDev = m_pDevice->GetUnitDevice(0);
		if (NULL != pUnitDev)
		{
			UpdateUnitDeviceData(pUnitDev);
			GenerateLogDevTree(pUnitDev);
			pUnitDev->Release();
		}

		for (DWORD i = 1; i < nUnitDevs; ++i)
		{
			ndas::UnitDevice* pUnitDev = m_pDevice->GetUnitDevice(i);
			if (NULL != pUnitDev)
			{
				pUnitDev->UpdateStatus();
				pUnitDev->UpdateInfo();
				pUnitDev->UpdateHostStats();
				pUnitDev->Release();
			}
		}

	}

	SetCursor(hSavedCursor);
}