newntui/activex/groupscombo/src/groupscomboctl.cpp
//-----------------------------------------------------------------------------------
// Callback will run when user pressed new group button on the toolbar.
// Will ask the user group name and will create new group if possible. The list
// will be automatically re-filled and the selection will be placed on the new group.
// Will fire NewGroup event to the container.
//------------------------------------------------------------------------------------
Callback will run when user pressed new group button on the toolbar.
Will ask the user group name and will create new group if possible. The list
will be automatically re-filled and the selection will be placed on the new group.
Will fire NewGroup event to the container.
Callback will run when user pressed new group button on the toolbar . Will ask the user group name and will create new group if possible . The list will be automatically re - filled and the selection will be placed on the new group . Will fire NewGroup event to the container .
void CGroupsComboCtrl::OnNewGroup() {
CString serverCall;
CString serverResults;
CString serverName;
CNewGroupDlg name;
   name.m_Scratch = 0;
   if(name.DoModal()==IDOK) {
	   serverName="";
	   for(register i=0;i<name.m_Name.GetLength();i++) { 
		   if( name.m_Name[i] != '{' && name.m_Name[i]!= '}' && name.m_Name[i]!= ' '  && 
			   name.m_Name[i] != '~' && name.m_Name[i]!= '@' && name.m_Name[i]!= '#'  && 
			   name.m_Name[i] != '$' && name.m_Name[i]!= '%' && name.m_Name[i]!= '^'  && 
			   name.m_Name[i] != '&' && name.m_Name[i]!= '*' && name.m_Name[i]!= '('  && 
			   name.m_Name[i] != ')' && name.m_Name[i]!= '+' && name.m_Name[i]!= '\\' && 
			   name.m_Name[i] != '|' && name.m_Name[i]!= '=' && name.m_Name[i]!= '`'  && 
			   name.m_Name[i] != '<' && name.m_Name[i]!= '>' && name.m_Name[i]!= '/') 
			   serverName+=name.m_Name[i];
		   else
			   serverName+='_';
	   }
	   serverCall.Format("group exists %s",serverName);
	   EvaluateSync(serverCall,&serverResults);
	   if(atoi(serverResults)!=0) {
		   CString errStr;
		   errStr.Format("The group with the name \"%s\" already exists!",serverName);
		   MessageBox(errStr,"Group Manager Error",MB_ICONSTOP);
		   return;
	   }
	   if(name.m_Scratch!=0) {
	      serverCall.Format("group new %s",serverName);
	      EvaluateSync(serverCall);
	      serverCall.Format("group save %s",serverName);
	      EvaluateSync(serverCall);
	   } else {
	      serverCall.Format("group tmp %s",serverName);
	      EvaluateSync(serverCall);
	   }
	   m_ElementsList.InsertItem(0,serverName,0);
       LV_FINDINFO findWhat; 
       findWhat.flags = LVFI_STRING;
	   findWhat.psz   = serverName;
	   int thisGroup = m_ElementsList.FindItem(&findWhat);
	   for(i=0; i<m_ElementsList.GetItemCount();i++) 
          m_ElementsList.SetItemState(i,~LVIS_SELECTED,LVIS_SELECTED);
	   if(thisGroup>=0)
	       m_ElementsList.SetItemState(thisGroup,LVIS_FOCUSED | LVIS_SELECTED,LVIS_FOCUSED | LVIS_SELECTED);
       m_GroupsList="";
	   for(i=0; i<m_ElementsList.GetItemCount();i++) {
          if(m_ElementsList.GetItemState(i,LVIS_SELECTED)!=0) {
		     m_GroupsList+="{";
		     m_GroupsList+=m_ElementsList.GetItemText(i,0);
		     m_GroupsList+='}';
	         m_ElementsList.SetItemState(thisGroup,0,LVIS_SELECTED);
		   }
	   }
	   SetToolbarStatus();
	   FillElementsList();
	   FireGroupCreated(serverName);
   }
}
void CGroupsComboCtrl :: OnNewGroup ( ) { CString serverCall ; CString serverResults ; CString serverName ; CNewGroupDlg name ; name . m_Scratch = 0 ; if ( name . DoModal ( ) == IDOK ) { serverName = " " ; for ( register i = 0 ; i < name . m_Name . GetLength ( ) ; i ++ ) { if ( name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' \\ ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' && name . m_Name [ i ] != ' ' ) serverName += name . m_Name [ i ] ; else serverName += ' ' ; } serverCall . Format ( " " , serverName ) ; EvaluateSync ( serverCall , & serverResults ) ; if ( atoi ( serverResults ) != 0 ) { CString errStr ; errStr . Format ( " \" \" " , serverName ) ; MessageBox ( errStr , " " , MB_ICONSTOP ) ; return ; } if ( name . m_Scratch != 0 ) { serverCall . Format ( " " , serverName ) ; EvaluateSync ( serverCall ) ; serverCall . Format ( " " , serverName ) ; EvaluateSync ( serverCall ) ; } else { serverCall . Format ( " " , serverName ) ; EvaluateSync ( serverCall ) ; } m_ElementsList . InsertItem ( 0 , serverName , 0 ) ; LV_FINDINFO findWhat ; findWhat . flags = LVFI_STRING ; findWhat . psz = serverName ; int thisGroup = m_ElementsList . FindItem ( & findWhat ) ; for ( i = 0 ; i < m_ElementsList . GetItemCount ( ) ; i ++ ) m_ElementsList . SetItemState ( i , ~ LVIS_SELECTED , LVIS_SELECTED ) ; if ( thisGroup >= 0 ) m_ElementsList . SetItemState ( thisGroup , LVIS_FOCUSED | LVIS_SELECTED , LVIS_FOCUSED | LVIS_SELECTED ) ; m_GroupsList = " " ; for ( i = 0 ; i < m_ElementsList . GetItemCount ( ) ; i ++ ) { if ( m_ElementsList . GetItemState ( i , LVIS_SELECTED ) != 0 ) { m_GroupsList += " " ; m_GroupsList += m_ElementsList . GetItemText ( i , 0 ) ; m_GroupsList += ' ' ; m_ElementsList . SetItemState ( thisGroup , 0 , LVIS_SELECTED ) ; } } SetToolbarStatus ( ) ; FillElementsList ( ) ; FireGroupCreated ( serverName ) ; } }
Callback will run when user pressed new group button on the toolbar.
Callback will run when user pressed new group button on the toolbar .
// Will change "{" "}" or space into "_" // Maybe we are trying to create existing group ?    // Creating new group in the database // We will select newly created group // Removing all old selections // Selecting current item