home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / CONTRIB / TEXTOUTS.ZIP / TEXTOUTS.PRG
Text File  |  1994-05-24  |  2KB  |  52 lines

  1. // function.: TextOuts.prg
  2. // Author...: Gerald Barber
  3. // Date.....: November 28, 1993; Last Updated 05/24/94 09:27 pm
  4. // Notice...: Copyright 1993 - 1994, Gerald Barber
  5. // Notes....: Decimal, Right, Left, and Center Text Out
  6.  
  7. #include "align.ch"
  8.  
  9. #xtranslate GetInt( <f> ) => ;
  10.       if('.' $ <f>, substr( <f>, 1, at('.', <f>) - 1), <f> )
  11.  
  12. #xtranslate GetDec( <f> ) => ;
  13.       if('.' $ <f>, substr( <f>, at('.', <f>) + 1), "" )
  14.  
  15. function dTextOut(hDC, x, y, cText)
  16. local dWidth := C4W_LoWord( GetTextExtent(hDC,".",1) ) / 2
  17. local wFlags := SetTextAlign(hDC, C4W_OR(TA_RIGHT,TA_TOP))
  18. TextOut(hDC, x - dWidth, y, GetInt(cText))
  19. if ('.' $ cText)
  20.     SetTextAlign(hDC, C4W_OR(TA_CENTER,TA_TOP))
  21.     TextOut(hDC, x         , y, "."          )
  22.     SetTextAlign(hDC, C4W_OR(TA_LEFT,TA_TOP) )
  23.     TextOut(hDC, x + dWidth, y, GetDec(cText))
  24. endif
  25. SetTextAlign (hDC, wFlags)
  26. return .t.
  27.  
  28. function rTextOut(hDC, x, y, cText)
  29. local wFlags := SetTextAlign(hDC, C4W_OR(TA_RIGHT,TA_TOP))
  30. TextOut(hDC, x, y, cText)
  31. SetTextAlign (hDC, wFlags)
  32. return .t.
  33.  
  34. function lTextOut(hDC, x, y, cText)
  35. local wFlags := SetTextAlign(hDC, C4W_OR(TA_LEFT,TA_TOP))
  36. TextOut(hDC, x, y, cText)
  37. SetTextAlign (hDC, wFlags)
  38. return .t.
  39.  
  40. function cTextOut(hDC, x, y, cText)
  41. local wFlags := SetTextAlign(hDC, C4W_OR(TA_CENTER,TA_TOP))
  42. TextOut(hDC, x, y, cText)
  43. SetTextAlign (hDC, wFlags)
  44. return .t.
  45.  
  46. static function SetTextAlign(hDC, wFlag)
  47. local hLib := LoadLibrary("GDI.EXE")
  48. local cSTA := GetProcAddress(hLib,"SetTextAlign","Pascal","Word","hDC, int")
  49. local lTA  := CallDLL( cSTA, hDC, wFlag )
  50. FreeLibrary( hLib )
  51. return lTA
  52.