Page 1 of 1

Bad look btnbmp disable()

PostPosted: Wed Mar 01, 2023 1:27 pm
by Silvio.Falconi
I have some btnbmp with pngs
when are disabled I see a bad btnbmp
but I think is for png file

Image

Re: Bad look btnbmp disable()

PostPosted: Sun Mar 05, 2023 2:30 pm
by ukoenig
Silvio,
I cannot detect a problem,
png-images are working
--
I have some btnbmp with pngs
when are disabled I see a bad btnbmp
but I think is for png file

-----
just a question :
Because of changing the imagepath of some old posts of mine,
sometimes I cannot see the normal edit-buttons on top of the post
Sample -> I want to change :
http://www.pflegeplus.com/images/disable.png // old
to
http://www.service-fivewin.de/images/disable.png // new
maybe do You know why this happens ?

Image

Code: Select all  Expand view

@ 525, 570 BTNBMP oBtn[7] OF oDlg2 ;
SIZE 100, 45 PIXEL 2007 ; // B / H
PROMPT " &Exit " ;
ACTION oDlg2:End() ;
FONT oFont  ;
LEFT
oBtn[7]:LoadBitmaps( , , c_path1 + "Exit.png" )
oBtn[7]:SetImages(c_path1 + "Exit.png")
SetTextColor( oBtn[7]:hDC, 0 )
oBtn[7]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
    { { 0.5, 10526975, 16777215 }, ;
      { 0.5, 16777215, 10526975 } }, ;
    { { 0.5, 16768185 , 10526975 }, ;
       { 0.5, 10526975, 16768185 } } ) }
oBtn[7]:cToolTip =  { "Exit BORDER-tests","EXIT", 1, CLR_BLACK, 14089979 }
oBtn[7]:SetColor( 0, )

@ 525, 680 BTNBMP oBtn[8] OF oDlg2 ;
SIZE 100, 45 PIXEL 2007 ; // B / H
PROMPT " &Exit " ;
ACTION oDlg2:End() ;
FONT oFont  ;
LEFT
oBtn[8]:Disable()  // !!!
oBtn[8]:LoadBitmaps( , , c_path1 + "Exit.png" )
oBtn[8]:SetImages(c_path1 + "Exit.png")
SetTextColor( oBtn[8]:hDC, 0 )
oBtn[8]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
    { { 0.5, 10526975, 16777215 }, ;
      { 0.5, 16777215, 10526975 } }, ;
    { { 0.5, 16768185 , 10526975 }, ;
       { 0.5, 10526975, 16768185 } } ) }
oBtn[8]:cToolTip =  { "Exit BORDER-tests","EXIT", 1, CLR_BLACK, 14089979 }
oBtn[8]:SetColor( 0, )
 


best regards
Uwe :D

Re: Bad look btnbmp disable()

PostPosted: Mon Mar 06, 2023 9:26 am
by Antonio Linares
Silvio.Falconi wrote:I have some btnbmp with pngs
when are disabled I see a bad btnbmp
but I think is for png file

Image


Dear Silvio,

How does the png file look right ? Please post it here, thanks

Re: Bad look btnbmp disable()

PostPosted: Wed Mar 08, 2023 9:13 am
by Silvio.Falconi
Image


Image

Code: Select all  Expand view


#define DLG_nColorBtn1    RGB( 245,245,235)
#define DLG_nColorBtn2    RGB(250,250,245)
#define DLG_nColorBtnB    RGB(195,195,185)

Function sample()
   local oDlg,oBtn,oFont
   local nHt      := Int( ScreenHeight() * 0.2 )
   local nWd      := Int( ScreenWidth() * 0.2 )

   local lNormal :=.f.
   local nClrBorder := RGB(243,243,238)
   local oChk
   local oGet,cGet:= space(100)
   local oSay[1]

 DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
 DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
       RESIZABLE   TiTle "test" COLOR CLR_BLACK, RGB( 245,245,235)  ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX, WS_THICKFRAME )

       @ 10,10 CheckBox oChk Var lNormal  Prompt "check" SIZE 100,20 of oDlg ;
       on change ( If(lNormal,(oBtn:Enable(), oGet:enable()),;
                              (oBtn:Disable(), oGet:disable())),;
                               oBtn:refresh(), oGet:refresh() )

          @ 10, 10 BTNBMP oBtn   ;
                   FILENAME "test.png" ;
                   FLAT SIZE 50,50  OF oDlg   PIXEL  ;
                   NOROUND   action msginfo()

                oBtn:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 0.25, DLG_nColorBtn1, DLG_nColorBtn2 },;
                      { 0.75, DLG_nColorBtn2, DLG_nColorBtn1 } },;
                    { { 0.25, DLG_nColorBtn2, DLG_nColorBtn1 }, ;
                      { 0.75, DLG_nColorBtn1, DLG_nColorBtn2 } } ) }
                oBtn:nClrBorder := DLG_nColorBtnB




   @ 62, 10 SAY oSay[1] PROMPT  "Test Get" SIZE 100,25  PIXEL OF oDlg  TRANSPARENT  FONT oFont
   @ 80, 10 GET oGet VAR cGet SIZE 100,24 PIXEL OF oDlg
