Page 1 of 1

BtnBmp and oPopup

PostPosted: Fri Jun 02, 2023 7:57 am
by Otto
Image

Hello friends,

I have expanded the TBtnBmp.
Now, when I insert a PopupMenu, I can select the width of the clickable area and use a bitmap instead of the PolyPolygon.
Best regards,
Otto


Code: Select all  Expand view

METHOD PaintPopupSection() CLASS TBtnBmp

   local nWidth, nHeight, hDC
   local hBlackBrush, hOldBrush
   local hDarkPen, hLightPen, hOldPen
   
   
   if ::oPopup != nil
      nHeight = ::nHeight
      nWidth  = ::nWidth
      hDC     = ::hDC
     
     
      hBlackBrush = GetStockObject( 4 )  //4
      hOldBrush   = SelectObject( hDC, hBlackBrush )
   
      FW_DrawImage( hDC, "c:\fwh\bitmaps\alphabmp\ichat.bmp", {::nHeight-30, ::nWidth-25, ::nHeight - 10, ::nWidth-5}, .t. )
   
     
     /*
      PolyPolygon( hDC, { { nWidth - ::nWPop + If( ::lPressed, 1, 0 ),;
         nHeight / 2 - 1 + If( ::lPressed, 1, 0 ) },;
         { nWidth - 7 + If( ::lPressed, 1, 0 ), nHeight / 2 + 1 + ;
           If( ::lPressed, 1, 0 ) },;
         { nWidth - 5 + If( ::lPressed, 1, 0 ), nHeight / 2 - 1 + ;
           If( ::lPressed, 1, 0 ) },;
         { nWidth - ::nWPop + If( ::lPressed, 1, 0 ), nHeight / 2 - 1 + ;
           If( ::lPressed, 1, 0 ) } } )
*/




      if ::lBorder .or. ::lPressed .or. ::lMOver
         hDarkPen  = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNSHADOW ) )
         hLightPen = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_BTNHIGHLIGHT ) )
         hOldPen = SelectObject( hDC, hLightPen )
         MoveTo( hDC, nWidth - ( ::nWPop + 3 ) + If( ::lPressed, 1, 0 ), 1 )
         LineTo( hDC, nWidth - ( ::nWPop + 3 ) + If( ::lPressed, 1, 0 ), nHeight - 1 )
         SelectObject( hDC, hDarkPen )
         MoveTo( hDC, nWidth - ( ::nWPop + 4 ) + If( ::lPressed, 1, 0 ), 1 )
         LineTo( hDC, nWidth - ( ::nWPop + 4 ) + If( ::lPressed, 1, 0 ), nHeight - 1 )
         SelectObject( hDC, hOldPen )
         DeleteObject( hDarkPen )
         DeleteObject( hLightPen )
      endif

      SelectObject( hDC, hOldBrush )
      DeleteObject( hBlackBrush )
     
   endif

return nil

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


 

Re: BtnBmp and oPopup

PostPosted: Fri Jun 02, 2023 10:12 am
by Antonio Linares
Dear Otto,

thank you for sharing it :-)

Re: BtnBmp and oPopup

PostPosted: Wed Jun 07, 2023 8:36 am
by Silvio.Falconi
>FW_DrawImage( hDC, "c:\fwh\bitmaps\alphabmp\ichat.bmp", {::nHeight-30, ::nWidth-25, ::nHeight - 10, ::nWidth-5}, .t. )

for me it's no good

perhaps...

Code: Select all  Expand view
data hBmpPop


on METHOD Paint() CLASS TBtnBmp

Code: Select all  Expand view
if ::oPopup != nil
 if ::hBmpPop != 0
        DrawBitmap( ::hDC, ::hBmpPop, aRect[1]+5, aRect[4]-15 )
            else
   ::PaintPopupSection()
endif
endif



instead of

Code: Select all  Expand view
if ::oPopup != nil
      ::PaintPopupSection()
   endif



but before we must load ::hBmpPop on New method

Code: Select all  Expand view
::hBmpPop      := ::LoadBmp( cBtnPop )



See on my class TBtnClr how I made

Re: BtnBmp and oPopup

PostPosted: Wed Jun 07, 2023 12:18 pm
by karinha
I agree with Silvio, it wasn't good.

Estoy de acuerdo con Silvio, no fue bueno.

Regards, saludos.

Re: BtnBmp and oPopup

PostPosted: Wed Jun 07, 2023 12:25 pm
by Otto
Hello,
That was just a suggestion.
Here we need new data variables.

Then everyone can load the ICON they want.

Again, it should only serve as a suggestion to extend the class.

It's like comparing apples and oranges to modify a class for personal use or to make it universally applicable. I can only do the former.

Best regards,
Otto