/[H6]/ResultDialog.cpp
ViewVC logotype

Contents of /ResultDialog.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 51 - (show annotations) (download)
Thu Sep 7 19:24:10 2006 UTC (17 years, 7 months ago) by torben
File size: 2866 byte(s)
Enable double-click on the result dialog's list control
1 /*
2 * Developed by Torben H. Nielsen
3 */
4
5 #include "stdafx.h"
6 #include "h6-udlånssystem.h"
7 #include "ResultDialog.h"
8 #include ".\resultdialog.h"
9
10 #include "CommonStorage.h"
11 #include "Containers.h"
12 #include "ResultDetailsDialog.h"
13
14
15 // 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 ON_WM_SETFOCUS()
35 ON_BN_CLICKED(IDC_DETAILS, OnBnClickedDetails)
36 ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnNMDblclkList)
37 END_MESSAGE_MAP()
38
39
40 // ResultDialog message handlers
41
42 void ResultDialog::OnOK()
43 {
44 // TODO: Add your specialized code here and/or call the base class
45
46 //CDialog::OnOK();
47 }
48
49 void ResultDialog::OnCancel()
50 {
51 // TODO: Add your specialized code here and/or call the base class
52
53 //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 }

  ViewVC Help
Powered by ViewVC 1.1.20