/[H6]/ResultDialog.cpp
ViewVC logotype

Annotation of /ResultDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 31 - (hide annotations) (download)
Sun Sep 3 10:10:19 2006 UTC (17 years, 7 months ago) by torben
File size: 2534 byte(s)
Added author/developer comments
1 torben 31 /*
2     * Developed by Torben H. Nielsen
3     */
4 torben 5
5     #include "stdafx.h"
6     #include "h6-udlånssystem.h"
7     #include "ResultDialog.h"
8     #include ".\resultdialog.h"
9    
10 torben 14 #include "CommonStorage.h"
11     #include "Containers.h"
12     #include "ResultDetailsDialog.h"
13 torben 5
14 torben 14
15 torben 5 // ResultDialog dialog
16    
17     IMPLEMENT_DYNAMIC(ResultDialog, CDialog)
18     ResultDialog::ResultDialog(CWnd* pParent /*=NULL*/)
19     : CDialog(ResultDialog::IDD, pParent)
20     {
21     }
22    
23     ResultDialog::~ResultDialog()
24     {
25     }
26    
27     void ResultDialog::DoDataExchange(CDataExchange* pDX)
28     {
29     CDialog::DoDataExchange(pDX);
30     }
31    
32    
33     BEGIN_MESSAGE_MAP(ResultDialog, CDialog)
34 torben 14 ON_WM_SETFOCUS()
35     ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails)
36 torben 5 END_MESSAGE_MAP()
37    
38    
39     // ResultDialog message handlers
40    
41     void ResultDialog::OnOK()
42     {
43     // TODO: Add your specialized code here and/or call the base class
44    
45     //CDialog::OnOK();
46     }
47    
48     void ResultDialog::OnCancel()
49     {
50     // TODO: Add your specialized code here and/or call the base class
51    
52     //CDialog::OnCancel();
53     }
54 torben 14
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     EquipmentVector 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 torben 20 list->SetColumnWidth(1,100);
81     list->SetColumnWidth(2,100);
82 torben 14 }
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 torben 30
108 torben 14 if (sel == -1) {
109     MessageBox("You must select an item");
110 torben 30 } else {
111     ResultDetailsDialog resdialog;
112     resdialog.m_resultIndex = sel;
113    
114     resdialog.DoModal();
115 torben 14 }
116     }

  ViewVC Help
Powered by ViewVC 1.1.20