ACTIVATE DIALOG oDlg CENTERED
 return nil

Re: Bad look btnbmp disable()

PostPosted: Thu Mar 09, 2023 4:39 am
by Jimmy
hi Silvo,

i have try to "disable" a BTMBMP which have a Resource

but when "disable" BTNBMP i "just" get gray Back-Ground and Caption but NO Resource (have try different)

---

BTNBMP have

Code: Select all  Expand view
  METHOD Disable() INLINE ::Super:Disable(), ::Refresh()

as it is FROM TControl() i look there but TControl() have no Method "disable"

so i look into CLASS Window
Code: Select all  Expand view
  METHOD Disable()  INLINE ::lActive := .f.,;
                            If( ::hWnd != 0, EnableWindow( ::hWnd, .f. ),)

it does nothing to grey Image

---

CLASS TBitmap have
Code: Select all  Expand view
  /*
   METHOD Disable() INLINE ;   It paints on the desktop cause hDC is not ready!
                               Also users may not want to see their bitmaps in gray!
      DrawGray( ::GetDC(), ::hBitmap ), ::ReleaseDC(), ::Super:Disable() */

but it is not active ...

---

there is

Code: Select all  Expand view
HB_FUNC( DRAWGRAY ) // ( hDC, hBitmap, nRow, nCol, nWidth, nHeight ) --> nil
{
   DrawGray( ( HDC ) fw_parH( 1 ), ( HBITMAP ) fw_parH( 2 ),
             hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ), hb_parni( 6 ) );
}

but it is NOT used in CLASS CODE except (Ownerdraw) MENU

so how to get a Bitmap in gray on a "disable" BTNBMP :?:

p.s. how to change Bitmap / Color after create :?:

Re: Bad look btnbmp disable()

PostPosted: Thu Mar 09, 2023 9:25 am
by Silvio.Falconi
i made a solution but it is not good

MakeDisable_BtnBmp(oBtn)

Code: Select all  Expand view

Function MakeDisable_BtnBmp(oBtn)
    local aBru[ 2 ]
    DEFINE BRUSH aBru[ 1 ]   STYLE BDIAGONAL COLOR  Rgb(195,195,185)    // you can use also FDIAGONAL or another type type BORLAND OLD
    DEFINE BRUSH aBru[ 2 ]   STYLE BDIAGONAL COLOR  Rgb(195,195,185)
   oBtn:l2007:=.t.
   oBtn:SetFile(,)
   oBtn:lBorder := .f.
   oBtn:bClrGrad := { |lInvert| If( lInvert, aBru[ 2 ]:hBrush, aBru[ 1 ]:hBrush ) }
   oBtn:disable()
  RETURN NIL
 


another types

Horizontal SetBrush( "HORIZONTAL", nRGB( 0, 255, 0 ) )
Vertical SetBrush( "VERTICAL", nRGB( 20, 30, 40 ) )
FDiagonal SetBrush( "FDIAGONAL", nRGB( 255, 0, 35 ) )
BDiagonal SetBrush( "BDIAGONAL" )
Cross SetBrush( "CROSS" )
DiagCross SetBrush( "DIAGCROSS", nRGB( 0, 100, 255 ) )


then to remake the border use the Uwe's solution


DEFINE DIALOG oDlg.....



oDlg:bPainted := < |hDC|
oBtn:setsize(20,17.6) // this because the obtn is more big with png
DRAWBORDER( hDC, oBtn:nLeft-2, oBtn:ntop-2,;
oBtn:nWidth+2, oBtn:nHeight+2 , 0, 1, Rgb(195,195,185), .t. )
RETURN NIL
>

ACTIVATE DIALOG oDlg....


Result

( in my opinion it is better to see the bmp bits with diagonal lines (and it is disabled) than having a disabled btnbmp with a figure that is not nice to see )

Image

I can make a small class to make it but I have problem with Border of Btnbmp and the last solution is that of Uwe
https://forums.fivetechsupport.com/viewtopic.php?f=3&t=36937&start=0&hilit=xbrowse+border

Re: Bad look btnbmp disable()

PostPosted: Tue Mar 28, 2023 6:29 pm
by nageswaragunupudi
Silvio.Falconi wrote:Image


Image

Code: Select all  Expand view


#define DLG_nColorBtn1    RGB( 245,245,235)
#define DLG_nColorBtn2    RGB(250,250,245)
#define DLG_nColorBtnB    RGB(195,195,185)

