FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse Button with EDIT_GET_BUTTON
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
xBrowse Button with EDIT_GET_BUTTON
Posted: Tue Sep 04, 2012 08:37 PM
To All

I have found a few examples on this forum and reviewing the sample TestxBrw.prg I can create a button within xBrowse .. however, two things ..

1) How do I size the Button and put a caption on the button
2) Is it possible to use BTNBMP as my button choice ?

Here is my code :

Code (fw): Select all Collapse
// serial number

ADD oCol to oLbxB AT 8 HEADER 'Serial Num' size 75 
oLbxB:aCols[ 8 ]:nEditType  := EDIT_GET_BUTTON
oLbxB:aCols[ 8 ]:bEditBlock := {|row, col, oCol| MsgInfo("WRITE YOUR FUNCTIONALITY HERE") }


Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Wed Sep 05, 2012 12:22 AM
2) Is it possible to use BTNBMP as my button choice ?


We can specify a bitmap.
Use oCol:AddBitmap( cBitmap ) to add the bitmap to the column and assign the bitmap number as oCol:nBtnBmp

1) How do I size the Button and put a caption on the button

We can not directly specify the size of the button. But if a bitmap is specified, the size of the button is adjusted to accommodate the size if the bitmap
Regards



G. N. Rao.

Hyderabad, India
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Wed Sep 05, 2012 05:30 PM
Rao

Looking at some of the samples .. xBrowGrd.prg

Code (fw): Select all Collapse
WITH OBJECT oBrw:HireDate
      :AddBitmap( '\fwh\bitmaps\Alphabmp\task.bmp' )  // alpha
      :bBmpData   := { || 1 }
END


Is there a way to use a Bitmap from resource rather than from file ?

Thanks
Rick Lipkin
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Wed Sep 05, 2012 08:26 PM
Rao

Using your suggestion, I did not get the result I was looking for :-) It does not appear that the bitmap is being overlayed on the button ..

Code (fw): Select all Collapse
 // serial number

       ADD oCol to oLbxB AT 8 HEADER 'Serial Num' size 75
       oLbxB:aCols[ 8 ]:nEditType  := EDIT_GET_BUTTON
       oLbxB:aCols[ 8 ]:bEditBlock := {|row, col, oCol| MsgInfo("WRITE YOUR FUNCTIONALITY HERE") }
       oLbxB:aCols[ 8 ]:AddBitmap( cDefa+"\images\serial.bmp" )  // alpha
       oLbxB:aCols[ 8 ]:lBtnTransparent := .t.
       oLbxB:aCols[ 8 ]:nBtnBmp     := 1 // := { || 1 }




Thanks
Rick Lipkin
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Fri Sep 07, 2012 02:41 PM
To All

Just a quick follow up to see if there is a work around here to add a caption to the button and give it a size .. It appears that if you add a bitmap it does change the dimension of the button up to a point.

I do not really want to add a bitmap to the column just be able to size the button :-) and it would be great if a caption could be used as a label. :-)

Any workaround or xBrowse code modification would be VERY much appreciated!

Rick Lipkin
FWH1203



ps .. I noticed if I compiled xBrowse.prg .. I get this result :

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Fri Sep 07, 2012 03:55 PM
To All

Somewhere in these two xBrowse functions is my answer .. any Ideas ??

Rick Lipkin

Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

METHOD CreateButtons() CLASS TXBrwColumn

   local aColors

    if ::oBtnList != nil .and. ::oBtnElip != nil
        ::oBtnList:Hide()
        ::oBtnElip:Hide()
        return nil
    endif

   if ::oBrw:lCreated

      aColors := Eval( ::bClrHeader )

      if ::oBtnList != nil
         ::oBtnList:End()
      endif
      if ::oBtnElip != nil
         ::oBtnElip:End()
      endif

      @ 0,0 BTNBMP ::oBtnList RESOURCE "" OF ::oBrw NOBORDER SIZE 0,0
      ::oBtnList:hBitmap1 := FwDArrow()
      ::oBtnList:bAction := { || ::ShowBtnList() }
      ::oBtnList:SetFont( If( ValType( ::oDataFont ) == "B", Eval( ::oDataFont, Self ), ::oDataFont ) )
      ::oBtnList:SetColor( aColors[ 1 ], aColors[ 2 ] )

      @ 0,0 BTNBMP ::oBtnElip OF ::oBrw NOBORDER SIZE 0,0
      ::oBtnElip:cCaption := "..."
      ::oBtnElip:bAction := {|| ::RunBtnAction() }
      ::oBtnElip:SetFont( If( ValType( ::oDataFont ) == "B", Eval( ::oDataFont, Self ), ::oDataFont ) )
      ::oBtnElip:SetColor( aColors[ 1 ], aColors[ 2 ] )

         if ::nBtnBmp > 0 .and. !empty( ::aBitMaps )
            if ::nBtnBmp > len( ::aBitMaps )
               ::nBtnBmp := len( ::aBitMaps )
            endif
               ::ChangeBitMap( )
         endif

      ::oBtnList:Hide()
      ::oBtnElip:Hide()

   endif

return nil

//------------------------------------------------------------------------------

