Dennis Syrovatsky | 32ed332 | 2005-12-15 09:37:38 +0000 | [diff] [blame] | 1 | /* Copyright (C) 2005 TightVNC Team. All Rights Reserved. |
| 2 | * |
| 3 | * This is free software; you can redistribute it and/or modify |
| 4 | * it under the terms of the GNU General Public License as published by |
| 5 | * the Free Software Foundation; either version 2 of the License, or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * This software is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | * You should have received a copy of the GNU General Public License |
| 14 | * along with this software; if not, write to the Free Software |
| 15 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
| 16 | * USA. |
| 17 | * |
| 18 | * TightVNC distribution homepage on the Web: http://www.tightvnc.com/ |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | // -=- FTBrpwseDlg.cxx |
| 23 | |
| 24 | #include <vncviewer/FTBrowseDlg.h> |
| 25 | |
| 26 | using namespace rfb; |
| 27 | using namespace rfb::win32; |
| 28 | |
| 29 | FTBrowseDlg::FTBrowseDlg(FTDialog *pFTDlg) |
| 30 | { |
Dennis Syrovatsky | 04e05c3 | 2005-12-15 09:51:03 +0000 | [diff] [blame] | 31 | m_pFTDlg = pFTDlg; |
| 32 | m_hwndDlg = NULL; |
Dennis Syrovatsky | 32ed332 | 2005-12-15 09:37:38 +0000 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | FTBrowseDlg::~FTBrowseDlg() |
| 36 | { |
Dennis Syrovatsky | 04e05c3 | 2005-12-15 09:51:03 +0000 | [diff] [blame] | 37 | destroy(); |
| 38 | } |
Dennis Syrovatsky | 32ed332 | 2005-12-15 09:37:38 +0000 | [diff] [blame] | 39 | |
Dennis Syrovatsky | 04e05c3 | 2005-12-15 09:51:03 +0000 | [diff] [blame] | 40 | bool |
| 41 | FTBrowseDlg::create() |
| 42 | { |
| 43 | m_hwndDlg = CreateDialogParam(GetModuleHandle(0), MAKEINTRESOURCE(IDD_FTBROWSE), |
| 44 | m_pFTDlg->getWndHandle(), (DLGPROC) FTBrowseDlgProc, |
| 45 | (LONG) this); |
| 46 | |
| 47 | if (m_hwndDlg == NULL) return false; |
| 48 | |
| 49 | ShowWindow(m_hwndDlg, SW_SHOW); |
| 50 | UpdateWindow(m_hwndDlg); |
| 51 | |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | void |
| 56 | FTBrowseDlg::destroy() |
| 57 | { |
| 58 | EndDialog(m_hwndDlg, 0); |
Dennis Syrovatsky | 32ed332 | 2005-12-15 09:37:38 +0000 | [diff] [blame] | 59 | } |
Dennis Syrovatsky | 2eee1c7 | 2005-12-15 09:43:34 +0000 | [diff] [blame] | 60 | |
Dennis Syrovatsky | b0b7247 | 2005-12-15 10:02:16 +0000 | [diff] [blame^] | 61 | void |
| 62 | FTBrowseDlg::addItems(FileInfo *pFI) |
| 63 | { |
| 64 | TVITEM tvi; |
| 65 | TVINSERTSTRUCT tvins; |
| 66 | |
| 67 | for (unsigned int i = 0; i < pFI->getNumEntries(); i++) |
| 68 | { |
| 69 | tvi.mask = TVIF_TEXT; |
| 70 | tvi.pszText = pFI->getNameAt(i);; |
| 71 | tvins.hParent = NULL; |
| 72 | tvins.item = tvi; |
| 73 | tvins.hParent = TreeView_InsertItem(GetDlgItem(m_hwndDlg, IDC_FTBROWSETREE), &tvins); |
| 74 | TreeView_InsertItem(GetDlgItem(m_hwndDlg, IDC_FTBROWSETREE), &tvins); |
| 75 | } |
| 76 | } |
| 77 | |
Dennis Syrovatsky | 2eee1c7 | 2005-12-15 09:43:34 +0000 | [diff] [blame] | 78 | BOOL CALLBACK |
| 79 | FTBrowseDlg::FTBrowseDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) |
| 80 | { |
| 81 | FTBrowseDlg *_this = (FTBrowseDlg *) GetWindowLong(hwnd, GWL_USERDATA); |
| 82 | switch (uMsg) |
| 83 | { |
| 84 | case WM_INITDIALOG: |
| 85 | { |
| 86 | SetWindowLong(hwnd, GWL_USERDATA, lParam); |
| 87 | return FALSE; |
| 88 | } |
| 89 | break; |
| 90 | case WM_COMMAND: |
| 91 | { |
| 92 | switch (LOWORD(wParam)) |
| 93 | { |
| 94 | case IDOK: |
| 95 | return FALSE; |
| 96 | case IDCANCEL: |
| 97 | return FALSE; |
| 98 | } |
| 99 | } |
| 100 | break; |
| 101 | case WM_NOTIFY: |
| 102 | switch (LOWORD(wParam)) |
| 103 | { |
| 104 | case IDC_FTBROWSETREE: |
| 105 | switch (((LPNMHDR) lParam)->code) |
| 106 | { |
| 107 | case TVN_SELCHANGED: |
| 108 | return FALSE; |
| 109 | case TVN_ITEMEXPANDING: |
| 110 | return FALSE; |
| 111 | } |
| 112 | break; |
| 113 | } |
| 114 | break; |
| 115 | case WM_CLOSE: |
| 116 | case WM_DESTROY: |
| 117 | return FALSE; |
| 118 | } |
| 119 | return 0; |
| 120 | } |