Function sample()
   local oDlg,oBtn,oFont
   local nHt      := Int( ScreenHeight() * 0.2 )
   local nWd      := Int( ScreenWidth() * 0.2 )

   local lNormal :=.f.
   local nClrBorder := RGB(243,243,238)
   local oChk
   local oGet,cGet:= space(100)
   local oSay[1]

 DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -14
 DEFINE DIALOG oDlg SIZE nWd, nHt PIXEL TRUEPIXEL;
       RESIZABLE   TiTle "test" COLOR CLR_BLACK, RGB( 245,245,235)  ;
       STYLE nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU, ;
                  WS_MINIMIZEBOX, WS_THICKFRAME )

       @ 10,10 CheckBox oChk Var lNormal  Prompt "check" SIZE 100,20 of oDlg ;
       on change ( If(lNormal,(oBtn:Enable(), oGet:enable()),;
                              (oBtn:Disable(), oGet:disable())),;
                               oBtn:refresh(), oGet:refresh() )

          @ 10, 10 BTNBMP oBtn   ;
                   FILENAME "test.png" ;
                   FLAT SIZE 50,50  OF oDlg   PIXEL  ;
                   NOROUND   action msginfo()

                oBtn:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 0.25, DLG_nColorBtn1, DLG_nColorBtn2 },;
                      { 0.75, DLG_nColorBtn2, DLG_nColorBtn1 } },;
                    { { 0.25, DLG_nColorBtn2, DLG_nColorBtn1 }, ;
                      { 0.75, DLG_nColorBtn1, DLG_nColorBtn2 } } ) }
                oBtn:nClrBorder := DLG_nColorBtnB




   @ 62, 10 SAY oSay[1] PROMPT  "Test Get" SIZE 100,25  PIXEL OF oDlg  TRANSPARENT  FONT oFont
   @ 80, 10 GET oGet VAR cGet SIZE 100,24 PIXEL OF oDlg
ACTIVATE DIALOG oDlg CENTERED
 return nil


We have this issue with some pngs.

Please try adding the clause "GDIP" while defining the BTNBMP, like this:
Code: Select all  Expand view
        @ 10, 10 BTNBMP oBtn   ;
                   FILENAME "test.png" ;
                   FLAT SIZE 50,50  OF oDlg   PIXEL  GDIP ;
                   NOROUND   action msginfo()
 

Re: Bad look btnbmp disable()

PostPosted: Wed Mar 29, 2023 10:54 am
by Silvio.Falconi
surely there is a problem , you could see how to solve the border color problem of a btnbmp , because as I wrote in this post

https://forums.fivetechsupport.com/viewtopic.php?f=3&t=42757&start=0&sid=fbf48af6683902a2f56acaff4f02ef02

it is always black and does not change color

Re: Bad look btnbmp disable()

PostPosted: Thu Mar 30, 2023 11:30 am
by nageswaragunupudi
My response was to the simple point of how does the pngs appear when the btnbmp is disabled.
I am trying to say the appearance of disabled png images differ when GDIP clause is used and not used.
This shows the difference:

Code: Select all  Expand view
function testbtnpaint()

   local oDlg, aBtn, n
   local cPngPath := "..\bitmaps\pngs\"
   local aPng  := { cPngPath + "
2.png" }

   AEval( FW_ListAsArray( "
1,2,6,7,8,9,10" ), { |c| ;
      AAdd( aPng, cPngPath + "
image" + c + ".png" ) } )

   aBtn  := ARRAY( 3, Len( aPng ) )

   DEFINE DIALOG oDlg SIZE 80 + 70 * Len( aPng ), 430 PIXEL TRUEPIXEL ;
      TITLE "
BTNBMP: WITH AND WITHOUT GDIP CLAUSE"

   @  40, 40 SAY "
ENABLED BUTTONS NORMAL LOOK" SIZE 400,12 PIXEL OF oDlg

   for n := 1 to Len( aPng )
      @  70, n * 70 - 30 BTNBMP aBtn[ 1, n ] FILE aPng[ n ] SIZE 64,64 PIXEL GDIP OF oDlg
   next

   @ 150, 40 SAY "
DISABLED BUTTONS WITH GDIP clause" SIZE 400,12 PIXEL OF oDlg

   for n := 1 to Len( aPng )
      @ 180, n * 70 - 30 BTNBMP aBtn[ 1, n ] FILE aPng[ n ] SIZE 64,64 PIXEL GDIP OF oDlg WHEN .F.
   next

   @ 260, 40 SAY "
DISABLED BUTTONS WITHOUT GDIP clause" SIZE 400,12 PIXEL OF oDlg

   for n := 1 to Len( aPng )
      @ 290, n * 70 - 30 BTNBMP aBtn[ 1, n ] FILE aPng[ n ] SIZE 64,64 PIXEL /*GDIP*/ OF oDlg WHEN .F.
   next

   ACTIVATE DIALOG oDlg CENTERED

return nil


Image

When we use GDIP clause, png images on disabled buttons look like the second row.
When GDIP clause is not used, they look like the third row.
It is desirable for a programmer to know the difference.

Re: Bad look btnbmp disable()

PostPosted: Thu Mar 30, 2023 12:10 pm
by Silvio.Falconi
THANKS i UNDERSTOOD