home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 20.ddi / MFC / SRC / VBFLOAT.CP_ / VBFLOAT.CP
Encoding:
Text File  |  1993-02-08  |  1.6 KB  |  58 lines

  1. // This is a part of the Microsoft Classes C++ Class Library.
  2. // Copyright (C) 1992 Microsoft Corporation,
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and Microsoft
  7. // QuickHelp and/or WinHelp documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. #include "stdafx.h"
  12. #include "vbctrl.h"
  13.  
  14. #ifdef AFX_VBX_SEG
  15. #pragma code_seg(AFX_VBX_SEG)
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19.  
  20. static int PASCAL _ConvertFontSizeToTwips(LONG lFontSize)
  21. {
  22.     float value = *(float*)&lFontSize;
  23.     return (int)((value * 20.0) + 0.5);
  24. }
  25.  
  26. static long PASCAL _ConvertTwipsToFontSize(int nTwips)
  27. {
  28.     float temp = ((float)nTwips) / 20;
  29.     return *(LONG*)&temp;
  30. }
  31.  
  32. void CVBControl::EnableVBXFloat()
  33. {
  34.     _afxConvertFontSizeToTwipsProc = _ConvertFontSizeToTwips;
  35.     _afxConvertTwipsToFontSizeProc = _ConvertTwipsToFontSize;
  36. }
  37.  
  38.  
  39. float CVBControl::GetFloatProperty(int nPropIndex, int index)
  40. {
  41.     if (_afxConvertFontSizeToTwipsProc == NULL)
  42.         EnableVBXFloat();
  43.  
  44.     LONG temp;
  45.     temp = GetNumPropertyWithType(nPropIndex, TYPE_REAL, index);
  46.     return *(float*)&temp;      // Do not do straight cast (float)
  47.                                 // as this would change the data format
  48. }
  49.  
  50. BOOL CVBControl::SetFloatProperty(int nPropIndex, float value, int index)
  51. {
  52.     if (_afxConvertFontSizeToTwipsProc == NULL)
  53.         EnableVBXFloat();
  54.     
  55.     return SetPropertyWithType(nPropIndex, TYPE_REAL, *(LONG*)&value, index);
  56. }
  57.  
  58.