Example #1
0
void CSelectDiskPage::UpdateControls()
{
	GetDlgItem(IDC_BTN_ADD).EnableWindow(m_wndListSingle.GetSelectedDiskObjectList().size() > 0);
	GetDlgItem(IDC_BTN_REMOVE).EnableWindow(m_wndListBind.GetSelectedDiskObjectList().size() > 0);
	GetDlgItem(IDC_BTN_REMOVE_ALL).EnableWindow( m_wndListBind.GetItemCount() > 0 );

	CEdit ctlEditCount;
	ctlEditCount.Attach(GetDlgItem(IDC_BIND_WIZ_COUNT));
	WTL::CString strDiskCount;
	strDiskCount.Format(_T("%d"), m_pWizData->m_nDiskCount);
	ctlEditCount.SetWindowText(strDiskCount);

	CEdit ctlEditSize;
	ctlEditSize.Attach(GetDlgItem(IDC_BIND_WIZ_SIZE));

	if ( m_wndListBind.GetDiskObjectList().size() == m_pWizData->m_nDiskCount )
	{
		WTL::CString strSize;
		pGetDiskSizeString(
			strSize, 
			m_pWizData->m_nBindType, 
			m_pWizData->m_nDiskCount, 
			m_wndListBind.GetSelectedDiskObjectList());

		ctlEditSize.SetWindowText(strSize);


		SetWizardButtons( PSWIZB_BACK | PSWIZB_NEXT );
	}
	else
	{
		ctlEditSize.SetWindowText(_T(""));
		SetWizardButtons( PSWIZB_BACK);
	}
}
Example #2
0
void CNBListViewCtrl::InitColumn()
{
	static COLUMN_INFO column_info[] = {	
		{ IDS_LISTVIEW_COL_NAME, 120 }, 
//		{ IDS_LISTVIEW_COL_ID, 200 },
		{ IDS_LISTVIEW_COL_SIZE, 100 } 
	};
	ATLASSERT( m_nColCount <= sizeof(column_info)/sizeof(column_info[0]) );

	UINT i, nColCount;
	// Clear all the column exist
	nColCount = CListViewCtrl::GetHeader().GetItemCount();
	for ( i=0; i < nColCount; i++ )
		CListViewCtrl::DeleteColumn(0);
	// Add new columns
	for ( i=0; i < m_nColCount; i++ )
	{
		WTL::CString strHeader;
		strHeader.LoadString( column_info[i].nColHeaderID );
		CListViewCtrl::InsertColumn(
			i, strHeader, LVCFMT_LEFT, 
			column_info[i].nWidth, -1 );
	}
	CRect lvrc;
	CListViewCtrl::GetClientRect(lvrc);
	CListViewCtrl::SetColumnWidth(1, 70);
	CListViewCtrl::SetColumnWidth(0, lvrc.Width() - 70);

}
Example #3
0
BOOL CALLBACK CheckCapacityForMirror(CNBUnitDevice *pUnitDevice, HWND hWnd, LPVOID lpContext)
{
	if(!lpContext)
		return TRUE;

	if(!pUnitDevice)
		return FALSE;

	CNBLogicalDevice *pLogicalDevice = (CNBLogicalDevice *)lpContext;

	for(UINT32 i = 0; i < pLogicalDevice->DevicesTotal(); i++)
	{
		if ((*pLogicalDevice)[i] && 
			(*pLogicalDevice)[i]->GetCapacityInByte() > pUnitDevice->GetCapacityInByte())
		{
			WTL::CString strMsg;
			strMsg.LoadString( IDS_SELECTMIRDLG_SMALLER_DISK );
			WTL::CString strTitle;
			strTitle.LoadString(IDS_APPLICATION);

			MessageBox(
				hWnd,
				strMsg,
				strTitle, 
				MB_OK | MB_ICONWARNING
				);

			return FALSE;
		}
	}

	return TRUE;
}
Example #4
0
void CRecoverDlg::Start()
{
	WTL::CString strBtnFace;

	//
	// Launch working thread
	//
	m_btnOK.EnableWindow(FALSE);

	strBtnFace.LoadString( IDS_RECOVER_BTN_CANCEL );
	m_btnCancel.SetWindowText( strBtnFace );
	m_btnCancel.EnableWindow(FALSE);

	m_bRunning = TRUE;

	HANDLE hThread;
	hThread = CreateThread(
		NULL,
		0,
		ThreadRecover,
		this,
		NULL, // run immediately
		NULL);

	if(!hThread)
	{
		WTL::CString strMsg = _T("");
		ShowErrorMessageBox(strMsg);

		strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE );
		m_btnCancel.SetWindowText( strBtnFace );
		m_bRunning = FALSE;
		m_bFinished = TRUE;
	}
}
Example #5
0
LRESULT CRecoverDlg::OnInitDialog(HWND /*hWndCtl*/, LPARAM /*lParam*/)
{
	ATLASSERT( m_pDevice.get() != NULL );
	CenterWindow();
	m_progBar.SubclassWindow( GetDlgItem(IDC_PROGBAR) );
	m_btnOK.Attach( GetDlgItem(IDOK) );
	m_btnCancel.Attach( GetDlgItem(IDCANCEL) );

	WTL :: CString strBtnFace;
	strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE );
	m_btnCancel.SetWindowText( strBtnFace );

	DoDataExchange(TRUE);
	m_strBindType.LoadString(m_id_bind_type);
	m_strDevice = m_pDevice->GetTitle();
	DoDataExchange(FALSE);

	WTL::CString strCaption;
	strCaption.LoadString(m_id_caption);
	SetWindowText(strCaption);

	SetPhaseText(IDS_RECOVERDLG_PHASE_READY);

	if(m_bForceStart)
		Start();

	return 0;
}
Example #6
0
WTL::CString CNBUnitDevice::GetTypeString()
{
	// AING_TO_DO : Set proper text
	WTL::CString strText;
	switch(GetType())
	{
	case NMT_INVALID:
	case NMT_SINGLE: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_MIRROR: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_SAFE_RAID1: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_AGGREGATE: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_RAID0: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_RAID1: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_RAID4: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_AOD: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_VDVD: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_CDROM: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_OPMEM: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	case NMT_FLASH: strText.LoadString(IDS_LOGDEV_TYPE_SINGLE_DISK); break;
	default:
		break;
	}

	return strText;
}
Example #7
0
//////////////////////////////////////////////////////////////////////////
// Page 2
//////////////////////////////////////////////////////////////////////////
LRESULT CDiskPropertyPage2::OnInitDialog(HWND /*hWndFocus*/, LPARAM /*lParam*/)
{
	WTL::CString strCaption;
	strCaption.LoadString(IDS_DISKPROPERTYPAGE_CAPTION);
	GetParentSheet()->SetWindowText(strCaption);

	CDiskObjectPtr disk = GetParentSheet()->GetDiskObject();

	m_listProperty.SubclassWindow( GetDlgItem(IDC_LIST_PROPERTY) );
	DWORD dwStyle = LVS_EX_FULLROWSELECT; 
	//| LVS_EX_GRIDLINES 
	//| LVS_EX_INFOTIP 
	m_listProperty.SetExtendedListViewStyle( dwStyle, dwStyle );

	WTL::CString strCol[2];
	strCol[0].LoadString( IDS_DISKPROPERTYPAGE_LIST_COL_NAME );
	strCol[1].LoadString( IDS_DISKPROPERTYPAGE_LIST_COL_VALUE );
	m_listProperty.InsertColumn( 0, strCol[0], LVCFMT_LEFT, 130, -1 );
	m_listProperty.InsertColumn( 1, strCol[1], LVCFMT_LEFT, 200, -1 );

	const CObjectUIHandler *phandler = CObjectUIHandler::GetUIHandler( disk );

	PropertyList propList = phandler->GetPropertyList( disk );
	PropertyList::iterator itr;
	for ( itr = propList.begin(); itr != propList.end(); ++itr )
	{
		m_listProperty.InsertItem( itr->strName, itr->strValue, itr->strToolTip );
	}

	return 0;
}
Example #8
0
void CMainFrame::ActivateUI(BOOL bActivate)
{
	m_wndToolBar.EnableWindow(bActivate);	

	HMENU hMenu = ATL::CWindow::GetMenu();
	if(!hMenu)
		return;

	UINT uEnableMenuItem = (bActivate) ? MF_ENABLED : MF_GRAYED;
	EnableMenuItem(hMenu, IDM_AGGR_REFRESH, uEnableMenuItem);
	EnableMenuItem(hMenu, IDM_AGGR_BIND, uEnableMenuItem);
	EnableMenuItem(hMenu, IDM_AGGR_UNBIND, uEnableMenuItem);
	EnableMenuItem(hMenu, IDM_AGGR_ADDMIRROR, uEnableMenuItem);
	EnableMenuItem(hMenu, IDM_AGGR_SYNCHRONIZE, uEnableMenuItem);
	EnableMenuItem(hMenu, IDM_AGGR_SINGLE, uEnableMenuItem);

	if(bActivate)
	{
		::SetWindowText(m_hWndStatusBar, _T(""));
	}
	else
	{
		WTL::CString strStatusText;
		strStatusText.LoadString(IDS_STATUS_REFRESH);
		::SetWindowText(m_hWndStatusBar, strStatusText);
	}
}
Example #9
0
//////////////////////////////////////////////////////////////////////////
// CNBBindListViewCtrl
//////////////////////////////////////////////////////////////////////////
void CNBBindListViewCtrl::InitColumn()
{
	static COLUMN_INFO column_info[] = {	
		//{ _T("Index"), 45 },
		{ IDS_LISTVIEW_COL_EMPTY, 20 },
		{ IDS_LISTVIEW_COL_NAME, 120 }, 
//		{ IDS_LISTVIEW_COL_ID, 200 },
		{ IDS_LISTVIEW_COL_SIZE, 100 } 
	};
	ATLASSERT( m_nColCount <= sizeof(column_info)/sizeof(column_info[0]) );

	UINT i, nColCount;
	// Clear all the column exist
	nColCount = CListViewCtrl::GetHeader().GetItemCount();
	for ( i=0; i < nColCount; i++ )
		CListViewCtrl::DeleteColumn(0);
	// Add new columns
	for ( i=0; i < m_nColCount; i++ )
	{
		WTL::CString strHeader;
		strHeader.LoadString( column_info[i].nColHeaderID );
		CListViewCtrl::InsertColumn(
			i, strHeader, LVCFMT_LEFT, 
			column_info[i].nWidth, -1 );
	}


	int viewWidth = 90;

	SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
	SetColumnWidth(2, 50);
	SetColumnWidth(1, viewWidth - GetColumnWidth(0) + GetColumnWidth(2));
}
Example #10
0
BOOL
CRegisterDeviceDialog::IsValidDeviceStringIdKey()
{
	// Transfer data from the controls to member variables
	DoDataExchange(TRUE);

	if (!(m_strDeviceIDs[0].GetLength() == 5 &&
		m_strDeviceIDs[1].GetLength() == 5 &&
		m_strDeviceIDs[2].GetLength() == 5 &&
		m_strDeviceIDs[3].GetLength() == 5 &&
		(m_strDeviceKey.GetLength() == 0 || m_strDeviceKey.GetLength() == 5)))
	{
		return FALSE;
	}

	WTL::CString strDeviceID;
	strDeviceID.Format(TEXT("%s%s%s%s"), 
		m_strDeviceIDs[0], m_strDeviceIDs[1], 
		m_strDeviceIDs[2], m_strDeviceIDs[3]);

	strDeviceID.MakeUpper();

	if (m_strDeviceKey.GetLength() > 0) {
		m_strDeviceKey.MakeUpper();
		return ::NdasValidateStringIdKeyW(strDeviceID, m_strDeviceKey);
	} else {
		return ::NdasValidateStringIdKeyW(strDeviceID, NULL);
	}
}
Example #11
0
WTL::CString CNBUnitDevice::GetStatusString()
{
	WTL::CString strText;

	DWORD status = GetStatus();

	if(NDASBIND_UNIT_DEVICE_STATUS_DISCONNECTED & status)
	{
		strText.LoadString(IDS_STATUS_NOT_CONNECTED);
	}
	else if(NDASBIND_UNIT_DEVICE_STATUS_MOUNTED & status)
	{
		strText.LoadString(IDS_STATUS_IN_USE);
	}
	else if(NDASBIND_UNIT_DEVICE_STATUS_NO_WRITE_KEY & status)
	{
		strText.LoadString(IDS_STATUS_READ_ONLY);
	}
	else
	{
		strText.LoadString(IDS_STATUS_FINE);
	}

	return strText;
}
Example #12
0
WTL::CString CEmptyDiskUIHandler::GetStringID(CDiskObjectPtr obj) const
{
	WTL::CString strDashedID;
	strDashedID.LoadString(IDS_UNIDEV_TYPE_DISK_EMPTY);

	return strDashedID;

}
Example #13
0
WTL::CString CNBNdasDevice::GetName()
{
	WTL::CString strText;

	strText.Format(_T("%s"), m_BaseInfo.szDeviceName);

	return strText;
}
Example #14
0
	CMenuIDToStringMap()
	{
		for ( int i=0; i < sizeof(IDToStrMap)/sizeof(IDToStrMap[0]); i++ )
		{
			WTL::CString strMenu;
			strMenu.LoadString( IDToStrMap[i].nStrID );
			insert( std::make_pair(IDToStrMap[i].nID, strMenu) );
		}
	}
