Bug in TBtnBmp [Solved]

Re: Bug in TBtnBmp

Postby Antonio Linares » Tue Aug 05, 2014 1: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Tue Aug 05, 2014 2: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
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Tue Aug 05, 2014 5: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Tue Aug 05, 2014 6:00 pm

Antonio,

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

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

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


Is it a clue?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Wed Aug 06, 2014 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Wed Aug 06, 2014 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Thu Aug 07, 2014 6:04 pm

Antonio,

the problem seems to be located here:

Code: Select all  Expand view  RUN
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
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Thu Aug 07, 2014 7: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Antonio Linares » Thu Aug 07, 2014 7:26 pm

Enrico,

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

Code: Select all  Expand view  RUN
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Thu Aug 07, 2014 9: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: Select all  Expand view  RUN
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
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Fri Aug 08, 2014 2: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Fri Aug 08, 2014 3: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
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Bug in TBtnBmp

Postby Antonio Linares » Sat Aug 09, 2014 6:31 pm

Enrico,

Now the caption also moves :-)

Code: Select all  Expand view  RUN
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
User avatar
Antonio Linares
Site Admin
 
Posts: 42125
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Bug in TBtnBmp

Postby Enrico Maria Giordano » Sat Aug 09, 2014 6:52 pm

Antonio,

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

Thank you! :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8719
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Previous

Return to Bugs report & fixes / Informe de errores y arreglos

Who is online

Users browsing this forum: No registered users and 6 guests