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.

ConnectionDialog.cxx 2.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* 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. #include <tchar.h>
  22. using namespace rfb;
  23. using namespace rfb::win32;
  24. ConnectionDialog::ConnectionDialog(CView* view_) : Dialog(GetModuleHandle(0)), view(view_) {
  25. }
  26. bool ConnectionDialog::showDialog() {
  27. return Dialog::showDialog(MAKEINTRESOURCE(IDD_CONNECTION_DLG));
  28. }
  29. void ConnectionDialog::initDialog() {
  30. HWND box = GetDlgItem(handle, IDC_SERVER_EDIT);
  31. std::list<char*> mru = MRU::getEntries();
  32. std::list<char*>::iterator i;
  33. // Locate the combo-box
  34. // NB: TCharArray converts the supplied char* and assumes ownership!
  35. for (i=mru.begin(); i!=mru.end(); i++) {
  36. int index = SendMessage(box, CB_ADDSTRING, 0, (LPARAM)TCharArray(*i).buf);
  37. }
  38. // Select the first item in the list
  39. SendMessage(box, CB_SETCURSEL, 0, 0);
  40. }
  41. bool ConnectionDialog::onOk() {
  42. delete [] hostname.buf;
  43. hostname.buf = 0;
  44. hostname.buf = getItemString(IDC_SERVER_EDIT);
  45. return hostname.buf[0] != 0;
  46. }
  47. bool ConnectionDialog::onCommand(int id, int cmd) {
  48. switch (id) {
  49. case IDC_ABOUT:
  50. AboutDialog::instance.showDialog();
  51. return true;
  52. case IDC_OPTIONS:
  53. view->optionsDialog.showDialog(view);
  54. return true;
  55. };
  56. return false;
  57. }