Beispiel #1
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 );
}
Beispiel #2
0
BOOL CUnitsPrefPage::OnCommand(WPARAM wParam, LPARAM lParam) 
{
	BOOL 	Bool;
	LPSTR 	lpUnit;
	HWND   	hActiveWnd = GetActiveDoc();
	HWND	hDlg = GetSafeHwnd();
	int 	id = GET_WM_COMMAND_ID(wParam, lParam);
	UINT 	codeNotify = GET_WM_COMMAND_CMD(wParam, lParam);

	switch (id)
	{
		case IDC_PREF_USERULERS:
			View.UseRulers = !View.UseRulers;
			::CheckDlgButton( hDlg, id, View.UseRulers );
			SetModified(TRUE);
		break;

		case IDC_PREF_DISPLAYPIXELS:
			Control.DisplayPixelValue = !Control.DisplayPixelValue;
			::CheckDlgButton( hDlg, id, !Control.DisplayPixelValue );
			SetModified(TRUE);
		break;

		case IDC_PREF_SCREENWIDTH:
			if ( ::GetFocus() != ::GetDlgItem( hDlg, id ) )
				break;
			if ( codeNotify != EN_CHANGE )
				break;
			Control.ScreenWidth = AstralGetDlgItemFixed( hDlg, id, &Bool, NO);
			SetModified(TRUE);
		break;

		case IDC_PREF_UNITS:
//		case IDC_PREF_UNITINCHES:
//		case IDC_PREF_UNITMM:
//		case IDC_PREF_UNITCM:
//		case IDC_PREF_UNITPICAS:
//		case IDC_PREF_UNITPIXELS:
			if ( !(id = HandleCombo( hDlg, id, codeNotify )) )
				break;
			Control.Units = id;
			SetUnitInfo((UNIT_TYPE)(Control.Units-IDC_PREF_UNITINCHES), Control.UnitRes, Control.Points);
			if ( AstralStr( Control.Units-IDC_PREF_UNITINCHES+IDS_INCHES,
	     		&lpUnit ) )
				::SetDlgItemText( hDlg, IDC_WIDTHLABEL, lpUnit );
			ControlEnable( hDlg, IDC_PREF_SCREENWIDTH,
				Control.Units != IDC_PREF_UNITPIXELS );

			if ( Control.Units != IDC_PREF_UNITPIXELS )
				AstralSetDlgItemFixed( hDlg, IDC_PREF_SCREENWIDTH, Control.ScreenWidth, NO );
			else
				::SetDlgItemInt( hDlg, IDC_PREF_SCREENWIDTH, GetSystemMetrics( SM_CXSCREEN ), NO );
			SetModified(TRUE);
		break;

	   	default:
			return (CPPPropertyPage::OnCommand(wParam, lParam));   	
		break;
   	}
	return(TRUE);
}