Example #15
0
BOOL CRAID4DiskUIHandler::OnRecover(CDiskObjectPtr obj) const
{
	ATLASSERT( dynamic_cast<CRAID4DiskObject*>(obj.get()) != NULL );
	
	CRAID4DiskObjectPtr raid4Disk = 
		boost::dynamic_pointer_cast<CRAID4DiskObject>(obj);

	if(!raid4Disk->IsDirty())
	{
		WTL::CString strMsg;
		strMsg.LoadString(IDS_WARNING_NOT_NEED_RECOVER );
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox( 
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK | MB_ICONERROR
			);
		return TRUE;
	}

	std::list<CDiskObjectPtr>::iterator it;
	CUnitDiskObjectPtr pUnitDisk;

	it = raid4Disk->begin();
	INT32 iDirty;
	for(iDirty = raid4Disk->GetDirtyDisk(); iDirty > 0; iDirty--)
		it++;

	pUnitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*it);

	CRecoverDlg dlgRecover(FALSE, IDS_LOGDEV_TYPE_DISK_RAID4, IDS_RECOVERDLG_TASK_RECOVER);

	dlgRecover.SetMemberDevice(pUnitDisk);
	dlgRecover.DoModal();

	CNdasHIXChangeNotify HixChangeNotify(pGetNdasHostGuid());
	BOOL bResults = HixChangeNotify.Initialize();
	if(bResults)
	{
		NDAS_UNITDEVICE_ID unitDeviceId;

		for(it = raid4Disk->begin(); it != raid4Disk->end(); ++it)
		{
			pUnitDisk = boost::dynamic_pointer_cast<CUnitDiskObject>(*it);
			CopyMemory(unitDeviceId.DeviceId.Node,
				pUnitDisk->GetLocation()->GetUnitDiskLocation()->MACAddr,
				sizeof(unitDeviceId.DeviceId.Node));
			unitDeviceId.UnitNo = 
				pUnitDisk->GetLocation()->GetUnitDiskLocation()->UnitNumber;
			HixChangeNotify.Notify(unitDeviceId);
		}
	}

	return TRUE;
}
Example #16
0
LRESULT CNBBindListViewCtrl::OnGetDispInfo(LPNMHDR lParam)
{
	NMLVDISPINFO *pDispInfo = reinterpret_cast<NMLVDISPINFO*>(lParam);
	CDiskObjectPtr obj;
	const CObjectUIHandler *phandler;

	obj = m_mapObject[static_cast<UINT>(pDispInfo->item.lParam)];
	ATLASSERT( obj.get() != NULL );

	phandler = CObjectUIHandler::GetUIHandler( obj );
	
	switch ( pDispInfo->item.iSubItem )
	{
	case 0: // Index
		::_stprintf(
			pDispInfo->item.pszText,
			_T("%d"), 
			pDispInfo->item.iItem
			);
		break;
	case 1:	// Name
		::_tcsncpy( 
			pDispInfo->item.pszText,  
			obj->GetTitle(),
			pDispInfo->item.cchTextMax-1
			);
		break;
	case 2:	// ID
/*
		::_tcsncpy(
			pDispInfo->item.pszText,  
			phandler->GetStringID( obj ),
			pDispInfo->item.cchTextMax-1
			);
		break;
	case 3: // Size
*/
		{
			WTL::CString strSize;
			strSize.FormatMessage(
				IDS_LISTVIEW_SIZE_IN_GB,
				phandler->GetSizeInMB( obj ) / 1024,
				(phandler->GetSizeInMB( obj ) % 1024) / 10
				);
			::_tcsncpy(
				pDispInfo->item.pszText,  
				strSize,
				pDispInfo->item.cchTextMax-1
				);
		}		
	default:
		break;
	}
	pDispInfo->item.pszText[pDispInfo->item.cchTextMax-1] = '\0';
	return 0;
}
Example #17
0
BOOL CRecoverDlg::CallBackRecover(
	DWORD dwStatus,
	UINT32 Total,
	UINT32 Current)

