Exemplo n.º 1
0
static int ProcessDatabaseValueDefault(CONTACTINFO *ci, const char* setting)
{
	DBVARIANT dbv;
	if ( !GetDatabaseString( ci, setting, &dbv )) {
		switch (dbv.type) {
		case DBVT_ASCIIZ:
			if (!dbv.pszVal[0]) break;
		case DBVT_WCHAR:
			if (!dbv.pwszVal[0]) break;
			ci->type = CNFT_ASCIIZ;
			ci->pszVal = dbv.ptszVal;
			return 0;
		}
		DBFreeVariant( &dbv );
	}

	if ( DBGetContactSetting( ci->hContact, ci->szProto, setting, &dbv ))
		return 1;

	switch (dbv.type) {
	case DBVT_BYTE:
		ci->type = CNFT_BYTE;
		ci->bVal = dbv.bVal;
		return 0;
	case DBVT_WORD:
		ci->type = CNFT_WORD;
		ci->wVal = dbv.wVal;
		return 0;
	case DBVT_DWORD:
		ci->type = CNFT_DWORD;
		ci->dVal = dbv.dVal;
		return 0;
	}

	DBFreeVariant( &dbv );
	return 1;
}
Exemplo n.º 2
0
static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) {
	DBVARIANT dbv;
	CONTACTINFO *ci = (CONTACTINFO*)lParam;

	if (ci==NULL) return 1;
	if (ci->szProto==NULL) ci->szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEACCOUNT,(WPARAM)ci->hContact,0);
	if (ci->szProto==NULL) return 1;
	ci->type = 0;
	switch(ci->dwFlag & 0x7F) {
		case CNF_FIRSTNAME:  return ProcessDatabaseValueDefault( ci, "FirstName" );
		case CNF_LASTNAME:   return ProcessDatabaseValueDefault( ci, "LastName" );
		case CNF_NICK:       return ProcessDatabaseValueDefault( ci, "Nick" );
		case CNF_EMAIL:      return ProcessDatabaseValueDefault( ci, "e-mail" );
		case CNF_CITY:       return ProcessDatabaseValueDefault( ci, "City" );
		case CNF_STATE:      return ProcessDatabaseValueDefault( ci, "State" );
		case CNF_PHONE:      return ProcessDatabaseValueDefault( ci, "Phone" );
		case CNF_HOMEPAGE:   return ProcessDatabaseValueDefault( ci, "Homepage" );
		case CNF_ABOUT:      return ProcessDatabaseValueDefault( ci, "About" );
		case CNF_AGE:        return ProcessDatabaseValueDefault( ci, "Age" );
		case CNF_GENDER:     return ProcessDatabaseValueDefault( ci, "Gender" );
		case CNF_FAX:        return ProcessDatabaseValueDefault( ci, "Fax" );
		case CNF_CELLULAR:	return ProcessDatabaseValueDefault( ci, "Cellular" );
		case CNF_BIRTHDAY:	return ProcessDatabaseValueDefault( ci, "BirthDay" );
		case CNF_BIRTHMONTH:	return ProcessDatabaseValueDefault( ci, "BirthMonth" );
		case CNF_BIRTHYEAR:	return ProcessDatabaseValueDefault( ci, "BirthYear" );
		case CNF_STREET:		return ProcessDatabaseValueDefault( ci, "Street" );
		case CNF_ZIP:			return ProcessDatabaseValueDefault( ci, "ZIP" );
		case CNF_LANGUAGE1:	return ProcessDatabaseValueDefault( ci, "Language1" );
		case CNF_LANGUAGE2:	return ProcessDatabaseValueDefault( ci, "Language2" );
		case CNF_LANGUAGE3:	return ProcessDatabaseValueDefault( ci, "Language3" );
		case CNF_CONAME:		return ProcessDatabaseValueDefault( ci, "Company" );
		case CNF_CODEPT:     return ProcessDatabaseValueDefault( ci, "CompanyDepartment" );
		case CNF_COPOSITION: return ProcessDatabaseValueDefault( ci, "CompanyPosition" );
		case CNF_COSTREET:   return ProcessDatabaseValueDefault( ci, "CompanyStreet" );
		case CNF_COCITY:     return ProcessDatabaseValueDefault( ci, "CompanyCity" );
		case CNF_COSTATE:    return ProcessDatabaseValueDefault( ci, "CompanyState" );
		case CNF_COZIP:      return ProcessDatabaseValueDefault( ci, "CompanyZIP" );
		case CNF_COHOMEPAGE: return ProcessDatabaseValueDefault( ci, "CompanyHomepage" );

		case CNF_CUSTOMNICK:
		{
			char* saveProto = ci->szProto; ci->szProto = "CList";
			if ( ci->hContact != NULL && !ProcessDatabaseValueDefault( ci, "MyHandle" )) {
				ci->szProto = saveProto;
				return 0;
			}
			ci->szProto = saveProto;
			break;
		}
		case CNF_COUNTRY:
		case CNF_COCOUNTRY:
			if ( !GetDatabaseString( ci, (ci->dwFlag & 0x7F) == CNF_COUNTRY ? "CountryName" : "CompanyCountryName", &dbv ))
				return 0;

			if ( !DBGetContactSetting( ci->hContact, ci->szProto, (ci->dwFlag & 0x7F)==CNF_COUNTRY ? "Country" : "CompanyCountry", &dbv )) {
				if ( dbv.type == DBVT_WORD ) {
					int i,countryCount;
					struct CountryListEntry *countries;
					CallService(MS_UTILS_GETCOUNTRYLIST,(WPARAM)&countryCount,(LPARAM)&countries);
					for(i=0;i<countryCount;i++) {
						if(countries[i].id!=dbv.wVal) continue;

						if ( ci->dwFlag & CNF_UNICODE ) {
							int cbLen = MultiByteToWideChar( CP_ACP, 0, ( LPCSTR )countries[i].szName, -1, NULL, 0 );
							WCHAR* buf = ( WCHAR* )mir_alloc( sizeof( WCHAR )*(cbLen+1) );
							if ( buf != NULL )
								MultiByteToWideChar( CP_ACP, 0, ( LPCSTR )countries[i].szName, -1, buf, cbLen );
							ci->pszVal = ( TCHAR* )buf;
						}
						else ci->pszVal = ( TCHAR* )mir_strdup(countries[i].szName);

						ci->type = CNFT_ASCIIZ;
						DBFreeVariant(&dbv);
						return 0;
					}
				}
				else return ProcessDatabaseValueDefault( ci, (ci->dwFlag & 0x7F)==CNF_COUNTRY ? "Country" : "CompanyCountry" );
				DBFreeVariant(&dbv);
			}
			break;

		case CNF_FIRSTLAST:
			if( !GetDatabaseString( ci, "FirstName", &dbv )) {
				DBVARIANT dbv2;
				if(!GetDatabaseString(ci,"LastName",&dbv2)) {
					ci->type = CNFT_ASCIIZ;
					if ( ci->dwFlag & CNF_UNICODE ) {
						size_t len = wcslen(dbv.pwszVal) + wcslen(dbv2.pwszVal) + 2;
						WCHAR* buf = ( WCHAR* )mir_alloc( sizeof( WCHAR )*len );
						if ( buf != NULL )
							wcscat( wcscat( wcscpy( buf, dbv.pwszVal ), L" " ), dbv2.pwszVal );
						ci->pszVal = ( TCHAR* )buf;
					}
					else {
						size_t len = strlen(dbv.pszVal) + strlen(dbv2.pszVal) + 2;
						char* buf = ( char* )mir_alloc( len );
						if ( buf != NULL )
							strcat( strcat( strcpy( buf, dbv.pszVal ), " " ), dbv2.pszVal );
						ci->pszVal = ( TCHAR* )buf;
					}
					DBFreeVariant( &dbv );
					DBFreeVariant( &dbv2 );
					return 0;
				}
				DBFreeVariant( &dbv );
			}
			break;

		case CNF_UNIQUEID:
		{
			char *uid = (char*)CallProtoService(ci->szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
			if ((INT_PTR)uid!=CALLSERVICE_NOTFOUND&&uid)
				if (!ProcessDatabaseValueDefault(ci,uid))
					return 0;

			break;
		}
		case CNF_DISPLAYUID:
		{
			if (!ProcessDatabaseValueDefault(ci, "display_uid"))
				return 0;
			char *uid = (char*)CallProtoService(ci->szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
			if ((INT_PTR)uid!=CALLSERVICE_NOTFOUND&&uid)
				if (!ProcessDatabaseValueDefault(ci,uid))
					return 0;

			break;
		}
		case CNF_DISPLAYNC:
		case CNF_DISPLAY:
		{
			int i;
			for( i=0; i < NAMEORDERCOUNT; i++ ) {
				switch(nameOrder[i])  {
					case 0: // custom name
					{
						// make sure we aren't in CNF_DISPLAYNC mode
						// don't get custom name for NULL contact
						char* saveProto = ci->szProto; ci->szProto = "CList";
						if (ci->hContact!=NULL && (ci->dwFlag&0x7F)==CNF_DISPLAY && !ProcessDatabaseValueDefault(ci,"MyHandle")) {
							ci->szProto = saveProto;
							return 0;
						}
						ci->szProto = saveProto;
						break;
					}
					case 1:
						if ( !ProcessDatabaseValueDefault( ci, "Nick" )) // nick
							return 0;
						break;
					case 2:
						if ( !ProcessDatabaseValueDefault( ci, "FirstName" )) // First Name
							return 0;
						break;
					case 3:
						if ( !ProcessDatabaseValueDefault( ci, "e-mail" )) // E-mail
							return 0;
						break;
					case 4:
						if ( !ProcessDatabaseValueDefault( ci, "LastName" )) // Last Name
							return 0;
						break;
					case 5: // Unique id
					{
						// protocol must define a PFLAG_UNIQUEIDSETTING
						char *uid = (char*)CallProtoService(ci->szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0);
						if ((INT_PTR)uid!=CALLSERVICE_NOTFOUND&&uid) {
							if (!GetDatabaseString(ci,uid,&dbv)) {
								if ( dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD ) {
									long value = (dbv.type == DBVT_BYTE) ? dbv.bVal:(dbv.type==DBVT_WORD ? dbv.wVal : dbv.dVal);
									if ( ci->dwFlag & CNF_UNICODE ) {
										WCHAR buf[ 40 ];
										_ltow( value, buf, 10 );
										ci->pszVal = ( TCHAR* )mir_wstrdup( buf );
									}
									else {
										char buf[ 40 ];
										_ltoa( value, buf, 10 );
										ci->pszVal = ( TCHAR* )mir_strdup(buf);
									}
									ci->type = CNFT_ASCIIZ;
									return 0;
								}
								if (dbv.type == DBVT_ASCIIZ && !(ci->dwFlag & CNF_UNICODE)) {
									ci->type = CNFT_ASCIIZ;
									ci->pszVal = dbv.ptszVal;
									return 0;
								}
								if (dbv.type == DBVT_WCHAR && (ci->dwFlag & CNF_UNICODE)) {
								  ci->type = CNFT_ASCIIZ;
								  ci->pszVal = dbv.ptszVal;
								  return 0;
						}	}	}
						break;
					}
					case 6: // first + last name
						if(!GetDatabaseString(ci,"FirstName",&dbv)) {
							DBVARIANT dbv2;
							if(!GetDatabaseString(ci,"LastName",&dbv2)) {
								ci->type = CNFT_ASCIIZ;

								if ( ci->dwFlag & CNF_UNICODE ) {
									size_t len = wcslen(dbv.pwszVal) + wcslen(dbv2.pwszVal) + 2;
									WCHAR* buf = ( WCHAR* )mir_alloc( sizeof( WCHAR )*len );
									if ( buf != NULL )
										wcscat( wcscat( wcscpy( buf, dbv.pwszVal ), L" " ), dbv2.pwszVal );
									ci->pszVal = ( TCHAR* )buf;
								}
								else {
									size_t len = strlen(dbv.pszVal) + strlen(dbv2.pszVal) + 2;
									char* buf = ( char* )mir_alloc( len );
									if ( buf != NULL )
										strcat( strcat( strcpy( buf, dbv.pszVal ), " " ), dbv2.pszVal );
									ci->pszVal = ( TCHAR* )buf;
								}

								DBFreeVariant( &dbv );
								DBFreeVariant( &dbv2 );
								return 0;
							}
							DBFreeVariant( &dbv );
						}
						break;

					case 7:
						if ( ci->dwFlag & CNF_UNICODE )
							ci->pszVal = ( TCHAR* )mir_wstrdup( TranslateW( L"'(Unknown Contact)'" ));
						else
							ci->pszVal = ( TCHAR* )mir_strdup( Translate("'(Unknown Contact)'"));
						ci->type = CNFT_ASCIIZ;
						return 0;
			}	}	}
			break;

		case CNF_TIMEZONE: {
			HANDLE hTz = tmi.createByContact(ci->hContact, TZF_KNOWNONLY);
			if (hTz)
			{
				LPTIME_ZONE_INFORMATION tzi = tmi.getTzi(hTz);
				int offset = tzi->Bias + tzi->StandardBias;

				char str[80];
				mir_snprintf(str, SIZEOF(str), offset ? "UTC%+d:%02d" : "UTC", offset / -60, abs(offset % 60));
				ci->pszVal = ci->dwFlag & CNF_UNICODE ? (TCHAR*)mir_a2u(str) : (TCHAR*)mir_strdup(str);
				ci->type = CNFT_ASCIIZ;
				return 0;
			}
			break;
		}
		case CNF_MYNOTES: {
			char* saveProto = ci->szProto; ci->szProto = "UserInfo";
			if (!ProcessDatabaseValueDefault(ci,"MyNotes")) {
				ci->szProto = saveProto;
				return 0;
			}
			ci->szProto = saveProto;
			break;
	}	}

	return 1;
}
Exemplo n.º 3
0
WCHAR* GetContactName(HANDLE hContact, const char *szProto, int unicode)
{
	int i, r = 0;
	static WCHAR res[512];
	char *proto = (char*)szProto;
	char name[256];

	if (hContact && !proto)
	if (GetValue(hContact, "Protocol", "p", name, SIZEOF(name)))
		proto = name;

	if (proto) {
		for (i = 0; i < NAMEORDERCOUNT - 1; i++) {
			switch (nameOrder[i]) {
			case 0: // custom name
				r = GetDatabaseString(hContact, "CList", "MyHandle", res, SIZEOF(res), unicode);
				break;

			case 1: // nick
				r = GetDatabaseString(hContact, proto, "Nick", res, SIZEOF(res), unicode);
				break;

			case 2: // First Name
				r = GetDatabaseString(hContact, proto, "FirstName", res, SIZEOF(res), unicode);
				break;

			case 3: // E-mail
				r = GetDatabaseString(hContact, proto, "e-mail", res, SIZEOF(res), unicode);
				break;

			case 4: // Last Name
				if (GetDatabaseString(hContact, proto, "LastName", res, SIZEOF(res), unicode))
					break;

			case 5: // Unique id
				{
					// protocol must define a PFLAG_UNIQUEIDSETTING
					char *uid = (char*)CallProtoService(proto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
					if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
						r = GetDatabaseString(hContact, proto, uid, res, SIZEOF(res), unicode);
				}
				break;
			case 6: // first + last name
				{
					int len = 0;

					if (r = GetDatabaseString(hContact, proto, "FirstName", res, SIZEOF(res), unicode)) {
						if (unicode)
							len = (int)wcslen(res);
						else
							len = (int)strlen((char*)res);
					}
					else
						res[0] = 0;

					if (len && len < SIZEOF(res) - 2) {
						if (unicode)
							wcscat(res, L" ");
						else
							strcat((char*)res, " ");

						len++;
					}

					if (SIZEOF(res) - len > 1)
						r |= GetDatabaseString(hContact, proto, "LastName", &res[len], SIZEOF(res) - len, unicode);

					break;
				}
			}

			if (r)
				return res;
		}
	}

	return (unicode) ? nick_unknownW : (WCHAR*)nick_unknown;
}
Exemplo n.º 4
0
BOOL CAddConnectionSD::OnInitDialog() 
{
	CDialog::OnInitDialog();
//
//  Set up pointers to the controls
//
  pComboBoxFROMNODE = (CComboBox *)GetDlgItem(ADDCONNECTIONSD_FROMNODE);
  pComboBoxTONODE = (CComboBox *)GetDlgItem(ADDCONNECTIONSD_TONODE);
  pEditDISTANCE = (CEdit *)GetDlgItem(ADDCONNECTIONSD_DISTANCE);
  pButtonALLROUTES = (CButton *)GetDlgItem(ADDCONNECTIONSD_ALLROUTES);
  pComboBoxROUTE = (CComboBox *)GetDlgItem(ADDCONNECTIONSD_ROUTE);
  pButtonALLSERVICES = (CButton *)GetDlgItem(ADDCONNECTIONSD_ALLSERVICES);
  pComboBoxSERVICE = (CComboBox *)GetDlgItem(ADDCONNECTIONSD_SERVICE);
  pButtonALLPATTERNS = (CButton *)GetDlgItem(ADDCONNECTIONSD_ALLPATTERNS);
  pComboBoxPATTERN = (CComboBox *)GetDlgItem(ADDCONNECTIONSD_PATTERN);
  pButtonRUNNINGTIME = (CButton *)GetDlgItem(ADDCONNECTIONSD_RUNNINGTIME);
  pButtonTRAVELTIME = (CButton *)GetDlgItem(ADDCONNECTIONSD_TRAVELTIME);
  pButtonDEADHEADTIME = (CButton *)GetDlgItem(ADDCONNECTIONSD_DEADHEADTIME);
  pButtonONEWAY = (CButton *)GetDlgItem(ADDCONNECTIONSD_ONEWAY);
  pButtonTWOWAY = (CButton *)GetDlgItem(ADDCONNECTIONSD_TWOWAY);
  pSDIGridGRID = (CSDIGrid *)GetDlgItem(ADDCONNECTIONSD_GRID);
  pButtonROUNDUP = (CButton *)GetDlgItem(ADDCONNECTIONSD_ROUNDUP);
  pButtonROUNDDOWN = (CButton *)GetDlgItem(ADDCONNECTIONSD_ROUNDDOWN);
  pButtonHALFMINUTES = (CButton *)GetDlgItem(ADDCONNECTIONSD_HALFMINUTES);
  pButtonFULLMINUTES = (CButton *)GetDlgItem(ADDCONNECTIONSD_FULLMINUTES);
  pButtonIDCALCULATE = (CButton *)GetDlgItem(IDCALCULATE);
//
//  There has to be at least one entry in the Routes Table
//
  int numRoutes = SetUpRouteList(m_hWnd, ADDCONNECTIONSD_ROUTE, NO_RECORD);

  if(numRoutes == 0)
  {
    TMSError(m_hWnd, MB_ICONSTOP, ERROR_008, (HANDLE)NULL);
    OnCancel();
    return(TRUE);
  }
//
//  There has to be at least one entry in the Services Table
//
  int numServices = SetUpServiceList(m_hWnd, ADDCONNECTIONSD_SERVICE, NO_RECORD);

  if(numServices == 0)
  {
    TMSError(m_hWnd, MB_ICONSTOP, ERROR_007, (HANDLE)NULL);
    OnCancel();
    return(TRUE);
  }
//
//  There has to be at least one entry in the Nodes Table
//
  int rcode2 = btrieve(B_GETFIRST, TMS_NODES, &NODES, &NODESKey2, 2);

  if(rcode2 != 0)
  {
    TMSError(m_hWnd, MB_ICONSTOP, ERROR_024, (HANDLE)NULL);
    OnCancel();
    return(TRUE);
  }
//
//  There were nodes.  Populate the from and to node combo boxes
//
  CString s;
  int     nI;

  while(rcode2 == 0)
  {
    if(!(NODES.flags & NODES_FLAG_STOP))
    {
      s = GetDatabaseString(NODES.abbrName, NODES_ABBRNAME_LENGTH);
      nI = pComboBoxFROMNODE->AddString(s);
      pComboBoxFROMNODE->SetItemData(nI, NODES.recordID);
      nI = pComboBoxTONODE->AddString(s);
      pComboBoxTONODE->SetItemData(nI, NODES.recordID);
    }
    rcode2 = btrieve(B_GETNEXT, TMS_NODES, &NODES, &NODESKey2, 2);
  }
//
//  Route
//
  for(nI = 0; nI < numRoutes; nI++)
  {
    if((long)pComboBoxROUTE->GetItemData(nI) == m_pAddConnectionSDData->pDI->fileInfo.routeRecordID)
    {
      pComboBoxROUTE->SetCurSel(nI);
      break;
    }
  }
//
//  Service
//
  for(nI = 0; nI < numServices; nI++)
  {
    if((long)pComboBoxSERVICE->GetItemData(nI) == m_pAddConnectionSDData->pDI->fileInfo.serviceRecordID)
    {
      pComboBoxSERVICE->SetCurSel(nI);
      break;
    }
  }
//
//  Pattern
//
  pButtonALLPATTERNS->SetCheck(TRUE);
  pComboBoxPATTERN->EnableWindow(FALSE);
//
//  1 or 2 way
//
  pButtonONEWAY->SetCheck(TRUE);
//
//  Running, Travel, and Deadhead Time checkboxes
//
  pButtonRUNNINGTIME->SetCheck(TRUE);
  pButtonTRAVELTIME->SetCheck(FALSE);
  pButtonDEADHEADTIME->SetCheck(FALSE);
//
//  Round up/down
//
  pButtonROUNDUP->SetCheck(TRUE);
  pButtonROUNDDOWN->SetCheck(FALSE);
//
//  Full/half minutes
//
  pButtonHALFMINUTES->SetCheck(FALSE);
  pButtonFULLMINUTES->SetCheck(TRUE);
//
//  Set up the DataGrid
//
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Exemplo n.º 5
0
BOOL CAddBustype::OnInitDialog() 
{
  BOOL   bFound;
  int    numComments;
  int    nI;

  CString s;
  CString fmt;

	CDialog::OnInitDialog();
//
//  Set up the pointers to the controls
//
  pEditNUMBER = (CEdit *)GetDlgItem(ADDBUSTYPE_NUMBER);
  pEditFLEETNAME = (CEdit *)GetDlgItem(ADDBUSTYPE_FLEETNAME);
  pEditNAME = (CEdit *)GetDlgItem(ADDBUSTYPE_NAME);
  pButtonACCESSIBLE = (CButton *)GetDlgItem(ADDBUSTYPE_ACCESSIBLE);
  pButtonCARRIER = (CButton *)GetDlgItem(ADDBUSTYPE_CARRIER);
  pButtonSURFACE = (CButton *)GetDlgItem(ADDBUSTYPE_SURFACE);
  pButtonRAIL = (CButton *)GetDlgItem(ADDBUSTYPE_RAIL);
  pButtonCAPACITY = (CButton *)GetDlgItem(ADDBUSTYPE_CAPACITY);
  pEditSEAT = (CEdit *)GetDlgItem(ADDBUSTYPE_SEAT);
  pEditSTAND = (CEdit *)GetDlgItem(ADDBUSTYPE_STAND);
  pButtonNA = (CButton *)GetDlgItem(ADDBUSTYPE_NA);
  pButtonCC = (CButton *)GetDlgItem(ADDBUSTYPE_CC);
  pComboBoxCOMMENTCODE = (CComboBox *)GetDlgItem(ADDBUSTYPE_COMMENTCODE);
//
//  Comment codes combo box
//
  numComments = SetUpCommentList(m_hWnd, ADDBUSTYPE_COMMENTCODE);
  if(numComments == 0)
  {
    pButtonCC->EnableWindow(FALSE);
    pComboBoxCOMMENTCODE->EnableWindow(FALSE);
  }
//
//  Are we updating or not?
//
  if(*m_pUpdateRecordID == NO_RECORD)
  {
    pButtonNA->SetCheck(TRUE);
    pEditNUMBER->SetWindowText("");
  }
//
//  Yes - Get the record
//
  else
  {
    BUSTYPESKey0.recordID = *m_pUpdateRecordID;
    btrieve(B_GETEQUAL, TMS_BUSTYPES, &BUSTYPES, &BUSTYPESKey0, 0);
//
//  Number
//
    s.Format("%ld", BUSTYPES.number);
    pEditNUMBER->SetWindowText(s);
//
//  Name
//
    s = GetDatabaseString(BUSTYPES.name, BUSTYPES_NAME_LENGTH);
    pEditNAME->SetWindowText(s);
//
//  Fleet name
//
    s = GetDatabaseString(BUSTYPES.fleetName, BUSTYPES_FLEETNAME_LENGTH);
    pEditFLEETNAME->SetWindowText(s);
//
//  Capacity
//
    fmt.LoadString(TEXT_240);
    s.Format(fmt, BUSTYPES.capacitySeated + BUSTYPES.capacityStanding);
    pButtonCAPACITY->SetWindowText(s);
//
//  Seated
//
    s.Format("%ld", BUSTYPES.capacitySeated);
    pEditSEAT->SetWindowText(s);
//
//  Standing
//
    s.Format("%ld", BUSTYPES.capacityStanding);
    pEditSTAND->SetWindowText(s);
//
//  Accessible
//
    if(BUSTYPES.flags & BUSTYPES_FLAG_ACCESSIBLE)
      pButtonACCESSIBLE->SetCheck(TRUE);
//
//  Carrier equipped
//
    if(BUSTYPES.flags & BUSTYPES_FLAG_CARRIER)
      pButtonCARRIER->SetCheck(TRUE);
//
//  Surface vehicle
//
    if(BUSTYPES.flags & BUSTYPES_FLAG_SURFACE)
      pButtonSURFACE->SetCheck(TRUE);
//
//  Rail vehicle
//
    if(BUSTYPES.flags & BUSTYPES_FLAG_RAIL)
      pButtonRAIL->SetCheck(TRUE);
//
//  Comment
//
    if(BUSTYPES.COMMENTSrecordID == NO_RECORD)
      pButtonNA->SetCheck(TRUE);
    else
    {
      for(bFound = FALSE, nI = 0; nI < numComments; nI++)
      {
        if((long)pComboBoxCOMMENTCODE->GetItemData(nI) == BUSTYPES.COMMENTSrecordID)
        {
          pComboBoxCOMMENTCODE->SetCurSel(nI);
          bFound = TRUE;
          break;
        }
      }
      CButton* pb = (bFound ? pButtonCC : pButtonNA);
      pb->SetCheck(TRUE);
    }
  }

  m_bInit = FALSE;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}