LPTSTR StripTrailer( LPTSTR pszStr, TCHAR cChar ) /************************************************************************/ { if( !pszStr ) return( NULL ); int len = MBStrlen( pszStr ); // find end of string LPTSTR psz = pszStr; while( *( MyCharNext( psz ))) psz = MyCharNext( psz ); while( len-- > 0 ) { BOOL fDBCS = IsDBCSLeadByte(( BYTE )*psz ); // if no match, quit if(( fDBCS && ( *(( LPWORD )psz )) != cChar ) || ( *psz != cChar )) break; psz = MyCharPrev( pszStr, psz ); // points to prev character in string. *( MyCharNext( psz )) = _T('\0'); // terminate string where match is found. } return( pszStr ); }
LPTSTR MyCharNextN( LPTSTR pszStr, UINT uPos ) // returns a pointer to the Nth + 1 multibyte character in a string. // uPos is treated as an array index where uPos == 1 returns a pointer to // the second multi-byte character in the string. /***********************************************************************/ { if( !pszStr || ( MBStrlen( pszStr ) < uPos )) return 0; for( int i = 0; i < uPos; i++ ) pszStr = MyCharNext( pszStr ); return( pszStr ); }
LFIXED AstralGetDlgItemFixed( HWND hDlg, int idDlg, BOOL FAR *lpTranslated, BOOL bNoConvert ) { LFIXED Fixed; double d; long picas, points; int units; TCHAR szFixed[32]; LPTSTR psz; *lpTranslated = TRUE; if ( bNoConvert ) units = UT_INCHES; else units = Units; GetDlgItemText( hDlg, idDlg, szFixed, sizeof(szFixed) ); if (!isValidFixed(szFixed)) { *lpTranslated = FALSE; return((LFIXED)0); } switch ( units ) { case UT_MM: Fixed = AsciiFixed( szFixed ); d = DOUBLE(Fixed) / (double)25.4; Fixed = DBL2FIX(d); break; case UT_CM: Fixed = AsciiFixed( szFixed ); d = DOUBLE(Fixed) / (double)2.54; Fixed = DBL2FIX(d); break; case UT_PICAS: if( MBStrchr( szFixed, '.' )) { Fixed = AsciiFixed(szFixed); d = DOUBLE(Fixed) * (double)12.0; if (Points != 0) d = 10.0 * (d / (double)Points); Fixed = DBL2FIX(d); } else { psz = MBStrchr( szFixed, ',' ); points = 0; if( psz ) { *psz = '\0'; psz++; if( MBStrlen( psz )) { points = atol( psz ); } } picas = atol(szFixed); points += 12 * picas; d = ((double)points / (double)Points) * 10.0; Fixed = DBL2FIX(d); } break; case UT_PIXELS: Fixed = AsciiFixed( szFixed ); if (UnitRes != 0) d = DOUBLE(Fixed) / (double)UnitRes; Fixed = DBL2FIX(d); break; case UT_INCHES: default: Fixed = AsciiFixed(szFixed); break; } return( Fixed ); }