/[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 54 by torben, Tue Sep 12 09:09:30 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            CString barcode = list->GetItemText(sel,0);
109    
110            if (sel == -1) {
111                    MessageBox("You must select an item");
112            } else {
113                    ResultDetailsDialog resdialog;
114                    resdialog.m_barcode = barcode;
115    
116                    resdialog.DoModal();
117            }
118    }
119    
120    void ResultDialog::OnNMDblclkList(NMHDR *pNMHDR, LRESULT *pResult)
121    {
122            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
123            int sel = list->GetSelectionMark();
124            CString barcode = list->GetItemText(sel,0);
125    
126            ResultDetailsDialog resdialog;
127            resdialog.m_barcode = barcode;
128    
129            resdialog.DoModal();
130    
131            *pResult = 0;
132    }

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

  ViewVC Help
Powered by ViewVC 1.1.20