Page 6 of 6

Re: Bug in TBtnBmp

PostPosted: Tue Aug 05, 2014 1:53 pm
by Antonio Linares
Enrico,

I sent you several modified Class TBtnBmp, maybe you are still linking one of them ?

Re: Bug in TBtnBmp

PostPosted: Tue Aug 05, 2014 2:57 pm
by Enrico Maria Giordano
Antonio,

no, I'm using clean latest FWH. Can you try using the downloaded FWH package? Maybe you have changed something in the last minute?

EMG

Re: Bug in TBtnBmp

PostPosted: Tue Aug 05, 2014 5:04 pm
by Antonio Linares
Enrico,

I just downloaded FWH 14.07, went to samples folder, did a buildh btn, and the EXE is working fine.

Really strange. Could you test it on another computer ?

Re: Bug in TBtnBmp

PostPosted: Tue Aug 05, 2014 6:00 pm
by Enrico Maria Giordano
Antonio,

the raised effect doesn't go away if I comment out this refresh:

Code: Select all  Expand view
METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TBtnBmp

   if ! ::lMOver
      ::lMOver = .T.
//      ::Refresh()
   endif
 


Is it a clue?

EMG

Re: Bug in TBtnBmp

PostPosted: Wed Aug 06, 2014 6:20 am
by Antonio Linares
Enrico,

Thats no a solution, as you are avoiding the repainting of the control.

Do you have virtualbox ? if you don't have another PC at hand, you may use one virtual and try it there.

Re: Bug in TBtnBmp

PostPosted: Wed Aug 06, 2014 8:04 am
by Enrico Maria Giordano
Antonio,

your EXE works fine here too so what's the point to test mine on another PC? Anyway, I just tried on my old XP machine: no change. :-(

EMG

Re: Bug in TBtnBmp

PostPosted: Thu Aug 07, 2014 6:04 pm
by Enrico Maria Giordano
Antonio,

the problem seems to be located here:

Code: Select all  Expand view
METHOD PaintBorder() CLASS TBtnBmp

   local nAdjustBorder := 0

   if ::l2007 .or. ::l2010
      nAdjustBorder = If( ::lBorder, If( ::lBarBtn, 0, 3 ), 0 )
   endif

   if ::lMOver .and. ::lBoxSelect
      if ! ::lRound .and. ! ::lEllipse
         if ::l2007 .or. ::l2010
            WndBox2007( ::hDC, nAdjustBorder, nAdjustBorder,;
                        ::nHeight - nAdjustBorder - 1, ::nWidth - nAdjustBorder - 1,;
                        nRGB( 221, 207, 155 ) )
         else
            if ! ::lPressed
               WndRaised( ::hWnd, ::hDC )
            else
               WndInset( ::hWnd, ::hDC )
            endif      
         endif                    
      else
         if ::lEllipse
            ::DrawEllipse( ::hDC, nRGB( 221, 207, 155 ), 2 )
         else
            if ::lRound
               RoundBox( ::hDC, 2, 2, ::nWidth - 3, ::nHeight - 3, 6, 6,;
                         nRGB( 221, 207, 155 ) )
            else            
               if ! ::lPressed
                  WndRaised( ::hWnd, ::hDC )
               else
                  WndInset( ::hWnd, ::hDC )
               endif      
            endif


As you can see, in the case of ::lRound = .T. (that is the default) we don't have a raised border. With NOROUND clause it works fine.

EMG

Re: Bug in TBtnBmp

PostPosted: Thu Aug 07, 2014 7:10 pm
by Antonio Linares
Enrico,

ok, thats what I told you: thst only using NOROUND was working fine.

Now the question is: why lRound is set to .T. by default ?

Try to set it .F. by default and then it should work fine.

Re: Bug in TBtnBmp

PostPosted: Thu Aug 07, 2014 7:26 pm
by Antonio Linares
Enrico,

Please place this MsgBeep() calls that I used here:

Code: Select all  Expand view
METHOD PaintBorder() CLASS TBtnBmp

   local nAdjustBorder := 0

   if ::l2007 .or. ::l2010
      nAdjustBorder = If( ::lBorder, If( ::lBarBtn, 0, 3 ), 0 )
   endif

   if ::lMOver .and. ::lBoxSelect
      if ! ::lRound .and. ! ::lEllipse
         if ::l2007 .or. ::l2010
            WndBox2007( ::hDC, nAdjustBorder, nAdjustBorder,;
                        ::nHeight - nAdjustBorder - 1, ::nWidth - nAdjustBorder - 1,;
                        nRGB( 221, 207, 155 ) )
         else
            MsgBeep()
            if ! ::lPressed
               WndRaised( ::hWnd, ::hDC )
            else
               WndInset( ::hWnd, ::hDC )
            endif      
         endif                    
      else
         if ::lEllipse
            ::DrawEllipse( ::hDC, nRGB( 221, 207, 155 ), 2 )
         else
            if ::lRound
               RoundBox( ::hDC, 2, 2, ::nWidth - 3, ::nHeight - 3, 6, 6,;
                         nRGB( 221, 207, 155 ) )
            else      
               if ! ::lPressed
                  WndRaised( ::hWnd, ::hDC )
               else
                  WndInset( ::hWnd, ::hDC )
               endif      
            endif  
         endif
      endif
   else
      if ::lBorder
         MsgBeep()
         if ! ::lPressed
            if ! ( ::l2007 .or. ::l2010 )
               WndRaised( ::hWnd, ::hDC )
            endif
         else      
            WndInset( ::hWnd, ::hDC )
         endif  
      endif          
   endif