METHOD ChangeBitmap( ) CLASS TXBrwColumn // BtnGet

 *  msginfo( "ChangeBitmap")

   if ::nBtnBmp > 0 .and. len( ::aBitmaps ) >= ::nBtnBmp
      ::oBtnElip:hBitmap1 := ::aBitMaps[::nBtnBmp, BITMAP_HANDLE ]
      ::oBtnList:hBitmap1 := ::aBitMaps[::nBtnBmp, BITMAP_HANDLE ]
      ::oBtnElip:cCaption := ""
      else
   ::oBtnElip:hBitmap1 := 0
      ::oBtnList:hBitmap1 := 0
      ::oBtnElip:cCaption := "..."
  endif

  ::oBrw:refresh()

return nil
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Sat Sep 08, 2012 04:20 PM

Rick,

If you change this line:

::oBtnElip:cCaption := "label"

you should get a caption. Please try it.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Sat Sep 08, 2012 04:23 PM

And in this line its size can be changed:

::oBtnElip:Move( nButtonRow, nButtonCol, nBtnWidth + 1, nHeight, .f.)

If those changes are fine, then we can see how to set it from your app, instead of modifying the Class source code.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Sat Sep 08, 2012 05:05 PM
Antonio

YES .. your suggestions worked .. however, it appears that there is another line of code that continues to create the original button .. here are the changes I made to the xBrowse code :

Method PaintCell
Code (fw): Select all Collapse
 if nType == EDIT_LISTBOX .or. nType == EDIT_GET_LISTBOX
           ::oBtnElip:Hide()
           ::oBtnList:Move( nButtonRow, nButtonCol, nBtnWidth + 1, nHeight, .f.) // ButtonGet
           ::oBtnList:Show()
           ::oBtnList:GetDC()
           if ::lBtnTransparent
              ::oBtnList:SetColor( aColors[ 1 ],aColors[ 2 ] )
           else
              FillRect( hDC, {nButtonRow, nButtonCol, nButtonRow + nHeight , nButtonCol + nBtnWidth + 1 } ,;   // ButtonGet
                       ::oBtnList:oBrush:hBrush  )
           endif
           ::oBtnList:Paint()
           ::oBtnList:ReleaseDC()
         else
            ::oBtnList:Hide()
            *   ::oBtnElip:Move( nButtonRow, nButtonCol, nBtnWidth + 1, nHeight, .f.) // ButtonGet
            ::oBtnElip:Move( nButtonRow, nButtonCol-60, nBtnWidth + 40, nHeight, .f.) // Ricks changes
            ::oBtnElip:Show()
            ::oBtnElip:GetDC()
           if ::lBtnTransparent
              ::oBtnElip:SetColor( aColors[ 1 ],aColors[ 2 ] )
           else
              FillRect( hDC, {nButtonRow, nButtonCol, nButtonRow + nHeight , nButtonCol + nBtnWidth + 1 },; // ButtonGet
                      ::oBtnElip:oBrush:hBrush )
           endif
            ::oBtnElip:Paint()
            ::oBtnElip:ReleaseDC()
         endif


Method CreateButtons and ChangeBitmap
Code (fw): Select all Collapse
//----------------------------------------------------------------------------//

METHOD CreateButtons() CLASS TXBrwColumn

   local aColors

    if ::oBtnList != nil .and. ::oBtnElip != nil
        ::oBtnList:Hide()
        ::oBtnElip:Hide()
        return nil
    endif

   if ::oBrw:lCreated

      aColors := Eval( ::bClrHeader )

      if ::oBtnList != nil
         ::oBtnList:End()
      endif
      if ::oBtnElip != nil
         ::oBtnElip:End()
      endif

      @ 0,0 BTNBMP ::oBtnList RESOURCE "" OF ::oBrw NOBORDER SIZE 0,0
      ::oBtnList:hBitmap1 := FwDArrow()
      ::oBtnList:bAction := { || ::ShowBtnList() }
      ::oBtnList:SetFont( If( ValType( ::oDataFont ) == "B", Eval( ::oDataFont, Self ), ::oDataFont ) )
      ::oBtnList:SetColor( aColors[ 1 ], aColors[ 2 ] )

      @ 0,0 BTNBMP ::oBtnElip OF ::oBrw NOBORDER SIZE 0,0
     * ::oBtnElip:cCaption := "..."
      ::oBtnElip:cCaption := "Label"     // antonio change
      ::oBtnElip:bAction := {|| ::RunBtnAction() }
      ::oBtnElip:SetFont( If( ValType( ::oDataFont ) == "B", Eval( ::oDataFont, Self ), ::oDataFont ) )
      ::oBtnElip:SetColor( aColors[ 1 ], aColors[ 2 ] )

         if ::nBtnBmp > 0 .and. !empty( ::aBitMaps )
            if ::nBtnBmp > len( ::aBitMaps )
               ::nBtnBmp := len( ::aBitMaps )
            endif
               ::ChangeBitMap( )
         endif

      ::oBtnList:Hide()
      ::oBtnElip:Hide()

   endif

return nil

//------------------------------------------------------------------------------

