[QUOTE}
penso di no, aggiungi via via le altre funzioni e guarda quando hai l'errore
ciao
sergio [/QUOTE]

questo è quello che ho potuto fare:

deallocando Id va in SIGSEGV quando si rialloca Id:

codice:
void InitCb(HWND hwnd, char from, int mItem, int IDCtrl, char *StrFind)
{
    RETCODE rc;
    SQLHSTMT stmtCb;
    char *StaSql=NULL;   ///QUI DA ADDRESS OUT OF BOUNDS     
    int *Id=new int(0);  /// RIGA 22  SIGSEGV   
    SQLAllocHandle(SQL_HANDLE_STMT,dbc,&stmtCb);
	if(from=='R') {	
	  StaSql=(char*)GlobalAlloc(GPTR,strlen("call DBA.sp_CbRicerca( ? )")+1);
	  StaSql="call DBA.sp_CbRicerca( ? )";
	  SQLBindParameter(stmtCb,1,SQL_PARAM_INPUT,SQL_C_SSHORT,SQL_INTEGER,0,0,&mItem,0,NULL);
	} else {
	       *Id=IDCtrl;
		if(mItem==12 && (IDCtrl==2107 || IDCtrl==2089)) {
		   	char TitWin[40]; GetWindowText(hwnd,TitWin,40);
			if(IDCtrl==2107) {
				*Id=((strcmp(TitWin,"Nuovo numero fisso")==0 || strcmp(TitWin,"Aggiorna numero fisso")==0) ? 1 : 2);
			} else if (IDCtrl==2089) {
				*Id=((strcmp(TitWin,"Nuovo numero fisso")==0 || strcmp(TitWin,"Aggiorna numero fisso")==0) ? 3 : 4);
			}
		}
		if((mItem==15 || mItem==16 || mItem==18) && (IDCtrl==2089 || IDCtrl==2092 || IDCtrl==2095 || IDCtrl==2098 || IDCtrl==2100)) {
			*Id=3; 
		} else if(mItem==18 && IDCtrl==2073) {
			*Id=4; 
		}
		if(mItem==21 && (IDCtrl==3141 || IDCtrl==3144))//IDC_tyE IDC_tyU
			*Id=3120; 
		if(mItem==22)
			*Id=5;
		if((mItem==23 || mItem==25) && IDCtrl==3202) {
			*Id=6;
		} else if(mItem==24 && IDCtrl==3202) {
			*Id=9;
		} else if(mItem==23 && IDCtrl==3204) {
			*Id=7;
		} else if((mItem==24 || mItem==25) && IDCtrl==3204) {
			*Id=8;
		}
        StaSql=(char*)GlobalAlloc(GPTR,strlen("call DBA.sp_Cb( ? )")+1);
        StaSql="call DBA.sp_Cb( ? )";
		SQLBindParameter(stmtCb,1,SQL_PARAM_INPUT,SQL_C_SSHORT,SQL_INTEGER,0,0,static_cast<void*>(Id),0,NULL);
		if(IDCtrl!=3120 && IDCtrl!=3202 && IDCtrl!=3204 && IDCtrl==3141 && IDCtrl==3144 || (IDCtrl==2089 || IDCtrl==2092 || IDCtrl==2095 || IDCtrl==2098 || IDCtrl==2100)) //type mov in docp,doca; gir
			SendDlgItemMessage(hwnd,IDCtrl,CB_ADDSTRING,0,(LPARAM)""); //item default
	}
	if(SQLExecDirect(stmtCb,(SQLCHAR*)StaSql,SQL_NTS)==SQL_SUCCESS) {
	  rc=SQLFetch(stmtCb);
	  RETCODE rc1;
	  while(rc== SQL_SUCCESS || rc==SQL_SUCCESS_WITH_INFO) {
		int *i=new int(1);
		while ((rc1=SQLGetData(stmtCb,*i,SQL_CHAR,szData1,50,&cbData1))==SQL_SUCCESS) {
			SendDlgItemMessage(hwnd,IDCtrl,CB_ADDSTRING,0,(LPARAM)szData1);
            *i+=1;
		}
		delete i;  ///QUESTO OK
                 rc=SQLFetch(stmtCb);
	  }
	  if(IDCtrl==802 || IDCtrl==2089 || IDCtrl==2092 || IDCtrl==2095 || IDCtrl==2098 || IDCtrl==2100 || IDCtrl==2073 || IDCtrl==2110 || IDCtrl==2111 || IDCtrl==2085 || IDCtrl==2086)
		  SendDlgItemMessage(hwnd,IDCtrl,CB_ADDSTRING,0,(LPARAM)"---new---");
	} else {
		ShowError(stmtCb);
	}
    	///delete Id;  ///QUESTO NO VA IN SIGSEGV in linea 22 	SQLFreeHandle(SQL_HANDLE_STMT,stmtCb);

	int *ItemSel=new int(0);  //1° item selezionato
	if(StrFind!=NULL) {
		*ItemSel=SendDlgItemMessage(hwnd,IDCtrl,CB_FINDSTRINGEXACT,(WPARAM)-1,(LPARAM)StrFind);
	}
	SendDlgItemMessage(hwnd,IDCtrl,CB_SETCURSEL,(WPARAM)*ItemSel, 0);
	delete ItemSel;  ///QUESTO OK
	GlobalFree(StaSql);
}

da debug inizialmente:

Local variables
StaSql= 0xa918 <Address 0xa918 out of bounds> ///PERCHE'

Id = (int*)0x0
ItemSel = (int*)0x4000400


quando crea int *Id=new int(0);

da debug:

Local variables
StaSql= 0x4380x8 "call DBA.sp_CbRicerca(?)"
id = (int*)0xb73378
ItemSel = (int*)0x4000400


quando crea int *i=new int(1); assegna stesso indirizzo di ItemSel ancora da creare E' OK??
da debug:

Local variables
i = (int*)0xb74228
Id = (int*)0xb73378
ItemSel = (int*)0xb74228


quando crea int *ItemSel=new int(0);
da debug:

Local variables
Id = (int*)0xb73378
ItemSel = (int*)0xb73efc