Page 1 of 1

Bug in BT_DrawTextEx?

Posted: Wed May 25, 2016 5:08 am
by Rathinagiri
I found some weird behavior of DrawTextEx:

When a BT_DrawText is used before DrawTextEx with BT_Text_Center alignment, the alignment is carried over to the next BT_DrawTextEx even though we give BT_Text_Left

Consider this example:

Code: Select all

#include <hmg.ch>

Function Main
   define window x at 0, 0 width 400 height 300 main
      define button y
         row 10
         col 10
         caption 'Click me!'
         action drawtest()
      end button   
   end window
   x.center
   x.activate

Return


function drawtest
   local hBitMap, hDC, BTStruct
   hBitMap := BT_BitmapCreateNew ( 800, 600, { 255,255,255 } )
   hDC := BT_CreateDC ( hBitmap, BT_HDC_BITMAP, @BTstruct)
   // connent following line and see the difference!
   BT_DrawText (hDC, 10, 100, 'This is the text!', 'Arial', 12, { 0, 0, 0 }, { 255, 255, 255 }, BT_TEXT_OPAQUE, BT_TEXT_CENTER )
   BT_DrawRectangle (hDC, 100, 150, 200, 300, { 0, 0, 0 }, 2 )
   BT_DrawTextEx (hDC, 100, 150, 200, 300, 'This is the text!', 'Arial', 12, { 0, 0, 0 }, { 255, 255, 255 }, BT_TEXT_OPAQUE, BT_TEXT_LEFT )
   BT_DeleteDC( BTStruct )               
   BT_BitmapSaveFile ( hBitmap, 'new.bmp', BT_FILEFORMAT_BMP )
   BT_BitmapRelease ( hBitmap )
return nil
Try commenting the line and run.

Code: Select all

   BT_DrawText (hDC, 10, 100, 'This is the text!', 'Arial', 12, { 0, 0, 0 }, { 255, 255, 255 }, BT_TEXT_OPAQUE, BT_TEXT_CENTER )

Re: Bug in BT_DrawTextEx?

Posted: Wed May 25, 2016 1:03 pm
by srvet_claudio
I will check