/[H6]/ResultDialog.cpp
ViewVC logotype

Diff of /ResultDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 5 by torben, Wed Aug 30 08:19:13 2006 UTC revision 14 by torben, Thu Aug 31 15:58:20 2006 UTC
# Line 6  Line 6 
6  #include "ResultDialog.h"  #include "ResultDialog.h"
7  #include ".\resultdialog.h"  #include ".\resultdialog.h"
8    
9    #include "CommonStorage.h"
10    #include "Containers.h"
11    #include "ResultDetailsDialog.h"
12    
13    
14  // ResultDialog dialog  // ResultDialog dialog
15    
# Line 26  void ResultDialog::DoDataExchange(CDataE Line 30  void ResultDialog::DoDataExchange(CDataE
30    
31    
32  BEGIN_MESSAGE_MAP(ResultDialog, CDialog)  BEGIN_MESSAGE_MAP(ResultDialog, CDialog)
33            ON_WM_SETFOCUS()
34            ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails)
35  END_MESSAGE_MAP()  END_MESSAGE_MAP()
36    
37    
# Line 44  void ResultDialog::OnCancel() Line 50  void ResultDialog::OnCancel()
50    
51          //CDialog::OnCancel();          //CDialog::OnCancel();
52  }  }
53    
54    void ResultDialog::OnSetFocus(CWnd* pOldWnd)
55    {
56            CDialog::OnSetFocus(pOldWnd);
57            LoadResults();
58    
59    }
60    
61    void ResultDialog::LoadResults(void)
62    {
63            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
64            EquipmentVector result = CommonStorage::Instance()->getSearchResult();
65    
66            CString count;
67            count.Format("Found %d items", result.size());
68            GetDlgItem(IDC_COUNTER)->SetWindowText(count);
69            list->DeleteAllItems();
70    
71            for (int i=0; i<result.size(); i++) {
72                    int nItem = list->InsertItem(i, result[i].barcode);
73                    list->SetItemText(nItem,1,result[i].name);
74                    list->SetItemText(nItem,2,result[i].status);
75            }
76    
77            if (result.size() >0) {
78                    list->SetColumnWidth(0,LVSCW_AUTOSIZE);
79                    list->SetColumnWidth(1,80);
80                    list->SetColumnWidth(2,80);
81            }
82    
83    }
84    
85    BOOL ResultDialog::OnInitDialog()
86    {
87            CDialog::OnInitDialog();
88    
89            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
90            list->SetExtendedStyle( LVS_EX_GRIDLINES  | LVS_EX_FULLROWSELECT );
91            list->InsertColumn(0,"Barcode");
92            list->InsertColumn(1,"Equipment");
93            list->InsertColumn(2,"Status");
94    
95            list->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER);
96            list->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER);
97            list->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER);
98    
99            return TRUE;
100    }
101    
102    void ResultDialog::OnBnClickedDetails()
103    {
104            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
105            int sel = list->GetSelectionMark();
106            if (sel == -1) {
107                    MessageBox("You must select an item");
108                    return;
109            }
110    
111            ResultDetailsDialog resdialog;
112            resdialog.m_resultIndex = sel;
113    
114            resdialog.DoModal();
115    }

Legend:
Removed from v.5  
changed lines
  Added in v.14

  ViewVC Help
Powered by ViewVC 1.1.20