return nil


Here I hear a beep when the mouse comes over the button and again when the mouse goes away from the button. Please check if you get the same beeps, thanks

Re: Bug in TBtnBmp

PostPosted: Thu Aug 07, 2014 9:50 pm
by Enrico Maria Giordano
Antonio,

Antonio Linares wrote:Enrico,

ok, thats what I told you: thst only using NOROUND was working fine.

Now the question is: why lRound is set to .T. by default ?

Try to set it .F. by default and then it should work fine.


This prints .T. no matter how I set lRound (INIT and redefine method default). Why?

Code: Select all  Expand view
METHOD PaintBorder() CLASS TBtnBmp

   local nAdjustBorder := 0

   if ::l2007 .or. ::l2010
      nAdjustBorder = If( ::lBorder, If( ::lBarBtn, 0, 3 ), 0 )
   endif

   if ::lMOver .and. ::lBoxSelect
? ::lRound
      if ! ::lRound .and. ! ::lEllipse


EMG

Re: Bug in TBtnBmp

PostPosted: Fri Aug 08, 2014 2:15 pm
by Antonio Linares
Enrico,

Please help me to locate the error, I am very busy with EasyReport, sorry, thanks :-)

Re: Bug in TBtnBmp

PostPosted: Fri Aug 08, 2014 3:31 pm
by Enrico Maria Giordano
Antonio Linares wrote:Enrico,

Please help me to locate the error, I am very busy with EasyReport, sorry, thanks :-)


Ok. lRound is .T. because the REDEFINE BTNBMP command instructs so (NOROUND clause set lRound to .F.). Solved adding clause NOROUND. Now it seems to work fine.

There is one more difference, though: on click, the bitmap goes down but the prompt don't. Is this what you want?

EMG

Re: Bug in TBtnBmp

PostPosted: Sat Aug 09, 2014 6:31 pm
by Antonio Linares
Enrico,

Now the caption also moves :-)

Code: Select all  Expand view
METHOD PaintCaption() CLASS TBtnBmp

   local nStyle, nClr
   local hOldFont, aRect, lMultiline, cWord, cWord2
   local nOffset, nMaxWidth, nLine
   local nTxtTop := 0, nTxtLeft := 6, nTxtRight := ::nWidth - 6
   local nTxtHeight, nAdjust := 0
   local nLayOut := ::nLayOut

   if ::oPopup != nil
      nTxtRight -= 12
   endif

   if ! Empty( ::cCaption )

      if ::oFont == nil
         ::GetFont()
      endif

      lMultiLine = ! Empty( ::cCaption ) .and. CRLF $ ::cCaption

      if lMultiLine
         cWord = cStrWord( ::cCaption, nOffset, CRLF )

         while nOffset < Len( ::cCaption )
            nMaxWidth = Max( nMaxWidth,;
                             Len( cWord2 := cStrWord( ::cCaption, @nOffset, CRLF ) ) )
            if Len( cWord ) < nMaxWidth
              cWord = cWord2
            endif
         end

         nLine = MLCount( ::cCaption )
      else
         cWord = ::cCaption
      endif

      nStyle = nOr( If( ::nLayOut == 0, DT_CENTER, nLayOut ), DT_WORDBREAK ,;
                    If( ::nLayOut % 2 == 0, DT_VCENTER, DT_TOP ) )

      nClr = If( IsWindowEnabled( ::hWnd ), ::nClrText,;
                 If( ::lDisColor, CLR_HGRAY, ::nClrTextDis ) )

      SetTextColor( ::hDC, If( ValType( nClr ) == "B", Eval( nClr, ::lMOver ), nClr ) )
      SetBkMode( ::hDC, 1 )

      if ::oWnd:oFont != nil .or. ::oFont != nil
         hOldFont = SelectObject( ::hDC, ::oFont:hFont )
      endif

      aRect = { nTxtTop + nAdjust, nTxtLeft + nAdjust, ::nHeight + nAdjust - 4,;
                nTxtRight + nAdjust }
      lMultiLine = ( nTxtHeight := DrawText( ::hDC, ::cCaption, aRect,;
                     nOr( DT_WORDBREAK, DT_CALCRECT ) ) ) > ;
                     DrawText( ::hDC, ::cCaption, aRect, nOr( DT_SINGLELINE, DT_CALCRECT ) )

      if ::nLayOut == 1
         nStyle     = nOr( DT_CENTER, DT_WORDBREAK )
         aRect[ 1 ] = aRect[ 3 ] - nTxtHeight
      endif

      if ::nLayOut == 3
         aRect[ 1 ] = 2
      endif

      if ::lPressed
         aRect[ 1 ]++
         aRect[ 2 ]++
         aRect[ 3 ]++
         aRect[ 4 ]++
      endif  

      DrawText( ::hDC, ::cCaption, aRect, nStyle  )

      SelectObject( ::hDC, hOldFont )
   endif

return nil

Re: Bug in TBtnBmp

PostPosted: Sat Aug 09, 2014 6:52 pm
by Enrico Maria Giordano
Antonio,

great! Now btnbmp seems to work like the old version.

Thank you! :-)

EMG