{
	WTL::CString strBtnFace;

	switch(dwStatus)
	{
	case NDAS_RECOVER_STATUS_INITIALIZE:
		// activate stop button
		m_nBytesPerBit = Current;
		m_timeBegin = ::time( NULL );
		m_progBar.OnSetRange32(0, 0, Total);
		m_progBar.OnSetPos(0, 0, NULL);
		m_btnCancel.EnableWindow(TRUE);
		SetPhaseText(IDS_RECOVERDLG_PHASE_SYNC);
		break;
	case NDAS_RECOVER_STATUS_RUNNING:
		RefreshProgBar(Total, Current);
		// refresh time remaining, progress
		break;
	case NDAS_RECOVER_STATUS_FINALIZE:
		//		m_bFinished = TRUE;
		break;
	case NDAS_RECOVER_STATUS_FAILED:
		m_bRunning = FALSE;
		m_bFinished = FALSE;

		m_btnOK.EnableWindow(TRUE);
		strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE );
		m_btnCancel.SetWindowText(strBtnFace);
		m_btnCancel.EnableWindow(TRUE);
		SetPhaseText(IDS_RECOVERDLG_PHASE_READY);
		break;
	case NDAS_RECOVER_STATUS_COMPLETE:
		m_bRunning = FALSE;
		m_bFinished = TRUE;

		m_btnOK.EnableWindow(FALSE);
		strBtnFace.LoadString( IDS_RECOVER_BTN_CLOSE );
		m_btnCancel.SetWindowText(strBtnFace);

		SetPhaseText(IDS_RECOVERDLG_PHASE_DONE);
		break;
	}

	if(m_bStopRequest)
	{
		m_bStopRequest = FALSE;
		return FALSE;
	}

	return TRUE;
}
Example #18
0
LRESULT 
CRegisterDeviceDialog::
OnInitDialog(HWND hWnd, LPARAM lParam)
{
	DWORD nDeviceCount = static_cast<DWORD>(lParam);

	//
	// Attach controls
	//
	m_wndStringIDs[0] = CEdit(GetDlgItem(IDC_DEV_ID_1));
	m_wndStringIDs[1] = CEdit(GetDlgItem(IDC_DEV_ID_2));
	m_wndStringIDs[2] = CEdit(GetDlgItem(IDC_DEV_ID_3));
	m_wndStringIDs[3] = CEdit(GetDlgItem(IDC_DEV_ID_4));

	m_wndStringKey = GetDlgItem(IDC_DEV_KEY);
	m_wndName = GetDlgItem(IDC_DEV_NAME);
	m_wndRegister = GetDlgItem(IDC_REGISTER);

	//
	// chaining paste support
	//
	DWORD i(0);
	for (; i < 3; ++i) {
		m_wndPasteChains[i].Attach(m_hWnd, m_wndStringIDs[i], m_wndStringIDs[i+1]);
	}
	m_wndPasteChains[i].Attach(m_hWnd, m_wndStringIDs[i], NULL);

	//
	// limit the maximum text
	//
	m_wndStringIDs[0].SetLimitText(5);
	m_wndStringIDs[1].SetLimitText(5);
	m_wndStringIDs[2].SetLimitText(5);
	m_wndStringIDs[3].SetLimitText(5);
	m_wndStringKey.SetLimitText(5);
	m_wndName.SetLimitText(32);

	//
	// default device name
	//
	WTL::CString strNewDeviceName;

	strNewDeviceName.Format(IDS_NEW_DEVICE_NAME_TEMPLATE, nDeviceCount + 1);
	m_wndName.SetWindowText(strNewDeviceName);
	m_wndName.SetSelAll();
	m_wndName.SetFocus();

	//
	// Centering
	//
	CenterWindow();

	SetMsgHandled(FALSE);
	return 0;
}
Example #19
0
CTreeItem CNBTreeListView::SetDevice(CTreeItem tiParent, CNBDevice *pDevice)
{
	CTreeItem tiDevice;

	if(!pDevice)
	{
		// set empty device
		WTL::CString strText;
		strText.LoadString(IDS_UNIDEV_TYPE_DISK_EMPTY);
		tiDevice = GetTreeControl().InsertItem(
			strText,
			0, // IDI_FAIL
			0, // IDI_FAIL
			tiParent,
			TVI_LAST);

		tiDevice.SetData((DWORD_PTR)NULL);

		return tiDevice;
	}

	tiDevice = GetTreeControl().InsertItem(
		pDevice->GetName(),
		pDevice->GetIconIndex((UINT *)anIconIDs, sizeof(anIconIDs)/sizeof(anIconIDs[0])),
		pDevice->GetSelectIconIndex((UINT *)anIconIDs, sizeof(anIconIDs)/sizeof(anIconIDs[0])),
		tiParent,
		TVI_LAST);

	tiDevice.SetData((DWORD_PTR)pDevice);

	// ID
	int col = 1;

	SetSubItemText(tiDevice, col, pDevice->GetIDString());

	// Capacity
	col++;
	SetSubItemText(tiDevice, col, pDevice->GetCapacityString());

	// Status
	col++;
	SetSubItemText(tiDevice, col, pDevice->GetStatusString());

	// Type
	col++;
	SetSubItemText(tiDevice, col, pDevice->GetTypeString());

	// Fault Tolerance
	col++;
	SetSubItemText(tiDevice, col, pDevice->GetFaultToleranceString());

	return tiDevice;
}
Example #20
0
CListImpl::CListImpl(void):
 m_highlightstat(0)
