Exemplo n.º 1
0
bool
CAdvancedOptions::save(HWND hwnd)
{
	HWND child = getItem(hwnd, IDC_ADVANCED_NAME_EDIT);
	CString name = getWindowText(child);
	if (!m_config->isValidScreenName(name)) {
		showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_SCREEN_NAME).c_str(),
								name.c_str()));
		SetFocus(child);
		return false;
	}
	if (!m_isClient && !m_config->isScreen(name)) {
		showError(hwnd, CStringUtil::format(
								getString(IDS_UNKNOWN_SCREEN_NAME).c_str(),
								name.c_str()));
		SetFocus(child);
		return false;
	}

	// get and verify port
	child = getItem(hwnd, IDC_ADVANCED_PORT_EDIT);
	CString portString = getWindowText(child);
	int port = atoi(portString.c_str());
	if (port < 1 || port > 65535) {
		CString defaultPortString = CStringUtil::print("%d", kDefaultPort);
		showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_PORT).c_str(),
								portString.c_str(),
								defaultPortString.c_str()));
		SetFocus(child);
		return false;
	}

	// save state
	m_screenName = name;
	m_port       = port;

	// save values to registry
	HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath());
	if (key != NULL) {
		CArchMiscWindows::setValue(key, "port", m_port);
		CArchMiscWindows::setValue(key, "name", m_screenName);
		CArchMiscWindows::closeKey(key);
	}

	return true;
}
Exemplo n.º 2
0
void
CScreensLinks::changeSrcScreen(HWND hwnd)
{
	HWND child = getItem(hwnd, IDC_SCREENS_SRC_SCREEN);
	m_editedLink.m_srcName = getWindowText(child);
	updateLink(hwnd);
}
Exemplo n.º 3
0
void
CScreensLinks::changeDstScreen(HWND hwnd)
{
	HWND child = getItem(hwnd, IDC_SCREENS_DST_SCREEN);
	m_editedLink.m_dstName = getWindowText(child);
	updateLink(hwnd);
}
BOOL CExpressionTreeDlg::OnInitDialog() {
  __super::OnInitDialog();

  m_treeCtrl.substituteControl(this, IDC_TREE_EXPRESSION);

  m_layoutManager.OnInitDialog(this);
  m_layoutManager.addControl(IDC_TREE_EXPRESSION  , RELATIVE_SIZE );
  m_layoutManager.addControl(IDCLOSE              , RELATIVE_X_POS);
  m_layoutManager.addControl(IDC_CHECKEXTENDEDINFO, RELATIVE_X_POS);
  m_layoutManager.addControl(IDC_LIST_SYMBOLTABLE , RELATIVE_Y_POS | RELATIVE_WIDTH);

  m_treeCtrl.showTree(m_node, m_extendedInfo);

  const String treeFormName = m_expr.getTreeFormName();
  const String stateName    = m_expr.getStateName();
  const int    nodeCount    = m_expr.getNodeCount();

  String title = getWindowText(this);
  title += format(_T(" - %s form - state %s. %d nodes")
                 ,treeFormName.cstr()
                 ,stateName.cstr()
                 ,nodeCount
                 );
  setWindowText(this, title);

  CListBox *lb = (CListBox*)GetDlgItem(IDC_LIST_SYMBOLTABLE);
  const ExpressionVariableArray variables = m_expr.getSymbolTable().getAllVariables();
  for(size_t i = 0; i < variables.size(); i++) {
    const ExpressionVariableWithValue &v = variables[i];
    lb->InsertString(-1, v.toString().cstr());
  }
  return TRUE;
}
Exemplo n.º 5
0
String getWindowText(const CWnd *wnd, int id) {
  CWnd *ctrl = wnd->GetDlgItem(id);
  if(ctrl == NULL) {
    showWarning(_T("No dlgItem %d in window"), id);
    return EMPTYSTRING;
  }
  return getWindowText(ctrl);
}
void setControlText(int id, CWnd *wnd) {
  const String title = getWindowText(wnd);
  if(title.length() > 0 && title[0] == '{') {
    String newTitle = loadString(id);
    wnd->SetWindowText(newTitle.cstr());
  }

  for(CWnd *child = wnd->GetWindow(GW_CHILD); child; child = child->GetNextWindow()) {
//    id = child->GetDlgCtrlID();
    const String text = getWindowText(child);
    if(text.length() > 0 && text[0] == '{') {
      const String label = loadString(child->GetDlgCtrlID());
      if(label.length() > 0) {
        setWindowText(child, label);
      }
    }
  }
}
Exemplo n.º 7
0
bool CGridDlg::getUintEmptyZero(int id, UINT &value) {
  const String str = getWindowText(this, id).trim();
  if(str.length() == 0) {
    value = 0;
    return true;
  } else {
    return _stscanf(str.cstr(), _T("%u"), &value) == 1;
  }
}
Exemplo n.º 8
0
void UpdateUrlDlg::saveData() {
  // get the editbox
  CWnd* editbox = 
    FromHandle(::GetDlgItem(GetSafeHwnd(), IDC_PREFIX_EDIT));
  if (editbox) {
    const CString text = getWindowText(*editbox);
    String updateUrlPrefix = String(text.GetString());
    ToolbarSettings::getInstance().writeValue(
      TO_UPDATEURLPREFIX, updateUrlPrefix);
    editbox->Detach();
  }
}
Exemplo n.º 9
0
void CColoredStatic::repaint(CDC &dc) {
  CFont *font = GetFont();
  if(font == NULL) {
    font = GetParent()->GetFont();
  }
  CFont *oldFont = dc.SelectObject(font);
  if(m_bkColorSet) {
    dc.SetBkColor(m_bkColor);
  }
  dc.SetTextColor(m_textColor);

  String text = getWindowText(this);
  StringArray lineArray(Tokenizer(text, "\n"));

  const int textAlign = GetStyle() & 0x3;
  int y = 0;
  switch(textAlign) {
  case SS_LEFT:
    { for(size_t i = 0; i < lineArray.size(); i++) {
        const String &line = lineArray[i];
        const CSize lineSize = getTextExtent(dc, line);
        dc.TextOut(0,y,line.cstr());
        y += lineSize.cy;
      }
    }
    break;
  case SS_RIGHT:
    { const CSize winSize = getWindowSize(this);
      for(size_t i = 0; i < lineArray.size(); i++) {
        const String &line = lineArray[i];
        const CSize lineSize = getTextExtent(dc, line);
        dc.TextOut(max(0, winSize.cx - lineSize.cx), y, line.cstr());
        y += lineSize.cy;
      }
    }
    break;
  case SS_CENTER:
    { const CSize winSize = getWindowSize(this);
      for(size_t i = 0; i < lineArray.size(); i++) {
        const String &line = lineArray[i];
        const CSize lineSize = getTextExtent(dc, line);
        dc.TextOut(max(0, (winSize.cx - lineSize.cx)/2), y, line.cstr());
        y += lineSize.cy;
      }
    }
    break;
  }
  dc.SelectObject(oldFont);
}
Exemplo n.º 10
0
int
CGlobalOptions::getTime(HWND hwnd, HWND child, bool reportError)
{
	CString valueString = getWindowText(child);
	int value = atoi(valueString.c_str());
	if (value < 1) {
		if (reportError) {
			showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_TIME).c_str(),
								valueString.c_str()));
			SetFocus(child);
		}
		return 0;
	}
	return value;
}
Exemplo n.º 11
0
static
void
saveMainWindow(HWND hwnd)
{
	HKEY key = CArchMiscWindows::openKey(HKEY_CURRENT_USER, getSettingsPath());
	if (key != NULL) {
		HWND child;
		child = getItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT);
		CArchMiscWindows::setValue(key, "server", getWindowText(child));
		child = getItem(hwnd, IDC_MAIN_DEBUG);
		CArchMiscWindows::setValue(key, "debug",
								SendMessage(child, CB_GETCURSEL, 0, 0));
		CArchMiscWindows::setValue(key, "isServer",
								isClientChecked(hwnd) ? 0 : 1);
		CArchMiscWindows::closeKey(key);
	}
}
Exemplo n.º 12
0
void cglApp::update(void)
{
  m_timer.update();
  static float rFPS = -1;
  float rTime = m_timer.getTime() - m_rPrevTime;
  std::wostringstream fpsStream; 
  fpsStream << getWindowText();
  if (rTime > s_fpsMeasurementTime)
  {
    // Calculate FPS
    rFPS = float(m_nFrameCount) / rTime;
    // Drop
    m_rPrevTime   = m_timer.getTime();
    m_nFrameCount = 0;
  }
  if (rFPS != -1)
    fpsStream << L"; FPS = " << std::setprecision(1) << rFPS;
  SetWindowText(HWND(m_hWnd), fpsStream.str().c_str());
  m_nFrameCount++;
} 
Exemplo n.º 13
0
bool CGridDlg::getDoubleValue(int id, double &value) {
  const String str = getWindowText(this, id);
  return _stscanf(str.cstr(), _T("%le"), &value) == 1;
}
Exemplo n.º 14
0
bool CGridDlg::getUintValue(int id, UINT &value) {
  const String str = getWindowText(this, id);
  return _stscanf(str.cstr(), _T("%u"), &value) == 1;
}
double CEditListNumericEditor::getDoubleValue() {
  return stringToValue(getWindowText(this));
}
Exemplo n.º 16
0
static
bool
saveMainWindow(HWND hwnd, bool quiting, CString* cmdLineOut = NULL)
{
	DWORD errorID = 0;
	CString arg;
	CString cmdLine;

	// save dialog state
	bool isClient = isClientChecked(hwnd);
	HKEY key = CArchMiscWindows::addKey(HKEY_CURRENT_USER, getSettingsPath());
	if (key != NULL) {
		HWND child;
		child = getItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT);
		CArchMiscWindows::setValue(key, "server", getWindowText(child));
		child = getItem(hwnd, IDC_MAIN_DEBUG);
		CArchMiscWindows::setValue(key, "debug",
								SendMessage(child, CB_GETCURSEL, 0, 0));
		CArchMiscWindows::setValue(key, "isServer", isClient ? 0 : 1);
		CArchMiscWindows::closeKey(key);
	}

	// save user's configuration
	if (!saveConfig(ARG->m_config, false)) {
		errorID = IDS_SAVE_FAILED;
		arg     = getErrorString(GetLastError());
		goto failed;
	}

	// save autostart configuration
	if (CAutoStart::isDaemonInstalled()) {
		if (!saveConfig(ARG->m_config, true)) {
			errorID = IDS_AUTOSTART_SAVE_FAILED;
			arg     = getErrorString(GetLastError());
			goto failed;
		}
	}

	// get autostart command
	cmdLine = getCommandLine(hwnd, false, quiting);
	if (cmdLineOut != NULL) {
		*cmdLineOut = cmdLine;
	}
	if (cmdLine.empty()) {
		return quiting;
	}

	// save autostart command
	if (CAutoStart::isDaemonInstalled()) {
		try {
			CAutoStart::reinstallDaemon(isClient, cmdLine);
			CAutoStart::uninstallDaemons(!isClient);
		}
		catch (XArchDaemon& e) {
			errorID = IDS_INSTALL_GENERIC_ERROR;
			arg     = e.what();
			goto failed;
		}
	}

	return true;

