Page 1 of 1

BTNBMP FWH1402 X FWH1408

PostPosted: Fri Sep 19, 2014 12:51 am
by Sistem
Antonio

BTNBMP muestra de manera diferente debido la versión FWH

@ 11, 138 BTNBMP OF oDlg SIZE 40, 15 PIXEL 2007 NOBORDER PROMPT " &Ok" FONT oFont LEFT RESOURCE "BMP_BTOK" ACTION (lOk:=.t., oDlg:End())
@ 179, 2 BTNBMP OF oDlg SIZE 180, 18 PIXEL 2007 NOBORDER PROMPT " SISTEM INFORMÁTICA " FONT oFont4 LEFT RESOURCE "BMP_INF2" ACTION SobreInfo2()

OK [FWH1402]
Image

NO OK [FWH1408]
Image

Re: BTNBMP FWH1402 X FWH1408

PostPosted: Fri Sep 19, 2014 12:57 am
by Antonio Linares
Vamos a revisarlo de inmediato, gracias

Re: BTNBMP FWH1402 X FWH1408

PostPosted: Fri Sep 19, 2014 1:49 pm
by Antonio Linares
Por favor modifica estos métodos con este código:

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

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

   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
         nTxtHeight = GetTextHeight( ::hWnd, ::hDC )
         nTxtTop    = ::nHeight / 2 - nTxtHeight / 2
         nMaxWidth  = GetTextWidth( 0, cWord, ::oFont:hFont )
         nTxtLeft   = ::nWidth / 2 - nMaxWidth / 2
         nTxtRight  = ::nWidth / 2 + nMaxWidth / 2
      endif

      if ::nLayOut == 1 // TOP
         nTxtLeft -= 3
      endif  

      if ::nLayout == 2 // LEFT
         nTxtLeft  += 5
         nTxtRight += nBmpWidth( ::hBmp ) / 2 - 5
      endif

      if ::nLayout == 4 // RIGHT
         nTxtLeft  -= nBmpWidth( ::hBmp ) / 2 - 5
         nTxtRight -= nBmpWidth( ::hBmp ) / 2 - 5
      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

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

      aRect = { nTxtTop, nTxtLeft, ::nHeight - 4, nTxtRight }

      lMultiLine = ( nTxtHeight := DrawText( ::hDC, ::cCaption, aRect,;
                     nOr( DT_WORDBREAK, DT_CALCRECT ) ) ) > ;
                     DrawText( ::hDC, ::cCaption, aRect, nOr( DT_SINGLELINE, DT_CALCRECT ) )

      if ::nLayOut == 1 // TOP
         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
 


Code: Select all  Expand view

METHOD PaintBitmap() CLASS TBtnBmp

   local hBmp  := ::hBmp
   local nTop  := ( ::nHeight / 2 ) - ( nBmpHeight( hBmp ) / 2 )
   local nLeft := ( ::nWidth / 2 ) - ( nBmpWidth( hBmp ) / 2 )

   if ::oFont != nil .and. ! Empty( ::cCaption ) .and. ::nLayOut == 2 // LEFT
      nLeft -= GetTextWidth( 0, ::cCaption, ::oFont:hFont ) / 2 - 5
   endif  

   if ! Empty( ::cCaption )
      nTop -= 10
   endif

   if ::oPopup != nil
      nLeft -= 6
   endif

   if ::nLayOut == 2 // LEFT
      nTop  += 10
      nLeft -= 10
   endif

   if ::nLayOut == 4 // RIGHT
      nTop  += 10
      nLeft += 35
   endif

   if ! Empty( hBmp )
      if ::lBmpTransparent
         if SetAlpha() .and. ::aAlpha[ ::nBtn ]
            ABPaint( ::hDC, nTop + If( ::lPressed, 1, 0 ),;
                     nLeft + If( ::lPressed, 1, 0 ), hBmp, ::nAlphaLevel() )
         else
            DrawTransBmp( ::hDC, hBmp, nTop + If( ::lPressed, 1, 0 ),;
                          nLeft + If( ::lPressed, 1, 0 ), nBmpWidth( hBmp ),;
                          nBmpHeight( hBmp ) )
         endif
      else
         DrawBitmap( ::hDC, hBmp, nTop + If( ::lPressed, 1, 0 ),;
                     nLeft + If( ::lPressed, 1, 0 ), nBmpWidth( hBmp ),;
                     nBmpHeight( hBmp ) )
      endif
   endif

return nil

 

Re: BTNBMP FWH1402 X FWH1408

PostPosted: Fri Sep 19, 2014 5:27 pm
by Sistem
ahora
esta bien

gracias