xBrowse Button with EDIT_GET_BUTTON

xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Tue Sep 04, 2012 8: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: Select all  Expand view

// 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") }
 


Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby nageswaragunupudi » 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
User avatar
nageswaragunupudi
 
Posts: 10632
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Wed Sep 05, 2012 5:30 pm

Rao

Looking at some of the samples .. xBrowGrd.prg

Code: Select all  Expand view

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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Wed Sep 05, 2012 8: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: Select all  Expand view

 // 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 } 
 


Image

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Fri Sep 07, 2012 2: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. :idea:

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

Rick Lipkin
FWH1203

Image

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

Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Fri Sep 07, 2012 3:55 pm

To All

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

Rick Lipkin

Code: Select all  Expand view

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

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
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Antonio Linares » Sat Sep 08, 2012 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Antonio Linares » Sat Sep 08, 2012 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Sat Sep 08, 2012 5: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: Select all  Expand view

 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: Select all  Expand view

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

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
 


Image

Here is the same code adding the Bitmap ..
Code: Select all  Expand view

// 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
 


Image

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")) .. ?
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Antonio Linares » Sat Sep 08, 2012 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Antonio Linares » Sat Sep 08, 2012 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Sat Sep 08, 2012 7: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.

Image

Otherwise it LOOKS Great!

Thanks
Rick
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Antonio Linares » Sun Sep 09, 2012 2:53 pm

Rick,

Can you click on each of them ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42089
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Mon Sep 10, 2012 1: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
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Button with EDIT_GET_BUTTON

Postby Rick Lipkin » Wed Sep 12, 2012 2: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: Select all  Expand view

// 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.
 


Image
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 89 guests