示例#1
0
int win_ListBox_Select (
  char *title,
  char **lines,       // array of string descriptions
  int    num_lines )  // # in array
{
	int i, selection;

	// If only 1 line available, return index to this line
	if (num_lines == 1)
		selection = 0;
	else {
		// Allow user to select from a MFC dialog box
		CArray <CString, CString> list;
	  for (i=0; i<num_lines; i++) 		
		  list.Add (lines[i]);
    ListBox dialog (NULL, title);
	  dialog.SetContents (&list);
//ShowCursor (TRUE);
	  if (dialog.DoModal () != IDOK)
		  selection = -1;
		else
			selection = dialog.GetSelection ();
  }

  return (selection);
}
示例#2
0
文件: Mediator.cpp 项目: z163/GoF23
void FontDialogDirector::WidgetChanged (
    Widget* theChangedWidget
) {
    if (theChangedWidget == _fontList) {
        _fontName->SetText(_fontList->GetSelection());} 
	else if (theChangedWidget == _ok) {
        // apply font change and dismiss dialog
        // ...
	} 
	else if (theChangedWidget == _cancel) {
        // dismiss dialog
    }
}