/[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 32 by torben, Sun Sep 3 15:31:13 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  END_MESSAGE_MAP()  END_MESSAGE_MAP()
37    
38    
# Line 44  void ResultDialog::OnCancel() Line 51  void ResultDialog::OnCancel()
51    
52          //CDialog::OnCancel();          //CDialog::OnCancel();
53  }  }
54    
55    void ResultDialog::OnSetFocus(CWnd* pOldWnd)
56    {
57            CDialog::OnSetFocus(pOldWnd);
58            LoadResults();
59    
60    }
61    
62    void ResultDialog::LoadResults(void)
63    {
64            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
65            vector<Equipment> result = CommonStorage::Instance()->getSearchResult();
66    
67            CString count;
68            count.Format("Found %d items", result.size());
69            GetDlgItem(IDC_COUNTER)->SetWindowText(count);
70            list->DeleteAllItems();
71    
72            for (int i=0; i<result.size(); i++) {
73                    int nItem = list->InsertItem(i, result[i].barcode);
74                    list->SetItemText(nItem,1,result[i].name);
75                    list->SetItemText(nItem,2,result[i].status);
76            }
77    
78            if (result.size() >0) {
79                    list->SetColumnWidth(0,LVSCW_AUTOSIZE);
80                    list->SetColumnWidth(1,100);
81                    list->SetColumnWidth(2,100);
82            }
83    
84    }
85    
86    BOOL ResultDialog::OnInitDialog()
87    {
88            CDialog::OnInitDialog();
89    
90            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
91            list->SetExtendedStyle( LVS_EX_GRIDLINES  | LVS_EX_FULLROWSELECT );
92            list->InsertColumn(0,"Barcode");
93            list->InsertColumn(1,"Equipment");
94            list->InsertColumn(2,"Status");
95    
96            list->SetColumnWidth(0,LVSCW_AUTOSIZE_USEHEADER);
97            list->SetColumnWidth(1,LVSCW_AUTOSIZE_USEHEADER);
98            list->SetColumnWidth(2,LVSCW_AUTOSIZE_USEHEADER);
99    
100            return TRUE;
101    }
102    
103    void ResultDialog::OnBnClickedDetails()
104    {
105            CListCtrl *list = (CListCtrl *) GetDlgItem(IDC_LIST);
106            int sel = list->GetSelectionMark();
107    
108            if (sel == -1) {
109                    MessageBox("You must select an item");
110            } else {
111                    ResultDetailsDialog resdialog;
112                    resdialog.m_resultIndex = sel;
113    
114                    resdialog.DoModal();
115            }
116    }

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

  ViewVC Help
Powered by ViewVC 1.1.20