,m_styleentry_height(80)
{
  // init font sample string
  WTL::CString text;
  text.LoadString(IDS_SUBTITLESTYLES);
  Strings::Split(text, L"|", m_samplevec);

  m_listtextrc.clear(); 
  m_listhittestrc.clear();
}
Example #21
0
void CMainFrame::OnUnBind(UINT /*wNotifyCode*/, int /*wID*/, HWND /*hwndCtl*/)
{
	ENTER_CRITICAL_SECTION(&m_csThreadRefreshStatus);

	CTreeItem itemSelected = m_view.GetSelectedItem();
	if ( itemSelected.IsNull() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		return;
	}

	CDiskObjectPtr obj, parent;
	obj = m_mapObject[m_view.GetItemData(itemSelected)];
	
	// Find topmost group composite of bind
	parent = obj->GetParent();
	while ( !parent->IsRoot() )
	{
		obj = parent;
		parent = obj->GetParent();
	}

	//
	// Check whether any disk is being accessed by other program/computer
	//
	if ( !obj->CanAccessExclusive() )
	{
		LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
		WTL::CString strMsg;
		strMsg.LoadString(IDS_FAIL_TO_ACCESS_EXCLUSIVELY);
		WTL::CString strTitle;
		strTitle.LoadString(IDS_APPLICATION);
		MessageBox( 
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return;
	}

	// Unbind disks
	CUnBindDlg dlgUnbind;

	dlgUnbind.SetDiskToUnbind(obj);
	if ( dlgUnbind.DoModal() == IDOK )
	{
		// AING : Cause dlgBind use ndasop.lib to bind disks, 
		// you can't ensure each disk information is stable after bind process.
		OnRefreshStatus(NULL, NULL, NULL);
	}

	LEAVE_CRITICAL_SECTION(&m_csThreadRefreshStatus);
}
Example #22
0
void CNBListViewCtrl::AddDiskObject(CNBUnitDevice *o)
{
	LVITEM lvItem = { 0 };
	WTL::CString strName = o->GetName();

	lvItem.mask		= LVIF_TEXT | LVIF_PARAM;
	lvItem.iItem	= GetItemCount();
	lvItem.pszText	= strName.LockBuffer();
	lvItem.lParam	= (LPARAM)o;
	CListViewCtrl::InsertItem( &lvItem );
	CListViewCtrl::SetItemText(lvItem.iItem, 1, o->GetCapacityString());
}
Example #23
0
BOOL CUnsupportedDiskUIHandler::OnClearDIB(CDiskObjectPtr obj) const
{
	ATLASSERT( dynamic_cast<CUnitDiskObject*>(obj.get()) != NULL);

	WTL::CString strWarning;
	strWarning.FormatMessage( 
			IDS_UIHANDLER_CLEARDIB_CONFIRM,
			obj->GetTitle()
			);
	WTL::CString strTitle;
	strTitle.LoadString(IDS_APPLICATION);
	if ( MessageBox(::GetFocus(), strWarning, strTitle, MB_YESNO | MB_ICONWARNING) != IDYES )
	{
		return TRUE;
	}
	CUnitDiskObjectPtr unitDisk = 
		boost::dynamic_pointer_cast<CUnitDiskObject>(obj);
	if ( !unitDisk->CanAccessExclusive() )
	{
		WTL::CString strMsg;
		strMsg.LoadString( IDS_FAIL_TO_ACCESS_EXCLUSIVELY );
		MessageBox( 
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK | MB_ICONWARNING
			);
		return TRUE;
	}
	try {
		unitDisk->Open( TRUE );
        unitDisk->Initialize( unitDisk );
		unitDisk->CommitDiskInfo();
		unitDisk->Close();
	}
	catch( CNDASException & )
	{
		unitDisk->Close();
		WTL::CString strMsg;
		strMsg.LoadString ( IDS_UIHANDLER_CLEARDIB_FAIL );
		MessageBox( 
			::GetFocus(),
			strMsg,
			strTitle,
			MB_OK | MB_ICONERROR
			);
		return TRUE;
	}
	WTL::CString strMsg;
	strMsg.LoadString( IDS_UIHANDLER_CLEARDIB_SUCCESS );
	return TRUE;
}
Example #24
0
void CNBBindListViewCtrl::OnPaint(HDC /*wParam*/)
{
	CRect rtCol, rtHeader, rtSubItem;
	CHeaderCtrl header = GetHeader();
	header.GetWindowRect( rtHeader );
	ScreenToClient( rtHeader );
	header.GetItemRect( 0, rtCol) ;
	rtCol.OffsetRect( rtHeader.TopLeft() );

	while ( !m_vtRowHeader.empty() )
	{
		CCustomStaticCtrl *pWnd = m_vtRowHeader.front();
		m_vtRowHeader.pop_front();
		pWnd->DestroyWindow();
		delete pWnd;
	}

	// For vertical scroll.
	if ( GetItemCount() > 0 )
	{
		GetSubItemRect(0, 0, LVIR_BOUNDS, rtSubItem);
	}
	else
	{
		rtSubItem.top = rtCol.bottom;
	}

	for ( UINT i=0; i < m_nMaxCount; i++ )
	{
		CCustomStaticCtrl *pWnd;
		CStatic staticCtrl;
		pWnd = new CCustomStaticCtrl;
		CRect rtItem;
		static int nHeight = 14;
		rtItem.left = rtCol.left;
		rtItem.right = rtCol.right-2;
		rtItem.top = rtSubItem.top + i * nHeight;
		rtItem.bottom = rtItem.top + nHeight-1;
		
		if ( rtItem.top < rtCol.bottom )
			continue;
		WTL::CString strTitle;
		strTitle.Format(_T("%d"), i);
		staticCtrl.Create( m_hWnd, rtItem, strTitle,
			WS_CHILD | SS_CENTER | WS_DISABLED);
		staticCtrl.ShowWindow( SW_SHOW );
		pWnd->SubclassWindow( staticCtrl.m_hWnd );
		m_vtRowHeader.push_back( pWnd );
	}
	DefWindowProc();
}
Example #25
0
WTL::CString CNBUnitDevice::GetIDString()
{
	WTL::CString strID = m_pDevice->m_BaseInfo.szDeviceStringId;
	WTL::CString strText;
	strID.Remove(_T('-'));

	strText += 
		strID.Mid(0, 5) + _T("-") +
		strID.Mid(5, 5) + _T("-") +
		strID.Mid(10, 5) + _T("-") + _T("*****");
	//		strID.Mid(0, 5) + _T("-") +

	return strText;
}
Example #26
0
BOOL CMainDlg::RawPrint(LPTSTR fileName)
{
    HANDLE p, f;
    p = f = INVALID_HANDLE_VALUE;
    LPBYTE buffer = NULL;
    DWORD err = ERROR_SUCCESS, w, size, r;
    WTL::CString ballon, message;
    CRPTray rwtray;

    WTL::CString printer = CMainDlg::GetRawPrinter();
    if (!printer.GetLength())
    {
        ::MessageBox(NULL, _(IDS_NOPRINTER), _T("RawPrinter"), MB_OK | MB_ICONERROR);
        return FALSE;
    }

    PRINTER_DEFAULTS defaults = { _T("RAW"), 0, PRINTER_ACCESS_USE };
    DOC_INFO_1 doc = { fileName, NULL, _T("RAW") };

    if ((f = ::CreateFile(fileName,
        GENERIC_READ, FILE_SHARE_READ,
        NULL, OPEN_EXISTING,
            FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE)
    {
        message.Format(_(IDS_ERROR_CREATEFILE), fileName, AtlGetErrorDescription(::GetLastError()));
        ::MessageBox(NULL, message, _T("RawPrinter"), MB_OK | MB_ICONERROR);
            goto end;
    }

    size = ::GetFileSize(f, NULL);
    buffer = (LPBYTE) new BYTE[size];
    ::ReadFile(f, buffer, size, &r, NULL);
    ::CloseHandle(f);

    LPTSTR fn = _tcsrchr(fileName, _T('\\'));
    ballon.Format(_(IDS_PRINTING), fn ? fn + 1: fileName, printer);
    rwtray.Ballon(ballon, 3000);

    CALL(::OpenPrinter(printer.GetBuffer(0), &p, &defaults), OpenPrinter);
    CALL(::StartDocPrinter(p, 1, (LPBYTE) &doc), StartDocPrinter);
    CALL(::StartPagePrinter(p), StartPagePrinter);
    CALL(::WritePrinter(p, buffer, size, &w), WritePrinter);
    CALL(::EndPagePrinter(p), EndPagePrinter);
    CALL(::EndDocPrinter(p), EndDocPrinter);

end:
    if (buffer) delete buffer;
    ClosePrinter(p);
    return TRUE;
}
Example #27
0
PropertyList CRAID4DiskUIHandler::GetPropertyList(CDiskObjectPtr obj) const
{
	PropertyList propList;
	PropertyListItem propItem;
	WTL::CString strBuffer;

	//propItem[0] = _T("Binding type");
	propItem.strName.LoadString( IDS_UIHANDLER_PROPERTY_NUM_BOUND_DISK );
	strBuffer.Format( _T("%d"), obj->GetDiskCountInBind() );
	propItem.strValue = strBuffer;
	propItem.strToolTip.LoadString( IDS_UIHANDLER_PROPERTY_NUM_BOUND_DISK_TOOLTIP );
	propList.push_back( propItem );
	return propList;	
}
Example #28
0
static 
HFONT 
pGetTitleFont()
{
	BOOL fSuccess = FALSE;
	static HFONT hTitleFont = NULL;
	if (NULL != hTitleFont) {
		return hTitleFont;
	}

	WTL::CString strFontName;
	WTL::CString strFontSize;
	fSuccess = strFontName.LoadString(IDS_BIG_BOLD_FONT_NAME);
	ATLASSERT(fSuccess);
	fSuccess = strFontSize.LoadString(IDS_BIG_BOLD_FONT_SIZE);
	ATLASSERT(fSuccess);

	NONCLIENTMETRICS ncm = {0};
	ncm.cbSize = sizeof(NONCLIENTMETRICS);
	fSuccess = ::SystemParametersInfo(
		SPI_GETNONCLIENTMETRICS, 
		sizeof(NONCLIENTMETRICS), 
		&ncm, 
		0);
	ATLASSERT(fSuccess);

	LOGFONT TitleLogFont = ncm.lfMessageFont;
	TitleLogFont.lfWeight = FW_BOLD;

	HRESULT hr = ::StringCchCopy(TitleLogFont.lfFaceName,
		(sizeof(TitleLogFont.lfFaceName)/sizeof(TitleLogFont.lfFaceName[0])),
		strFontName);

	ATLASSERT(SUCCEEDED(hr));

	INT TitleFontSize = ::StrToInt(strFontSize);
	if (TitleFontSize == 0) {
		TitleFontSize = 12;
	}

	HDC hdc = ::GetDC(NULL);
	TitleLogFont.lfHeight = 0 - 
		::GetDeviceCaps(hdc,LOGPIXELSY) * TitleFontSize / 72;

	hTitleFont = ::CreateFontIndirect(&TitleLogFont);
	::ReleaseDC(NULL, hdc);

	return hTitleFont;
}
Example #29
0
WTL::CString CNBUnitDevice::GetName()
{
	WTL::CString strText;

	if(1 != m_pDevice->UnitDevicesCount())
	{
		strText.Format(_T("%s:%d"), m_pDevice->m_BaseInfo.szDeviceName, m_BaseInfo.UnitNo);
	}
	else
	{
		strText.Format(_T("%s"), m_pDevice->m_BaseInfo.szDeviceName);
	}

	return strText;
}
Example #30
0
WTL::CString CObjectUIHandler::GetStringID(CDiskObjectPtr obj) const
{
	WTL::CString strID = obj->GetStringDeviceID();
	WTL::CString strDashedID;
	strID.Remove(_T('-'));

	strDashedID += 
		strID.Mid(0, 5) + _T("-") +
		strID.Mid(5, 5) + _T("-") +
		strID.Mid(10, 5) + _T("-") + _T("*****");
//		strID.Mid(0, 5) + _T("-") +

	return strDashedID;

}