Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

629 lines
18 KiB

  1. // wabtoolDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "wabtool.h"
  5. #include "wabobject.h"
  6. #include "wabtoolDlg.h"
  7. #include "DlgProp.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. CWAB * g_pWAB;
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAboutDlg dialog used for App About
  16. class CAboutDlg : public CDialog
  17. {
  18. public:
  19. CAboutDlg();
  20. // Dialog Data
  21. //{{AFX_DATA(CAboutDlg)
  22. enum { IDD = IDD_ABOUTBOX };
  23. //}}AFX_DATA
  24. // ClassWizard generated virtual function overrides
  25. //{{AFX_VIRTUAL(CAboutDlg)
  26. protected:
  27. virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
  28. //}}AFX_VIRTUAL
  29. // Implementation
  30. protected:
  31. //{{AFX_MSG(CAboutDlg)
  32. //}}AFX_MSG
  33. DECLARE_MESSAGE_MAP()
  34. };
  35. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  36. {
  37. //{{AFX_DATA_INIT(CAboutDlg)
  38. //}}AFX_DATA_INIT
  39. }
  40. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialog::DoDataExchange(pDX);
  43. //{{AFX_DATA_MAP(CAboutDlg)
  44. //}}AFX_DATA_MAP
  45. }
  46. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  47. //{{AFX_MSG_MAP(CAboutDlg)
  48. // No message handlers
  49. //}}AFX_MSG_MAP
  50. END_MESSAGE_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // CWabtoolDlg dialog
  53. CWabtoolDlg::CWabtoolDlg(CWnd* pParent /*=NULL*/)
  54. : CDialog(CWabtoolDlg::IDD, pParent)
  55. {
  56. //{{AFX_DATA_INIT(CWabtoolDlg)
  57. // NOTE: the ClassWizard will add member initialization here
  58. //}}AFX_DATA_INIT
  59. // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  60. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  61. }
  62. void CWabtoolDlg::DoDataExchange(CDataExchange* pDX)
  63. {
  64. CDialog::DoDataExchange(pDX);
  65. //{{AFX_DATA_MAP(CWabtoolDlg)
  66. // NOTE: the ClassWizard will add DDX and DDV calls here
  67. //}}AFX_DATA_MAP
  68. }
  69. BEGIN_MESSAGE_MAP(CWabtoolDlg, CDialog)
  70. //{{AFX_MSG_MAP(CWabtoolDlg)
  71. ON_WM_SYSCOMMAND()
  72. ON_WM_PAINT()
  73. ON_WM_QUERYDRAGICON()
  74. ON_NOTIFY(NM_DBLCLK, IDC_LIST, OnDblclkList)
  75. ON_BN_CLICKED(IDC_BUTTON_BROWSE, OnButtonBrowse)
  76. ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST, OnItemchangedList)
  77. ON_LBN_SELCHANGE(IDC_LIST_TAGS, OnSelchangeListTags)
  78. ON_BN_CLICKED(IDC_BUTTON_DETAILS, OnButtonDetails)
  79. ON_BN_CLICKED(IDC_BUTTON_NEW, OnButtonNew)
  80. ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
  81. ON_BN_CLICKED(IDC_BUTTON_ADDPROP, OnButtonAddprop)
  82. ON_BN_CLICKED(IDC_BUTTON_MODIFYPROP, OnButtonModifyprop)
  83. ON_LBN_DBLCLK(IDC_LIST_TAGS, OnDblclkListTags)
  84. ON_BN_CLICKED(IDC_BUTTON_REFRESH, OnButtonRefresh)
  85. ON_BN_CLICKED(IDC_BUTTON_WABVIEW, OnButtonWabview)
  86. //}}AFX_MSG_MAP
  87. END_MESSAGE_MAP()
  88. /////////////////////////////////////////////////////////////////////////////
  89. // CWabtoolDlg message handlers
  90. BOOL CWabtoolDlg::OnInitDialog()
  91. {
  92. CDialog::OnInitDialog();
  93. // Add "About..." menu item to system menu.
  94. // IDM_ABOUTBOX must be in the system command range.
  95. ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  96. ASSERT(IDM_ABOUTBOX < 0xF000);
  97. CMenu* pSysMenu = GetSystemMenu(FALSE);
  98. if (pSysMenu != NULL)
  99. {
  100. CString strAboutMenu;
  101. strAboutMenu.LoadString(IDS_ABOUTBOX);
  102. if (!strAboutMenu.IsEmpty())
  103. {
  104. pSysMenu->AppendMenu(MF_SEPARATOR);
  105. pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  106. }
  107. }
  108. // Set the icon for this dialog. The framework does this automatically
  109. // when the application's main window is not a dialog
  110. SetIcon(m_hIcon, TRUE); // Set big icon
  111. SetIcon(m_hIcon, FALSE); // Set small icon
  112. // TODO: Add extra initialization here
  113. InitCommonControls();
  114. LoadContents(TRUE);
  115. return TRUE; // return TRUE unless you set the focus to a control
  116. }
  117. void CWabtoolDlg::OnSysCommand(UINT nID, LPARAM lParam)
  118. {
  119. if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  120. {
  121. CAboutDlg dlgAbout;
  122. dlgAbout.DoModal();
  123. }
  124. else
  125. {
  126. CDialog::OnSysCommand(nID, lParam);
  127. }
  128. }
  129. // If you add a minimize button to your dialog, you will need the code below
  130. // to draw the icon. For MFC applications using the document/view model,
  131. // this is automatically done for you by the framework.
  132. void CWabtoolDlg::OnPaint()
  133. {
  134. if (IsIconic())
  135. {
  136. CPaintDC dc(this); // device context for painting
  137. SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  138. // Center icon in client rectangle
  139. int cxIcon = GetSystemMetrics(SM_CXICON);
  140. int cyIcon = GetSystemMetrics(SM_CYICON);
  141. CRect rect;
  142. GetClientRect(&rect);
  143. int x = (rect.Width() - cxIcon + 1) / 2;
  144. int y = (rect.Height() - cyIcon + 1) / 2;
  145. // Draw the icon
  146. dc.DrawIcon(x, y, m_hIcon);
  147. }
  148. else
  149. {
  150. CDialog::OnPaint();
  151. }
  152. }
  153. // The system calls this to obtain the cursor to display while the user drags
  154. // the minimized window.
  155. HCURSOR CWabtoolDlg::OnQueryDragIcon()
  156. {
  157. return (HCURSOR) m_hIcon;
  158. }
  159. BOOL CWabtoolDlg::DestroyWindow()
  160. {
  161. // TODO: Add your specialized code here and/or call the base class
  162. ClearCurrentWAB(TRUE);
  163. return CDialog::DestroyWindow();
  164. }
  165. //
  166. // Double-clicking the contents list view shows Details on the
  167. // selected entries
  168. //
  169. void CWabtoolDlg::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
  170. {
  171. g_pWAB->ShowSelectedItemDetails(m_hWnd);
  172. *pResult = 0;
  173. }
  174. //
  175. // Clicking the browse button lets the user select a new WAB file
  176. // to inspect
  177. //
  178. void CWabtoolDlg::OnButtonBrowse()
  179. {
  180. char szFilters[]="WAB Files (*.wab)|*.wab|All Files (*.*)|*.*||";
  181. CFileDialog CFileDlg (TRUE, "wab", "*.wab",
  182. OFN_FILEMUSTEXIST, szFilters, this);
  183. if(CFileDlg.DoModal() == IDOK)
  184. {
  185. delete m_pszFileName;
  186. m_pszFileName = new CString(CFileDlg.GetPathName());
  187. ClearCurrentWAB(TRUE);
  188. LoadContents(TRUE);
  189. }
  190. }
  191. // Loads the WAB contents into the list view
  192. //
  193. // bLoadNew is true if we are loading a new file
  194. //
  195. void CWabtoolDlg::LoadContents(BOOL bLoadNew)
  196. {
  197. CListCtrl * pListView = (CListCtrl *) GetDlgItem(IDC_LIST);
  198. if(bLoadNew)
  199. g_pWAB = new CWAB(m_pszFileName);
  200. g_pWAB->LoadWABContents(pListView);
  201. CStatic * pFileName = (CStatic *) GetDlgItem(IDC_STATIC_FILENAME);
  202. pFileName->SetWindowText((LPTSTR) (LPCTSTR) *m_pszFileName);
  203. TCHAR sz[256];
  204. wsprintf(sz, "%d entries", pListView->GetItemCount());
  205. CStatic * pCount = (CStatic *) GetDlgItem(IDC_STATIC_NUMENTRIES);
  206. pCount->SetWindowText(sz);
  207. // select the first item in the list view
  208. pListView->SetItem( 0, 0,
  209. LVIF_STATE,NULL,
  210. 0,
  211. LVNI_SELECTED | LVNI_FOCUSED,
  212. LVNI_SELECTED | LVNI_FOCUSED,
  213. NULL);
  214. }
  215. //
  216. // Clear out the currently loaded WAB
  217. //
  218. void CWabtoolDlg::ClearCurrentWAB(BOOL bLoadNew)
  219. {
  220. CListCtrl * pListView = (CListCtrl *) GetDlgItem(IDC_LIST);
  221. g_pWAB->ClearWABLVContents(pListView);
  222. if(bLoadNew) // we'll be loading a new address book so lose this object
  223. delete g_pWAB;
  224. }
  225. void CWabtoolDlg::OnItemchangedList(NMHDR* pNMHDR, LRESULT* pResult)
  226. {
  227. NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
  228. CListCtrl * pListView = (CListCtrl *) GetDlgItem(IDC_LIST);
  229. static int oldItem = -1;
  230. int newItem = pListView->GetNextItem(-1, LVNI_SELECTED);
  231. if(newItem != oldItem && newItem != -1)
  232. {
  233. g_pWAB->SetSelection(pListView);
  234. g_pWAB->GetSelectedItemPropArray();
  235. TCHAR sz[MAX_PATH];
  236. g_pWAB->GetStringPropVal(m_hWnd, PR_DISPLAY_NAME, sz, sizeof(sz));
  237. ((CStatic *)GetDlgItem(IDC_STATIC_SELECTED))->SetWindowText(sz);
  238. UpdatePropTagData();
  239. OnSelchangeListTags();
  240. oldItem = newItem;
  241. }
  242. *pResult = 0;
  243. }
  244. void CWabtoolDlg::UpdatePropTagData()
  245. {
  246. g_pWAB->LoadPropTags((CListBox *) GetDlgItem(IDC_LIST_TAGS));
  247. }
  248. void CWabtoolDlg::OnSelchangeListTags()
  249. {
  250. TCHAR sz[64];
  251. CListBox * pList = (CListBox *) GetDlgItem(IDC_LIST_TAGS);
  252. ULONG ulPropTag = (ULONG) pList->GetItemData(pList->GetCurSel());
  253. pList->GetText(pList->GetCurSel(), sz);
  254. SetPropTagString(sz);
  255. SetPropTypeString(ulPropTag);
  256. SetPropNameString(ulPropTag);
  257. SetPropDataString(ulPropTag);
  258. }
  259. LPTSTR PropTypeString(ULONG ulPropType) {
  260. switch (ulPropType) {
  261. case PT_UNSPECIFIED:
  262. return("PT_UNSPECIFIED");
  263. case PT_NULL:
  264. return("PT_NULL ");
  265. case PT_I2:
  266. return("PT_I2 ");
  267. case PT_LONG:
  268. return("PT_LONG ");
  269. case PT_R4:
  270. return("PT_R4 ");
  271. case PT_DOUBLE:
  272. return("PT_DOUBLE ");
  273. case PT_CURRENCY:
  274. return("PT_CURRENCY ");
  275. case PT_APPTIME:
  276. return("PT_APPTIME ");
  277. case PT_ERROR:
  278. return("PT_ERROR ");
  279. case PT_BOOLEAN:
  280. return("PT_BOOLEAN ");
  281. case PT_OBJECT:
  282. return("PT_OBJECT ");
  283. case PT_I8:
  284. return("PT_I8 ");
  285. case PT_STRING8:
  286. return("PT_STRING8 ");
  287. case PT_UNICODE:
  288. return("PT_UNICODE ");
  289. case PT_SYSTIME:
  290. return("PT_SYSTIME ");
  291. case PT_CLSID:
  292. return("PT_CLSID ");
  293. case PT_BINARY:
  294. return("PT_BINARY ");
  295. case PT_MV_I2:
  296. return("PT_MV_I2 ");
  297. case PT_MV_LONG:
  298. return("PT_MV_LONG ");
  299. case PT_MV_R4:
  300. return("PT_MV_R4 ");
  301. case PT_MV_DOUBLE:
  302. return("PT_MV_DOUBLE ");
  303. case PT_MV_CURRENCY:
  304. return("PT_MV_CURRENCY");
  305. case PT_MV_APPTIME:
  306. return("PT_MV_APPTIME ");
  307. case PT_MV_SYSTIME:
  308. return("PT_MV_SYSTIME ");
  309. case PT_MV_STRING8:
  310. return("PT_MV_STRING8 ");
  311. case PT_MV_BINARY:
  312. return("PT_MV_BINARY ");
  313. case PT_MV_UNICODE:
  314. return("PT_MV_UNICODE ");
  315. case PT_MV_CLSID:
  316. return("PT_MV_CLSID ");
  317. case PT_MV_I8:
  318. return("PT_MV_I8 ");
  319. default:
  320. return(" <unknown> ");
  321. }
  322. }
  323. void CWabtoolDlg::SetPropTypeString(ULONG ulPropTag)
  324. {
  325. ((CStatic *) GetDlgItem(IDC_STATIC_PROPTYPE))->SetWindowText(PropTypeString(PROP_TYPE(ulPropTag)));
  326. }
  327. void CWabtoolDlg::SetPropTagString(LPTSTR lpTag)
  328. {
  329. ((CStatic *) GetDlgItem(IDC_STATIC_PROPTAG))->SetWindowText(lpTag);
  330. }
  331. void CWabtoolDlg::OnButtonDetails()
  332. {
  333. g_pWAB->ShowSelectedItemDetails(m_hWnd);
  334. // refresh the list view
  335. OnButtonRefresh();
  336. }
  337. #define RETURN_PROP_CASE(pt) case PROP_ID(pt): return(#pt)
  338. /***************************************************************************
  339. Name : PropTagName
  340. Purpose : Associate a name with a property tag
  341. Parameters: ulPropTag = property tag
  342. Returns : none
  343. Comment : Add new Property ID's as they become known
  344. ***************************************************************************/
  345. LPTSTR PropTagName(ULONG ulPropTag) {
  346. static TCHAR szPropTag[35]; // see string on default
  347. switch (PROP_ID(ulPropTag)) {
  348. RETURN_PROP_CASE(PR_7BIT_DISPLAY_NAME);
  349. RETURN_PROP_CASE(PR_ACCOUNT);
  350. RETURN_PROP_CASE(PR_ADDRTYPE);
  351. RETURN_PROP_CASE(PR_ALTERNATE_RECIPIENT);
  352. RETURN_PROP_CASE(PR_ASSISTANT);
  353. RETURN_PROP_CASE(PR_ASSISTANT_TELEPHONE_NUMBER);
  354. RETURN_PROP_CASE(PR_BIRTHDAY);
  355. RETURN_PROP_CASE(PR_BUSINESS_FAX_NUMBER);
  356. RETURN_PROP_CASE(PR_BUSINESS_HOME_PAGE);
  357. RETURN_PROP_CASE(PR_BUSINESS_TELEPHONE_NUMBER);
  358. RETURN_PROP_CASE(PR_BUSINESS2_TELEPHONE_NUMBER);
  359. RETURN_PROP_CASE(PR_CALLBACK_TELEPHONE_NUMBER);
  360. RETURN_PROP_CASE(PR_CAR_TELEPHONE_NUMBER);
  361. RETURN_PROP_CASE(PR_CELLULAR_TELEPHONE_NUMBER);
  362. RETURN_PROP_CASE(PR_CHILDRENS_NAMES);
  363. RETURN_PROP_CASE(PR_COMMENT);
  364. RETURN_PROP_CASE(PR_COMPANY_MAIN_PHONE_NUMBER);
  365. RETURN_PROP_CASE(PR_COMPANY_NAME);
  366. RETURN_PROP_CASE(PR_COMPUTER_NETWORK_NAME);
  367. RETURN_PROP_CASE(PR_CONTACT_ADDRTYPES);
  368. RETURN_PROP_CASE(PR_CONTACT_DEFAULT_ADDRESS_INDEX);
  369. RETURN_PROP_CASE(PR_CONTACT_EMAIL_ADDRESSES);
  370. RETURN_PROP_CASE(PR_CONTACT_ENTRYIDS);
  371. RETURN_PROP_CASE(PR_CONTACT_VERSION);
  372. RETURN_PROP_CASE(PR_CONVERSION_PROHIBITED);
  373. RETURN_PROP_CASE(PR_COUNTRY);
  374. RETURN_PROP_CASE(PR_CUSTOMER_ID);
  375. RETURN_PROP_CASE(PR_DEPARTMENT_NAME);
  376. RETURN_PROP_CASE(PR_DISCLOSE_RECIPIENTS);
  377. RETURN_PROP_CASE(PR_DISPLAY_NAME);
  378. RETURN_PROP_CASE(PR_DISPLAY_NAME_PREFIX);
  379. RETURN_PROP_CASE(PR_EMAIL_ADDRESS);
  380. RETURN_PROP_CASE(PR_ENTRYID);
  381. RETURN_PROP_CASE(PR_FTP_SITE);
  382. RETURN_PROP_CASE(PR_GENDER);
  383. RETURN_PROP_CASE(PR_GENERATION);
  384. RETURN_PROP_CASE(PR_GIVEN_NAME);
  385. RETURN_PROP_CASE(PR_GOVERNMENT_ID_NUMBER);
  386. RETURN_PROP_CASE(PR_HOBBIES);
  387. RETURN_PROP_CASE(PR_HOME_ADDRESS_CITY);
  388. RETURN_PROP_CASE(PR_HOME_ADDRESS_COUNTRY);
  389. RETURN_PROP_CASE(PR_HOME_ADDRESS_POST_OFFICE_BOX);
  390. RETURN_PROP_CASE(PR_HOME_ADDRESS_POSTAL_CODE);
  391. RETURN_PROP_CASE(PR_HOME_ADDRESS_STATE_OR_PROVINCE);
  392. RETURN_PROP_CASE(PR_HOME_ADDRESS_STREET);
  393. RETURN_PROP_CASE(PR_HOME_FAX_NUMBER);
  394. RETURN_PROP_CASE(PR_HOME_TELEPHONE_NUMBER);
  395. RETURN_PROP_CASE(PR_HOME2_TELEPHONE_NUMBER);
  396. RETURN_PROP_CASE(PR_INITIALS);
  397. RETURN_PROP_CASE(PR_ISDN_NUMBER);
  398. RETURN_PROP_CASE(PR_KEYWORD);
  399. RETURN_PROP_CASE(PR_LANGUAGE);
  400. RETURN_PROP_CASE(PR_LOCALITY);
  401. RETURN_PROP_CASE(PR_LOCATION);
  402. RETURN_PROP_CASE(PR_MAIL_PERMISSION);
  403. RETURN_PROP_CASE(PR_MANAGER_NAME);
  404. RETURN_PROP_CASE(PR_MHS_COMMON_NAME);
  405. RETURN_PROP_CASE(PR_MIDDLE_NAME);
  406. RETURN_PROP_CASE(PR_NICKNAME);
  407. RETURN_PROP_CASE(PR_OBJECT_TYPE);
  408. RETURN_PROP_CASE(PR_OFFICE_LOCATION);
  409. RETURN_PROP_CASE(PR_ORGANIZATIONAL_ID_NUMBER);
  410. RETURN_PROP_CASE(PR_ORIGINAL_DISPLAY_NAME);
  411. RETURN_PROP_CASE(PR_ORIGINAL_ENTRYID);
  412. RETURN_PROP_CASE(PR_ORIGINAL_SEARCH_KEY);
  413. RETURN_PROP_CASE(PR_OTHER_ADDRESS_CITY);
  414. RETURN_PROP_CASE(PR_OTHER_ADDRESS_COUNTRY);
  415. RETURN_PROP_CASE(PR_OTHER_ADDRESS_POST_OFFICE_BOX);
  416. RETURN_PROP_CASE(PR_OTHER_ADDRESS_POSTAL_CODE);
  417. RETURN_PROP_CASE(PR_OTHER_ADDRESS_STATE_OR_PROVINCE);
  418. RETURN_PROP_CASE(PR_OTHER_ADDRESS_STREET);
  419. RETURN_PROP_CASE(PR_OTHER_TELEPHONE_NUMBER);
  420. RETURN_PROP_CASE(PR_PAGER_TELEPHONE_NUMBER);
  421. RETURN_PROP_CASE(PR_PERSONAL_HOME_PAGE);
  422. RETURN_PROP_CASE(PR_POST_OFFICE_BOX);
  423. RETURN_PROP_CASE(PR_POSTAL_ADDRESS);
  424. RETURN_PROP_CASE(PR_POSTAL_CODE);
  425. RETURN_PROP_CASE(PR_PREFERRED_BY_NAME);
  426. RETURN_PROP_CASE(PR_PRIMARY_FAX_NUMBER);
  427. RETURN_PROP_CASE(PR_PRIMARY_TELEPHONE_NUMBER);
  428. RETURN_PROP_CASE(PR_PROFESSION);
  429. RETURN_PROP_CASE(PR_RADIO_TELEPHONE_NUMBER);
  430. RETURN_PROP_CASE(PR_SEND_INTERNET_ENCODING);
  431. RETURN_PROP_CASE(PR_SEND_RICH_INFO);
  432. RETURN_PROP_CASE(PR_SPOUSE_NAME);
  433. RETURN_PROP_CASE(PR_STATE_OR_PROVINCE);
  434. RETURN_PROP_CASE(PR_STREET_ADDRESS);
  435. RETURN_PROP_CASE(PR_SURNAME);
  436. RETURN_PROP_CASE(PR_TELEX_NUMBER);
  437. RETURN_PROP_CASE(PR_TITLE);
  438. RETURN_PROP_CASE(PR_TRANSMITABLE_DISPLAY_NAME);
  439. RETURN_PROP_CASE(PR_TTYTDD_PHONE_NUMBER);
  440. RETURN_PROP_CASE(PR_USER_CERTIFICATE);
  441. RETURN_PROP_CASE(PR_USER_X509_CERTIFICATE);
  442. RETURN_PROP_CASE(PR_WEDDING_ANNIVERSARY);
  443. RETURN_PROP_CASE(PR_SEARCH_KEY);
  444. default:
  445. wsprintf(szPropTag, "Unknown property tag 0x%x", PROP_ID(ulPropTag));
  446. return(szPropTag);
  447. }
  448. }
  449. void CWabtoolDlg::SetPropNameString(ULONG ulPropTag)
  450. {
  451. LPTSTR lp = PropTagName(ulPropTag);
  452. CStatic * pType = (CStatic *) GetDlgItem(IDC_STATIC_PROPNAME);
  453. pType->SetWindowText(lp);
  454. }
  455. void CWabtoolDlg::SetPropDataString(ULONG ulPropTag)
  456. {
  457. CEdit * pEdit = (CEdit *) GetDlgItem(IDC_EDIT_PROPDATA);
  458. g_pWAB->SetPropString(pEdit, ulPropTag);
  459. }
  460. void CWabtoolDlg::OnButtonNew()
  461. {
  462. HRESULT hr = g_pWAB->ShowNewEntryDialog(m_hWnd);
  463. if(!hr)
  464. OnButtonRefresh();
  465. }
  466. void CWabtoolDlg::OnButtonDelete()
  467. {
  468. g_pWAB->DeleteEntry();
  469. // refresh the list view
  470. OnButtonRefresh();
  471. }
  472. void CWabtoolDlg::OnButtonAddprop()
  473. {
  474. TCHAR sz[512];
  475. *sz = '\0';
  476. CDlgProp dlgProp;
  477. dlgProp.m_ulPropTag = 0;
  478. dlgProp.m_lpszPropVal = sz;
  479. dlgProp.m_cbsz = sizeof(sz);
  480. if(dlgProp.DoModal())
  481. {
  482. g_pWAB->SetSingleStringProp(m_hWnd, dlgProp.m_ulPropTag, sz);
  483. UpdatePropTagData();
  484. OnSelchangeListTags();
  485. }
  486. }
  487. void CWabtoolDlg::OnButtonModifyprop()
  488. {
  489. CListBox * pList = (CListBox *) GetDlgItem(IDC_LIST_TAGS);
  490. ULONG ulPropTag = (ULONG) pList->GetItemData(pList->GetCurSel());
  491. TCHAR sz[512];
  492. if(g_pWAB->GetStringPropVal(m_hWnd, ulPropTag, sz, sizeof(sz)))
  493. {
  494. CDlgProp dlgProp;
  495. dlgProp.m_ulPropTag = ulPropTag;
  496. dlgProp.m_lpszPropVal = sz;
  497. dlgProp.m_cbsz = sizeof(sz);
  498. if(dlgProp.DoModal())
  499. {
  500. g_pWAB->SetSingleStringProp(m_hWnd, ulPropTag, sz);
  501. UpdatePropTagData();
  502. OnSelchangeListTags();
  503. }
  504. }
  505. }
  506. void CWabtoolDlg::OnDblclkListTags()
  507. {
  508. OnButtonModifyprop();
  509. }
  510. void CWabtoolDlg::OnButtonRefresh()
  511. {
  512. // refresh the list view
  513. ClearCurrentWAB(FALSE);
  514. LoadContents(FALSE);
  515. }
  516. void CWabtoolDlg::OnButtonWabview()
  517. {
  518. g_pWAB->ShowAddressBook(m_hWnd);
  519. }