Ejemplo n.º 1
0
void
CMainFrame::OnCmdResetDevice(DWORD dwSlotNo)
{
	ndas::DevicePtr pDevice;
	if (!ndas::FindDeviceBySlotNumber(pDevice, dwSlotNo))
	{
		return;
	}

	if (!pDevice->Enable(FALSE)) 
	{
		ErrorMessageBox(IDS_ERROR_RESET_DEVICE);
		return;
	}

	::SetCursor(AtlLoadSysCursor(IDC_WAIT));

	CSimpleWaitDlg().DoModal(m_hWnd, 2000);

	::SetCursor(AtlLoadSysCursor(IDC_ARROW));

	if (!pDevice->Enable(TRUE)) 
	{
		ErrorMessageBox(IDS_ERROR_RESET_DEVICE);
	}

	ndas::UpdateDeviceList();
}
LRESULT 
CNdasDevicePropGeneralPage::OnUpdateThreadCompleted(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	UINT i = static_cast<UINT>(lParam);

	ATLASSERT(i < RTL_NUMBER_OF(m_pUnitDevices));
	if (i >= RTL_NUMBER_OF(m_pUnitDevices))
	{
		m_hCursor = AtlLoadSysCursor(IDC_ARROW);
		::SetCursor(m_hCursor);
		pNotifyThreadCompleted();
		return 255;
	}

	ndas::UnitDevicePtr pUnitDevice = m_pUnitDevices[i];

	if (!pUnitDevice.get())
	{
		ATLASSERT(FALSE);
		m_hCursor = AtlLoadSysCursor(IDC_ARROW);
		::SetCursor(m_hCursor);
		pNotifyThreadCompleted();
		return TRUE;
	}

	m_unitDeviceUpdated[i] = true;

	if (m_curUnitDevice == i)
	{
		CString str;
		str.Format(_T("%d"), pUnitDevice->GetROHostCount());
		if (m_wndUnitDeviceROHosts.IsWindow())
		{
			m_wndUnitDeviceROHosts.SetWindowText(str);
		}

		str.Format(_T("%d"), pUnitDevice->GetRWHostCount());
		if (m_wndUnitDeviceRWHosts.IsWindow())
		{
			m_wndUnitDeviceRWHosts.SetWindowText(str);
		}
	}

	m_hCursor = AtlLoadSysCursor(IDC_ARROW);
	::SetCursor(m_hCursor);

	pNotifyThreadCompleted();

	return TRUE;
}
Ejemplo n.º 3
0
LRESULT CPreviewClientWindow::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
  m_curOp = 0;
  m_imageBuf = 0;
	m_update = sFALSE;

  m_crossCursor = AtlLoadSysCursor(IDC_CROSS);
  m_arrowCursor = AtlLoadSysCursor(IDC_ARROW);

  m_scrlX = m_scrlY = 0;
  m_scrlMaxX = m_scrlMaxY = 0;

  bHandled = FALSE;
  return 0;
}
Ejemplo n.º 4
0
void
CDeviceAdvancedPage::OnResetDevice(UINT uCode, int nCtrlID, HWND hwndCtrl)
{
	ATLASSERT(NULL != m_pDevice.get());

	CString strMessage = (LPCTSTR) IDS_CONFIRM_RESET_DEVICE;
	CString strTitle = (LPCTSTR) IDS_MAIN_TITLE;

	ATLASSERT(!strMessage.IsEmpty());
	ATLASSERT(!strTitle.IsEmpty());

	INT_PTR iResponse = MessageBox(
		strMessage, 
		strTitle, 
		MB_YESNO | MB_ICONQUESTION);

	if (IDYES != iResponse) 
	{
		return;
	}

	if (!m_pDevice->Enable(FALSE)) 
	{
		ErrorMessageBox(m_hWnd, IDS_ERROR_RESET_DEVICE);
		return;
	}

	::SetCursor(AtlLoadSysCursor(IDC_WAIT));

	CSimpleWaitDlg().DoModal(m_hWnd, 2000);

	::SetCursor(AtlLoadSysCursor(IDC_ARROW));

	if (!m_pDevice->Enable(TRUE)) 
	{
		ErrorMessageBox(m_hWnd, IDS_ERROR_RESET_DEVICE);
	}

	::PostMessage(GetParent(), IDCLOSE, 0, 0);
}
Ejemplo n.º 5
0
void
CDeviceGeneralPage::_UpdateUnitDeviceData(
	ndas::UnitDevicePtr pUnitDevice)
{
	pUnitDevice->UpdateStatus();
	pUnitDevice->UpdateInfo();

	m_hCursor = AtlLoadSysCursor(IDC_APPSTARTING);
	SetCursor(m_hCursor);

	int index = pUnitDevice->GetUnitNo();
	ATLASSERT(index < RTL_NUMBER_OF(m_hWorkerThread));
	m_hWorkerThread[index] = CreateWorkerThreadParam(ULongToPtr(index));
}
Ejemplo n.º 6
0
void
CDeviceHostStatPage::BeginRefreshHosts()
{
	m_wndRefreshLink.EnableWindow(FALSE);

	m_findHostsAnimate.ShowWindow(SW_SHOW);
	m_findHostsAnimate.Play(0,-1,-1);

	m_hostInfoDataArray.RemoveAll();
	m_wndListView.DeleteAllItems();

	m_hWorkerThread = CreateWorkerThread();
	if (NULL == m_hWorkerThread)
	{
		ATLTRACE("Worker Thread creation failed %d\n", ::GetLastError());
	}

	m_hCursor = AtlLoadSysCursor(IDC_APPSTARTING);
	SetCursor(m_hCursor);
}
void
CNdasDevicePropAdvancedPage::OnResetDevice(UINT uCode, int nCtrlID, HWND hwndCtrl)
{
	ATLASSERT(NULL != m_pDevice.get());

	int response = AtlTaskDialogEx(
		m_hWnd,
		IDS_MAIN_TITLE,
		IDS_CONFIRM_RESET_DEVICE,
		0U,
		TDCBF_YES_BUTTON | TDCBF_NO_BUTTON,
		TD_INFORMATION_ICON);

	if (IDYES != response) 
	{
		return;
	}

	if (!m_pDevice->Enable(FALSE)) 
	{
		ErrorMessageBox(m_hWnd, IDS_ERROR_RESET_DEVICE);
		return;
	}

	m_waiting = true;
	SetCursor(m_waitCursor);

	CSimpleWaitDlg().DoModal(m_hWnd, 2000);

	m_waiting = false;
	SetCursor(AtlLoadSysCursor(IDC_ARROW));

	if (!m_pDevice->Enable(TRUE)) 
	{
		ErrorMessageBox(m_hWnd, IDS_ERROR_RESET_DEVICE);
	}
	else
	{
		::PostMessage(GetParent(), WM_CLOSE, 0, 0);
	}
}
Ejemplo n.º 8
0
LRESULT
CDeviceHostStatPage::OnWorkDone(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	// Stop the animation
	m_findHostsAnimate.Stop();
	m_findHostsAnimate.ShowWindow(SW_HIDE);

	// Fill the list view

	CString strBuffer;
	int size = m_hostInfoDataArray.GetSize();
	for (int i = 0; i < size; ++i)
	{
		HostInfoData& data = m_hostInfoDataArray[i];
		const NDAS_HOST_INFO* pHostInfo = &data.HostInfo;
		ACCESS_MASK access = data.Access;

		(void) pAddressString(
			strBuffer,
			&pHostInfo->LPXAddrs,
			&pHostInfo->IPV4Addrs);

		CString rw(MAKEINTRESOURCE(IDS_HOST_RW));
		CString ro(MAKEINTRESOURCE(IDS_HOST_RO));
		m_wndListView.AddItem(i, 0, (access & GENERIC_WRITE) ? rw : ro);
		m_wndListView.SetItemText(i, 1, pHostInfo->szHostname);
		m_wndListView.SetItemText(i, 2, strBuffer);
	}

	AdjustHeaderWidth(m_wndListView);

	m_wndRefreshLink.EnableWindow(TRUE);

	m_hCursor = AtlLoadSysCursor(IDC_ARROW);
	SetCursor(m_hCursor);

	return TRUE;
}
void
CNdasDevicePropGeneralPage::_UpdateUnitDeviceData(
	ndas::UnitDevicePtr pUnitDevice)
{
	pUnitDevice->UpdateStatus();
	pUnitDevice->UpdateInfo();

	m_hCursor = AtlLoadSysCursor(IDC_APPSTARTING);
	SetCursor(m_hCursor);

	int index = pUnitDevice->GetUnitNo();

	UpdateThreadParam* param = new UpdateThreadParam();
	if (NULL == param)
	{
		return;
	}
	param->Instance = this;
	param->UnitIndex = index;

	m_ThreadCount++;

	BOOL success = QueueUserWorkItem(
		spUpdateThreadStart, 
		param, 
		WT_EXECUTEDEFAULT);

	if (!success)
	{
		delete param;

		ATLVERIFY(PostMessage(
			WM_THREADED_WORK_COMPLETED, 0, static_cast<LPARAM>(index)));

		return;
	}
}
LRESULT 
CNdasDevicePropGeneralPage::OnInitDialog(HWND hwndFocus, LPARAM lParam)
{
	ATLASSERT(m_pDevice != 0);

	m_hCursor = AtlLoadSysCursor(IDC_ARROW);

	m_wndDeviceName.Attach(GetDlgItem(IDC_DEVICE_NAME));
	m_wndDeviceId.Attach(GetDlgItem(IDC_DEVICE_ID));
	m_wndDeviceStatus.Attach(GetDlgItem(IDC_DEVICE_STATUS));
	m_wndDeviceWriteKey.Attach(GetDlgItem(IDC_DEVICE_WRITE_KEY));
	m_wndAddRemoveWriteKey.Attach(GetDlgItem(IDC_ADD_WRITE_KEY));

	m_wndUnitDeviceGroup.Attach(GetDlgItem(IDC_UNITDEVICE_GROUP));
	m_wndUnitDeviceIcon.Attach(GetDlgItem(IDC_UNITDEVICE_TYPE_ICON));
	m_wndUnitDeviceType.Attach(GetDlgItem(IDC_UNITDEVICE_TYPE));
	m_wndUnitDeviceStatus.Attach(GetDlgItem(IDC_UNITDEVICE_STATUS));
	m_wndUnitDeviceCapacity.Attach(GetDlgItem(IDC_UNITDEVICE_CAPACITY));
	m_wndUnitDeviceROHosts.Attach(GetDlgItem(IDC_UNITDEVICE_RO_HOSTS));
	m_wndUnitDeviceRWHosts.Attach(GetDlgItem(IDC_UNITDEVICE_RW_HOSTS));
	m_wndLogDeviceTree.Attach(GetDlgItem(IDC_LOGDEV_TREE));

	m_wndUnitDeviceList = GetDlgItem(IDC_UNITDEVICE_LIST);

	// Temporary edit control to get an effective password character
	{
		CEdit wndPassword;
		wndPassword.Create(m_hWnd, NULL, NULL, WS_CHILD | ES_PASSWORD);
		m_chConcealed = wndPassword.GetPasswordChar();
		wndPassword.DestroyWindow();
	}

	BOOL fSuccess = m_imageList.CreateFromImage(
		IDB_UNITDEVICES, 
		32, 
		1, 
		CLR_DEFAULT, 
		IMAGE_BITMAP,
		LR_CREATEDIBSECTION | LR_DEFAULTCOLOR | LR_DEFAULTSIZE);
	ATLASSERT(fSuccess && "Loading IDB_UNITDEVICES failed");

	_GrabUnitDeviceControls();

	// get the bold font
	CFontHandle boldFont;
	{
		CFontHandle dlgFont = GetFont();
		LOGFONT logFont;
		dlgFont.GetLogFont(&logFont);
		logFont.lfWeight = FW_BOLD;
		ATLVERIFY(boldFont.CreateFontIndirect(&logFont));
	}

	m_wndUnitDeviceType.SetFont(boldFont);

	// Cover up control, be sure to create this after FillUnitDeviceControls()
	{
		CRect rect;
		m_wndUnitDeviceGroup.GetClientRect(&rect);
		::MapWindowPoints(m_wndUnitDeviceGroup, HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2);
		::MapWindowPoints(HWND_DESKTOP, m_hWnd, reinterpret_cast<LPPOINT>(&rect), 2);
		rect.DeflateRect(10,50,10,10);
		m_wndNA.Create(m_hWnd, rect, NULL, WS_CHILD | SS_CENTER);
		CString str = MAKEINTRESOURCE(IDS_UNITDEVICE_NONE);
		ATLTRACE("NA: %ws\n", str);
		m_wndNA.SetWindowText(str);
		m_wndNA.SetFont(GetFont());
		m_wndNA.EnableWindow(FALSE);
	}
	{
		CRect rect;
		m_wndLogDeviceTree.GetWindowRect(&rect);
		::MapWindowPoints(HWND_DESKTOP, m_hWnd, reinterpret_cast<LPPOINT>(&rect), 2);
		// rect.DeflateRect(10,10,10,10);
		CString str = MAKEINTRESOURCE(IDS_LOGDEV_INFO_UNAVAILABLE);
		m_wndLogDeviceNA.Create(m_hWnd, rect, str, 
			WS_CHILD | WS_DISABLED | 
			BS_FLAT | BS_CENTER | BS_VCENTER | BS_TEXT);
		// m_wndLogDeviceNA.Create( Create(m_hWnd, rect, NULL, WS_CHILD | SS_CENTER, WS_EX_TRANSPARENT);
		ATLTRACE(_T("LogDevice N/A: %s"), str);
		// m_wndLogDeviceNA.SetWindowText(str);
		m_wndLogDeviceNA.SetFont(GetFont());
		m_wndLogDeviceNA.EnableWindow(FALSE);
	}

	_InitData();

	// Support F5 to refresh
	ACCEL accel = {0};
	accel.fVirt = FVIRTKEY;
	accel.key = VK_F5;
	accel.cmd = IDC_REFRESH_HOST;

	m_hAccel = ::CreateAcceleratorTable(&accel, 1);
	ATLASSERT(NULL != m_hAccel);

	return 0;
}
Ejemplo n.º 11
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);
}
Ejemplo n.º 12
0
	{
		static CFont2 font(Font::Big);
		return font;
	}
	else if (type == Font::BigHover)
	{
		static CFont2 font(Font::BigHover);
		return font;
	}

	static CFont2 font(Font::Standard);
	return font;
}