METHOD ChangeBitmap( ) CLASS TXBrwColumn // BtnGet

   msginfo( "ChangeBitmap")

   if ::nBtnBmp > 0 .and. len( ::aBitmaps ) >= ::nBtnBmp
      ::oBtnElip:hBitmap1 := ::aBitMaps[::nBtnBmp, BITMAP_HANDLE ]
      ::oBtnList:hBitmap1 := ::aBitMaps[::nBtnBmp, BITMAP_HANDLE ]
      *  ::oBtnElip:cCaption := ""
      ::oBtnElip:cCaption := "label"     // antonio change
  else
      ::oBtnElip:hBitmap1 := 0
      ::oBtnList:hBitmap1 := 0
      *  ::oBtnElip:cCaption := "..."
      ::oBtnElip:cCaption := "label"     // antonio change
  endif

  ::oBrw:refresh()

return nil




Here is the same code adding the Bitmap ..
Code (fw): Select all Collapse
// serial number

       ADD oCol to oLbxB AT 8 HEADER 'Serial Num' size 75
       oLbxB:aCols[ 8 ]:nEditType  := EDIT_GET_BUTTON
       oLbxB:aCols[ 8 ]:bEditBlock := {|row, col, oCol| _SerBrow( nRepairNumber,;
                       oRsInvDetail:Fields("Inventory Id"):Value,;
                       oRsInvDetail:Fields("Qty"):Value,oRsInvDetail,;
                       oBtn1,oBtn2,oBtn3,oBtn4,oBtn5 ) }

       oLbxB:aCols[ 8 ]:addbmpfile( "c:\fwh1203\bitmaps\alphabmp\task.bmp" )
       oLbxB:aCols[ 8 ]:lBtnTransparent := .t.
       oLbxB:aCols[ 8 ]:nBtnBmp := 1




I sincerely appreciate your Help!
Rick Lipkin

ps .. I have been trying out different options .. Is it possible to modify my :addbmpfile line with something like oLbxB:aCols[8]:If( oRs:Fields("whatever"):Value = .t., addbmpfile( "c:\fwh1203\bitmaps\alphabmp\task.bmp" ,addbmpfile( "c:\fwh1203\bitmaps\alphabmp\task1.bmp")) .. ?
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Sat Sep 08, 2012 06:17 PM

Rick,

It looks as placed too much to the left. Please try to change the :Move( ... ) params to move it to the right

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Sat Sep 08, 2012 06:24 PM

Rick,

Please try this:

oLbxB:aCols[8]:addbmpfile( "c:\fwh1203\bitmaps\alphabmp\task.bmp" )
oLbxB:aCols[8]:addbmpfile( "c:\fwh1203\bitmaps\alphabmp\task1.bmp")
oLbxB:aCols[ 8 ]:bBmpData = { | lValue | If( lValue, 1, 2 ) }

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Sat Sep 08, 2012 07:30 PM
Antonio

YES .. the codeblock for the Addbmpfile worked great .. Have another look at my previous post .. It appears that there is still a ( small ) button being painted even though I modified the 'move' line.



Otherwise it LOOKS Great!

Thanks
Rick
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Sun Sep 09, 2012 02:53 PM

Rick,

Can you click on each of them ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Mon Sep 10, 2012 01:01 PM

Antonio

The button with "Label" works .. the small button on the right does not .. might be the FillRect or WndBoxRaised ?

Thanks
Rick Lipkin

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: xBrowse Button with EDIT_GET_BUTTON
Posted: Wed Sep 12, 2012 02:12 PM
Antonio

I think I can live with the 'default' xBrowse button .. I am using bitmaps from file ( as you suggested ) to visually project whether there is data behind the button or not... and I like that, however all my bitmaps are stored as resources and I would prefer not to distribute the individual bitmaps ..

Is there another option to add bitmaps other than from a file ? .. here is my code that produced the screenshot below ?

Thanks
Rick Lipkin

Code (fw): Select all Collapse
// serial number

       ADD oCol to oLbxB AT 8 HEADER 'Serial Num' size 60
       oLbxB:aCols[ 8 ]:nEditType  := EDIT_GET_BUTTON
       oLbxB:aCols[ 8 ]:bEditBlock := {|row, col, oCol| oLbxB:GoLeftMost(),_SerBrow(;
                       nRepairNumber,;
                       oRsInvDetail:Fields("Inventory Id"):Value,;
                       oRsInvDetail:Fields("Qty"):Value,;
                       oRsInvDetail:Fields("Key"):Value,;
                       oRsInvDetail,;
                       oBtn1,oBtn2,oBtn3,oBtn4,oBtn5 ) }

       oLbxB:aCols[ 8 ]:addbmpfile( "c:\fwh1203\bitmaps\16x16\zoom2.bmp" )
       oLbxB:aCols[ 8 ]:addbmpfile( "c:\fwh1203\bitmaps\16x16\adddbf.bmp" )
       oLbxB:aCols[ 8 ]:bBmpData := { | lValue | If( oRsInvDetail:Fields("IsSerial"):Value = .t., 1, 2 ) }
       oLbxB:aCols[ 8 ]:lBtnTransparent := .t.