--- ResultDialog.cpp 2006/08/31 15:58:20 14 +++ ResultDialog.cpp 2006/09/26 14:16:56 58 @@ -1,5 +1,6 @@ -// ResultDialog.cpp : implementation file -// +/* + * Developed by Torben H. Nielsen + */ #include "stdafx.h" #include "h6-udlånssystem.h" @@ -32,6 +33,7 @@ BEGIN_MESSAGE_MAP(ResultDialog, CDialog) ON_WM_SETFOCUS() ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails) + ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnNMDblclkList) END_MESSAGE_MAP() @@ -61,7 +63,7 @@ void ResultDialog::LoadResults(void) { CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); - EquipmentVector result = CommonStorage::Instance()->getSearchResult(); + vector result = CommonStorage::Instance()->getSearchResult(); CString count; count.Format("Found %d items", result.size()); @@ -76,8 +78,8 @@ if (result.size() >0) { list->SetColumnWidth(0,LVSCW_AUTOSIZE); - list->SetColumnWidth(1,80); - list->SetColumnWidth(2,80); + list->SetColumnWidth(1,100); + list->SetColumnWidth(2,100); } } @@ -102,14 +104,34 @@ void ResultDialog::OnBnClickedDetails() { CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); - int sel = list->GetSelectionMark(); - if (sel == -1) { - MessageBox("You must select an item"); - return; + if (list->GetItemCount() > 0) { + + int sel = list->GetSelectionMark(); + CString barcode = list->GetItemText(sel,0); + + if (sel == -1) { + MessageBox("You must select an item"); + } else { + ResultDetailsDialog resdialog; + resdialog.m_barcode = barcode; + + resdialog.DoModal(); + } } +} - ResultDetailsDialog resdialog; - resdialog.m_resultIndex = sel; +void ResultDialog::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult) +{ + CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST); + if (list->GetItemCount() > 0) { + int sel = list->GetSelectionMark(); + CString barcode = list->GetItemText(sel,0); + + ResultDetailsDialog resdialog; + resdialog.m_barcode = barcode; + + resdialog.DoModal(); + } - resdialog.DoModal(); + *pResult = 0; }