blob: c083444c5b2f150798c4c6b3e75126fdd0dafb1d [file] [log] [blame]
Constantin Kaplinsky47ed8d32004-10-08 09:43:57 +00001/* Copyright (C) 2002-2003 RealVNC Ltd. 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#include <vncviewer/ConnectionDialog.h>
19#include <vncviewer/CView.h>
20#include <vncviewer/resource.h>
21
22#include <tchar.h>
23
24using namespace rfb;
25using namespace rfb::win32;
26
27
28ConnectionDialog::ConnectionDialog(CView* view_) : Dialog(GetModuleHandle(0)), view(view_) {
29}
30
31
32bool ConnectionDialog::showDialog() {
33 return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONNECTION_DLG));
34}
35
36void ConnectionDialog::initDialog() {
37 HWND box = GetDlgItem(handle, IDC_SERVER_EDIT);
38
39 std::list<char*> mru = MRU::getEntries();
40 std::list<char*>::iterator i;
41
42 // Locate the combo-box
43 // NB: TCharArray converts the supplied char* and assumes ownership!
44 for (i=mru.begin(); i!=mru.end(); i++) {
45 int index = SendMessage(box, CB_ADDSTRING, 0, (LPARAM)TCharArray(*i).buf);
46 }
47
48 // Select the first item in the list
49 SendMessage(box, CB_SETCURSEL, 0, 0);
50}
51
52
53bool ConnectionDialog::onOk() {
54 delete [] hostname.buf;
55 hostname.buf = 0;
56 hostname.buf = getItemString(IDC_SERVER_EDIT);
57 return hostname.buf[0] != 0;
58}
59
60bool ConnectionDialog::onCommand(int id, int cmd) {
61 switch (id) {
62 case IDC_ABOUT:
63 AboutDialog::instance.showDialog();
64 return true;
65 case IDC_OPTIONS:
66 view->optionsDialog.showDialog(view);
67 return true;
68 };
69 return false;
70}