/[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 51 by torben, Thu Sep 7 19:24:10 2006 UTC
# Line 1  Line 1 
1  // ResultDialog.cpp : implementation file  /*
2  //   * Developed by Torben H. Nielsen
3     */
4    
5  #include "stdafx.h"  #include "stdafx.h"
6  #include "h6-udlånssystem.h"  #include "h6-udlånssystem.h"
7  #include "ResultDialog.h"  #include "ResultDialog.h"
8  #include ".\resultdialog.h"  #include ".\resultdialog.h"
9    
10    #include "CommonStorage.h"
11    #include "Containers.h"
12    #include "ResultDetailsDialog.h"
13    
14    
15  // ResultDialog dialog  // ResultDialog dialog
16    
# Line 26  void ResultDialog::DoDataExchange(CDataE Line 31  void ResultDialog::DoDataExchange(CDataE
31    
32    
33  BEGIN_MESSAGE_MAP(ResultDialog, CDialog)  BEGIN_MESSAGE_MAP(ResultDialog, CDialog)
34            ON_WM_SETFOCUS()
35            ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails)
36            ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnNMDblclkList)
37  END_MESSAGE_MAP()  END_MESSAGE_MAP()
38    
39    
# Line 44  void ResultDialog::OnCancel() Line 52  void ResultDialog::OnCancel()
52    
53          //CDialog::OnCancel();          //CDialog::OnCancel();
54  }  }
55    
56    void ResultDialog::OnSetFocus(CWnd* pOldWnd)
57    {
58            CDialog::OnSetFocus(pOldWnd);
59            LoadResults();
60    
61    }
62    
63    void ResultDialog::LoadResults(void)
64    {
65            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
66            vector<Equipment> result = CommonStorage::Instance()->getSearchResult();
67    
68            CString count;
69            count.Format("Found %d items", result.size());
70            GetDlgItem(IDC_COUNTER)->SetWindowText(count);
71            list->DeleteAllItems();
72    
73            for (int i=0; i<result.size(); i++) {
74                    int nItem = list->InsertItem(i, result[i].barcode);
75                    list->SetItemText(nItem,1,result[i].name);
76                    list->SetItemText(nItem,2,result[i].status);
77            }
78    
79            if (result.size() >0) {
80                    list->SetColumnWidth(0,LVSCW_AUTOSIZE);
81                    list->SetColumnWidth(1,100);
82                    list->SetColumnWidth(2,100);
83            }
84    
85    }
86    
87    BOOL ResultDialog::OnInitDialog()
88    {
89            CDialog::OnInitDialog();
90    
91            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
92            list->SetExtendedStyle( LVS_EX_GRIDLINES  | LVS_EX_FULLROWSELECT );
93            list->InsertColumn(0,"Barcode");
94            list->InsertColumn(1,"Equipment");
95            list->InsertColumn(2,"Status");
96    
97            list->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER);
98            list->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER);
99            list->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER);
100    
101            return TRUE;
102    }
103    
104    void ResultDialog::OnBnClickedDetails()
105    {
106            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
107            int sel = list->GetSelectionMark();
108    
109            if (sel == -1) {
110                    MessageBox("You must select an item");
111            } else {
112                    ResultDetailsDialog resdialog;
113                    resdialog.m_resultIndex = sel;
114    
115                    resdialog.DoModal();
116            }
117    }
118    
119    void ResultDialog::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult)
120    {
121            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
122            int sel = list->GetSelectionMark();
123    
124            ResultDetailsDialog resdialog;
125            resdialog.m_resultIndex = sel;
126    
127            resdialog.DoModal();
128    
129            *pResult = 0;
130    }

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

  ViewVC Help
Powered by ViewVC 1.1.20