FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Bugs report & fixes / Informe de errores y arreglos Bug in TBtnBmp [Solved]
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBtnBmp
Posted: Tue Aug 05, 2014 01:53 PM

Enrico,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBtnBmp
Posted: Tue Aug 05, 2014 02:57 PM

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

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBtnBmp
Posted: Tue Aug 05, 2014 05:04 PM

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 ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBtnBmp
Posted: Tue Aug 05, 2014 06:00 PM
Antonio,

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

Code (fw): Select all Collapse
METHOD MouseMove( nRow, nCol, nKeyFlags ) CLASS TBtnBmp

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


Is it a clue?

EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBtnBmp
Posted: Wed Aug 06, 2014 06:20 AM

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.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBtnBmp
Posted: Wed Aug 06, 2014 08:04 AM

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

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBtnBmp
Posted: Thu Aug 07, 2014 06:04 PM
Antonio,

the problem seems to be located here:

Code (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBtnBmp
Posted: Thu Aug 07, 2014 07:10 PM

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.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBtnBmp
Posted: Thu Aug 07, 2014 07:26 PM
Enrico,

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

Code (fw): Select all Collapse
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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBtnBmp
Posted: Thu Aug 07, 2014 09:50 PM
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 (fw): Select all Collapse
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBtnBmp
Posted: Fri Aug 08, 2014 02:15 PM

Enrico,

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBtnBmp
Posted: Fri Aug 08, 2014 03:31 PM
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Bug in TBtnBmp
Posted: Sat Aug 09, 2014 06:31 PM
Enrico,

Now the caption also moves :-)

Code (fw): Select all Collapse
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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Bug in TBtnBmp
Posted: Sat Aug 09, 2014 06:52 PM

Antonio,

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

Thank you! :-)

EMG

Continue the discussion