failed:
	CString errorMessage =
		CStringUtil::format(getString(errorID).c_str(), arg.c_str());
	if (quiting) {
		errorMessage += "\n";
		errorMessage += getString(IDS_UNSAVED_DATA_REALLY_QUIT);
		if (askVerify(hwnd, errorMessage)) {
			return true;
		}
	}
	else {
		showError(hwnd, errorMessage);
	}
	return false;
}
Exemplo n.º 17
0
static
CString
getCommandLine(HWND hwnd, bool testing, bool silent)
{
	CString cmdLine;

	// add constant testing args
	if (testing) {
		cmdLine += " -z --no-restart --no-daemon";
	}

	// can't start as service on NT
	else if (!CArchMiscWindows::isWindows95Family()) {
		cmdLine += " --no-daemon";
	}

	// get the server name
	CString server;
	bool isClient = isClientChecked(hwnd);
	if (isClient) {
		// check server name
		HWND child = getItem(hwnd, IDC_MAIN_CLIENT_SERVER_NAME_EDIT);
		server = getWindowText(child);
		if (!ARG->m_config.isValidScreenName(server)) {
			if (!silent) {
				showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_SERVER_NAME).c_str(),
								server.c_str()));
			}
			SetFocus(child);
			return CString();
		}

		// compare server name to local host.  a common error
		// is to provide the client's name for the server.  we
		// don't bother to check the addresses though that'd be
		// more accurate.
		if (CStringUtil::CaselessCmp::equal(ARCH->getHostName(), server)) {
			if (!silent) {
				showError(hwnd, CStringUtil::format(
								getString(IDS_SERVER_IS_CLIENT).c_str(),
								server.c_str()));
			}
			SetFocus(child);
			return CString();
		}
	}

	// debug level.  always include this.
	if (true) {
		HWND child = getItem(hwnd, IDC_MAIN_DEBUG);
		int debug  = (int)SendMessage(child, CB_GETCURSEL, 0, 0);

		// if testing then we force the debug level to be no less than
		// s_minTestDebug.   what's the point of testing if you can't
		// see the debugging info?
		if (testing && debug < s_minTestDebug) {
			debug = s_minTestDebug;
		}

		cmdLine    += " --debug ";
		cmdLine    += s_debugName[debug][1];
	}

	// add advanced options
	cmdLine += s_advancedOptions->getCommandLine(isClient, server);

	return cmdLine;
}
Exemplo n.º 18
0
cglApp::cglApp(int nW, int nH, void* hInst, int nCmdShow) 
  : m_hWnd(NULL)
  , m_hInstance(hInst)
  , m_nClearColor(0xFF007F00)
  , m_pD3D(NULL)
  , m_nFrameCount(0)
  , m_rPrevTime(0.0f)
{
  // Register window class
  WNDCLASS wndClass;
  wndClass.style          = 0;
  wndClass.lpfnWndProc    = D3DBaseAppCallback;
  wndClass.cbClsExtra     = 0;
  wndClass.cbWndExtra     = 4;
  wndClass.hInstance      = HINSTANCE(hInst);
  wndClass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);
  wndClass.hCursor        = LoadCursor(NULL, IDC_ARROW);
  wndClass.hbrBackground  = HBRUSH(GetStockObject(WHITE_BRUSH));
  wndClass.lpszMenuName   = NULL;
  wndClass.lpszClassName  = s_windowClassName;
  RegisterClass(&wndClass);

  // Adjust window in regard to client area nW x nH
  int  nStyle = WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX;
  RECT rRect;
  SetRect(&rRect, 0, 0, nW, nH);
  AdjustWindowRect(&rRect, nStyle, TRUE);
  
  // Create main window
  m_hWnd = NULL;
  m_hWnd = (void*)CreateWindow(s_windowClassName, getWindowText(), nStyle,
                               CW_USEDEFAULT, CW_USEDEFAULT, 
                               (rRect.right - rRect.left), (rRect.bottom - rRect.top),
                               NULL, NULL, HINSTANCE(hInst), NULL);
  if (m_hWnd == NULL)
    return;
    
  // Set pointer
  SetWindowLong(HWND(m_hWnd), 0, LONG(this));

  // Show window
  ShowWindow(HWND(m_hWnd), nCmdShow);
  UpdateWindow(HWND(m_hWnd));
  
  // We need to determine the BPP of desktop
  HDC hDC = GetDC(HWND(m_hWnd));            // Get DC of desktop
  int nBPP = GetDeviceCaps(hDC, BITSPIXEL); // Retrieve BPP
  ReleaseDC(HWND(m_hWnd), hDC);             // Release DC handle

  // Create our D3D class
  cglD3D::CreateParams params;
  params.hWnd    = m_hWnd;
  params.nBPP    = (nBPP == 32) ? cglD3D::BPP_32 : cglD3D::BPP_16;
  params.nWidth  = nW;
  params.nHeight = nH;
  m_pD3D = new cglD3D(params);
  // Check creation result
  if (m_pD3D == NULL || m_pD3D->isFailed())
    return;

  // Init random generator
  srand(0);
}
String CEditListStringEditor::getValue() {
  const String v = getWindowText(this);
  validateValue(v);
  return v;
}
Exemplo n.º 20
0
String Window::getText() const
{
  return getWindowText(hWnd);
}
Exemplo n.º 21
0
bool
CAdvancedOptions::save(HWND hwnd)
{
	SetCursor(LoadCursor(NULL, IDC_WAIT));

	HWND child = getItem(hwnd, IDC_ADVANCED_NAME_EDIT);
	CString name = getWindowText(child);
	if (!m_config->isValidScreenName(name)) {
		showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_SCREEN_NAME).c_str(),
								name.c_str()));
		SetFocus(child);
		return false;
	}
	if (!m_isClient && !m_config->isScreen(name)) {
		showError(hwnd, CStringUtil::format(
								getString(IDS_UNKNOWN_SCREEN_NAME).c_str(),
								name.c_str()));
		SetFocus(child);
		return false;
	}

	child = getItem(hwnd, IDC_ADVANCED_INTERFACE_EDIT);
	CString iface = getWindowText(child);
	if (!m_isClient) {
		try {
			if (!iface.empty()) {
				ARCH->nameToAddr(iface);
			}
		}
		catch (XArchNetworkName& e) {
			showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_INTERFACE_NAME).c_str(),
								iface.c_str(), e.what().c_str()));
			SetFocus(child);
			return false;
		}
	}

	// get and verify port
	child = getItem(hwnd, IDC_ADVANCED_PORT_EDIT);
	CString portString = getWindowText(child);
	int port = atoi(portString.c_str());
	if (port < 1 || port > 65535) {
		CString defaultPortString = CStringUtil::print("%d", kDefaultPort);
		showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_PORT).c_str(),
								portString.c_str(),
								defaultPortString.c_str()));
		SetFocus(child);
		return false;
	}

	// save state
	m_screenName = name;
	m_port       = port;
	m_interface  = iface;

	// save values to registry
	HKEY key = CArchMiscWindows::addKey(HKEY_CURRENT_USER, getSettingsPath());
	if (key != NULL) {
		CArchMiscWindows::setValue(key, "port", m_port);
		CArchMiscWindows::setValue(key, "name", m_screenName);
		CArchMiscWindows::setValue(key, "interface", m_interface);
		CArchMiscWindows::closeKey(key);
	}

	return true;
}
Exemplo n.º 22
0
static
BOOL CALLBACK
addDlgProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	// only one add dialog at a time!
	static CScreenInfo* info = NULL;

	switch (message) {
	case WM_INITDIALOG: {
		info = (CScreenInfo*)lParam;

		// set title
		CString title;
		if (info->m_screen.empty()) {
			title = getString(IDS_ADD_SCREEN);
		}
		else {
			title = CStringUtil::format(
								getString(IDS_EDIT_SCREEN).c_str(),
								info->m_screen.c_str());
		}
		SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM)title.c_str());

		// fill in screen name
		HWND child = getItem(hwnd, IDC_ADD_SCREEN_NAME_EDIT);
		SendMessage(child, WM_SETTEXT, 0, (LPARAM)info->m_screen.c_str());

		// fill in aliases
		CString aliases;
		for (CStringList::const_iterator index = info->m_aliases.begin();
								index != info->m_aliases.end(); ++index) {
			if (!aliases.empty()) {
				aliases += "\r\n";
			}
			aliases += *index;
		}
		child = getItem(hwnd, IDC_ADD_ALIASES_EDIT);
		SendMessage(child, WM_SETTEXT, 0, (LPARAM)aliases.c_str());

		// set options
		CConfig::CScreenOptions::const_iterator index;
		child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK);
		index = info->m_options.find(kOptionHalfDuplexCapsLock);
		setItemChecked(child, (index != info->m_options.end() &&
											index->second != 0));
		child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK);
		index = info->m_options.find(kOptionHalfDuplexNumLock);
		setItemChecked(child, (index != info->m_options.end() &&
											index->second != 0));
		child = getItem(hwnd, IDC_ADD_HD_SCROLL_CHECK);
		index = info->m_options.find(kOptionHalfDuplexScrollLock);
		setItemChecked(child, (index != info->m_options.end() &&
											index->second != 0));

		// modifier options
		for (UInt32 i = 0; i < sizeof(s_modifiers) /
									sizeof(s_modifiers[0]); ++i) {
			child = getItem(hwnd, s_modifiers[i].m_ctrlID);

			// fill in options
			for (UInt32 j = 0; j < sizeof(s_modifiers) /
										sizeof(s_modifiers[0]); ++j) {
				SendMessage(child, CB_ADDSTRING, 0,
									(LPARAM)s_modifiers[j].m_name);
			}

			// choose current value
			index            = info->m_options.find(s_modifiers[i].m_optionID);
			KeyModifierID id = s_modifiers[i].m_modifierID;
			if (index != info->m_options.end()) {
				id = index->second;
			}
			SendMessage(child, CB_SETCURSEL, id - baseModifier, 0);
		}

		// dead corners
		UInt32 corners = 0;
		index = info->m_options.find(kOptionScreenSwitchCorners);
		if (index != info->m_options.end()) {
			corners = index->second;
		}
		child = getItem(hwnd, IDC_ADD_DC_TOP_LEFT);
		setItemChecked(child, (corners & kTopLeftMask) != 0);
		child = getItem(hwnd, IDC_ADD_DC_TOP_RIGHT);
		setItemChecked(child, (corners & kTopRightMask) != 0);
		child = getItem(hwnd, IDC_ADD_DC_BOTTOM_LEFT);
		setItemChecked(child, (corners & kBottomLeftMask) != 0);
		child = getItem(hwnd, IDC_ADD_DC_BOTTOM_RIGHT);
		setItemChecked(child, (corners & kBottomRightMask) != 0);
		index = info->m_options.find(kOptionScreenSwitchCornerSize);
		SInt32 size = 0;
		if (index != info->m_options.end()) {
			size = index->second;
		}
		char buffer[20];
		sprintf(buffer, "%d", size);
		child = getItem(hwnd, IDC_ADD_DC_SIZE);
		SendMessage(child, WM_SETTEXT, 0, (LPARAM)buffer);

		return TRUE;
	}

	case WM_COMMAND:
		switch (LOWORD(wParam)) {
		case IDOK: {
			CString newName;
			CStringList newAliases;

			// extract name and aliases
			HWND child = getItem(hwnd, IDC_ADD_SCREEN_NAME_EDIT);
			newName = getWindowText(child);
			child = getItem(hwnd, IDC_ADD_ALIASES_EDIT);
			tokenize(newAliases, getWindowText(child));

			// name must be valid
			if (!ARG->m_config.isValidScreenName(newName)) {
				showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_SCREEN_NAME).c_str(),
								newName.c_str()));
				return TRUE;
			}

			// aliases must be valid
			for (CStringList::const_iterator index = newAliases.begin();
								index != newAliases.end(); ++index) {
				if (!ARG->m_config.isValidScreenName(*index)) {
					showError(hwnd, CStringUtil::format(
								getString(IDS_INVALID_SCREEN_NAME).c_str(),
								index->c_str()));
					return TRUE;
				}
			}

			// new name may not be in the new alias list
			if (isNameInList(newAliases, newName)) {
				showError(hwnd, CStringUtil::format(
								getString(IDS_SCREEN_NAME_IS_ALIAS).c_str(),
								newName.c_str()));
				return TRUE;
			}

			// name must not exist in config but allow same name.  also
			// allow name if it exists in the old alias list but not the
			// new one.
			if (ARG->m_config.isScreen(newName) &&
				!CStringUtil::CaselessCmp::equal(newName, info->m_screen) &&
				!isNameInList(info->m_aliases, newName)) {
				showError(hwnd, CStringUtil::format(
								getString(IDS_DUPLICATE_SCREEN_NAME).c_str(),
								newName.c_str()));
				return TRUE;
			}

			// aliases must not exist in config but allow same aliases and
			// allow an alias to be the old name.
			for (CStringList::const_iterator index = newAliases.begin();
								index != newAliases.end(); ++index) {
				if (ARG->m_config.isScreen(*index) &&
					!CStringUtil::CaselessCmp::equal(*index, info->m_screen) &&
					!isNameInList(info->m_aliases, *index)) {
					showError(hwnd, CStringUtil::format(
								getString(IDS_DUPLICATE_SCREEN_NAME).c_str(),
								index->c_str()));
					return TRUE;
				}
			}

			// dead corner size must be non-negative
			child = getItem(hwnd, IDC_ADD_DC_SIZE);
			CString valueString = getWindowText(child);
			int cornerSize = atoi(valueString.c_str());
			if (cornerSize < 0) {
				showError(hwnd, CStringUtil::format(
									getString(IDS_INVALID_CORNER_SIZE).c_str(),
									valueString.c_str()));
				SetFocus(child);
				return TRUE;
			}

			// save name data
			info->m_screen  = newName;
			info->m_aliases = newAliases;

			// save options
			child = getItem(hwnd, IDC_ADD_HD_CAPS_CHECK);
			if (isItemChecked(child)) {
				info->m_options[kOptionHalfDuplexCapsLock] = 1;
			}
			else {
				info->m_options.erase(kOptionHalfDuplexCapsLock);
			}
			child = getItem(hwnd, IDC_ADD_HD_NUM_CHECK);
			if (isItemChecked(child)) {
				info->m_options[kOptionHalfDuplexNumLock] = 1;
			}
			else {
				info->m_options.erase(kOptionHalfDuplexNumLock);
			}
			child = getItem(hwnd, IDC_ADD_HD_SCROLL_CHECK);
			if (isItemChecked(child)) {
				info->m_options[kOptionHalfDuplexScrollLock] = 1;
			}
			else {
				info->m_options.erase(kOptionHalfDuplexScrollLock);
			}

			// save modifier options
			for (UInt32 i = 0; i < sizeof(s_modifiers) /
										sizeof(s_modifiers[0]); ++i) {
				child            = getItem(hwnd, s_modifiers[i].m_ctrlID);
				KeyModifierID id = static_cast<KeyModifierID>(
									SendMessage(child, CB_GETCURSEL, 0, 0) +
										baseModifier);
				if (id != s_modifiers[i].m_modifierID) {
					info->m_options[s_modifiers[i].m_optionID] = id;
				}
				else {
					info->m_options.erase(s_modifiers[i].m_optionID);
				}
			}

			// save dead corner options
			UInt32 corners = 0;
			if (isItemChecked(getItem(hwnd, IDC_ADD_DC_TOP_LEFT))) {
				corners |= kTopLeftMask;
			}
			if (isItemChecked(getItem(hwnd, IDC_ADD_DC_TOP_RIGHT))) {
				corners |= kTopRightMask;
			}
			if (isItemChecked(getItem(hwnd, IDC_ADD_DC_BOTTOM_LEFT))) {
				corners |= kBottomLeftMask;
			}
			if (isItemChecked(getItem(hwnd, IDC_ADD_DC_BOTTOM_RIGHT))) {
				corners |= kBottomRightMask;
			}
			info->m_options[kOptionScreenSwitchCorners]    = corners;
			info->m_options[kOptionScreenSwitchCornerSize] = cornerSize;

			// success
			EndDialog(hwnd, 1);
			info = NULL;
			return TRUE;
		}

		case IDCANCEL:
			EndDialog(hwnd, 0);
			info = NULL;
			return TRUE;
		}

	default:
		break;
	}

	return FALSE;
}