Ejemplo n.º 1
0
LFIXED GetFixedParm( LPTSTR pszCommand, int nParam, LPINT pbTranslated )
/***********************************************************************/
{
    TCHAR parm[20];
	WORD wChar;

    if( !( pszCommand = SkipParm( pszCommand, nParam )))
    {
	    if( pbTranslated )
		    *pbTranslated = FALSE;

	    return( 0 );
    }

    LPTSTR psz = parm;

    while( TRUE )
    {
		BOOL fDBCS = IsDBCSLeadByte(( BYTE )*pszCommand );

		if( fDBCS )
            wChar = *(( LPWORD )pszCommand );
        else
            wChar = *pszCommand;

		if( wChar == _T(' ') || wChar == _T('\0') ) 
			break;

		if( fDBCS )
			*(( LPWORD )psz ) = wChar;
		else
			*psz = *pszCommand;

    	psz = MyCharNext( psz ); pszCommand = MyCharNext( pszCommand );
    }
    *psz = _T('\0');

    if( pbTranslated )
	    *pbTranslated = TRUE;

    return( AsciiFixed( parm ));
}
Ejemplo n.º 2
0
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 );
}
Ejemplo n.º 3
0
LFIXED GetDlgItemSpinFixed(
	HWND  hWindow,
	int   idControl,
	LPINT lpTranslated,
	BOOL  bConvert)
{
	HWND hEditControl;
	HWND hSpinControl;
	LFIXED fMin, fMax, fValue, fNewValue;
	STRING szString;
	static BOOL bGetting = FALSE;

	fValue = 0L;

	if (!bGetting)
	{
		// Get the fixed value (translate into units if bConvert)
		fValue = AstralGetDlgItemFixed( hWindow, idControl, lpTranslated, !bConvert );
	}

	/* Get the handle to the control */
	if ( !(hEditControl = GetDlgItem( hWindow, idControl ) ) )
		return( fValue );

	if ( !(hSpinControl = GetWindow(hEditControl, GW_HWNDNEXT) ) )
		return( fValue );

	if ( GetDlgCtrlID(hSpinControl) != idControl )
		return( fValue );

	if (bGetting)
	{
		fValue = GetWindowLong( hSpinControl, GWL_FSPINVALUE );
		goto Exit;
	}

	fMin = GetWindowLong( hSpinControl, GWL_FSPINMIN );
	fMax = GetWindowLong( hSpinControl, GWL_FSPINMAX );

	if ( !fValue || !(*lpTranslated))
	{ // if zero from the control, check to see if it's empty (which is OK)
		GetDlgItemText(hWindow, idControl, szString, MAX_STR_LEN);
		if ( !lstrlen( szString ) )
			return( fMin ); // it's empty
		if ( szString[0] == '-' && szString[1] == '\0' )
			return( fMin ); // it's a minus sign

		fNewValue = AsciiFixed( szString );

		if (fNewValue < fMin) 
			fNewValue = fMin;

		if (fNewValue > fMax)
			fNewValue = fMax;
	}

	if (fValue < fMin)
		fNewValue = fMin;
	else if (fValue > fMax)
		fNewValue = fMax;
	else if (!(*lpTranslated))
		fNewValue = fValue; // != 0 so was partially translated
	else
	{
		SetWindowLong(hSpinControl, GWL_FSPINVALUE, fValue);
		return( fValue );
	}

	MessageBeep(0);

	SetWindowLong(hSpinControl, GWL_FSPINVALUE, fNewValue);

	bGetting = TRUE;

	// Set the edit control (translate into units if bConvert)
	AstralSetDlgItemFixed( hWindow, idControl, fNewValue, !bConvert );

	bGetting = FALSE;

Exit:
	return( fNewValue );
}