CCursor IW::Style::Cursor::Link = AtlLoadCursor(IDC_HANDLINK);
CCursor IW::Style::Cursor::Normal = AtlLoadSysCursor(IDC_ARROW);
CCursor IW::Style::Cursor::Move = AtlLoadCursor(IDC_MOVE);
CCursor IW::Style::Cursor::LeftRight = AtlLoadSysCursor(IDC_SIZEWE);
CCursor IW::Style::Cursor::HandUp = AtlLoadCursor(IDC_HANDUP);
CCursor IW::Style::Cursor::HandDown = AtlLoadCursor(IDC_HANDDOWN);
CCursor IW::Style::Cursor::Select = AtlLoadCursor(IDC_SELECT);
CCursor IW::Style::Cursor::Insert = AtlLoadCursor(IDC_INSERT);

CIcon IW::Style::Icon::ImageWalker = AtlLoadIcon(IDI_IMAGEWALKER);
CIcon IW::Style::Icon::Folder = AtlLoadIcon(IDI_FOLDER);
CIcon IW::Style::Icon::Default = AtlLoadIcon(IDI_DEFAULT);

DWORD IW::Style::Color::SlideShowWindow;
DWORD IW::Style::Color::SlideShowText;
DWORD IW::Style::Color::TaskText;
DWORD IW::Style::Color::TaskTextBold;