FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour BtnBmp and oPopup
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
BtnBmp and oPopup
Posted: Fri Jun 02, 2023 07:57 AM


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 (fw): Select all Collapse
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

//----------------------------------------------------------------------------//
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: BtnBmp and oPopup
Posted: Fri Jun 02, 2023 10:12 AM
Dear Otto,

thank you for sharing it :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: BtnBmp and oPopup
Posted: Wed Jun 07, 2023 08:36 AM
>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 (fw): Select all Collapse
data hBmpPop
on METHOD Paint() CLASS TBtnBmp
Code (fw): Select all Collapse
if ::oPopup != nil
 if ::hBmpPop != 0
        DrawBitmap( ::hDC, ::hBmpPop, aRect[1]+5, aRect[4]-15 )
            else
   ::PaintPopupSection()
endif
endif

instead of
Code (fw): Select all Collapse
 if ::oPopup != nil
      ::PaintPopupSection()
   endif

but before we must load ::hBmpPop on New method
Code (fw): Select all Collapse
::hBmpPop      := ::LoadBmp( cBtnPop )

See on my class TBtnClr how I made
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8523
Joined: Tue Dec 20, 2005 07:36 PM
Re: BtnBmp and oPopup
Posted: Wed Jun 07, 2023 12:18 PM

I agree with Silvio, it wasn't good.

Estoy de acuerdo con Silvio, no fue bueno.

Regards, saludos.

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
Posts: 6984
Joined: Fri Oct 07, 2005 07:07 PM
Re: BtnBmp and oPopup
Posted: Wed Jun 07, 2023 12:25 PM

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

Continue the discussion