Page 1 of 2
an image on btnbmp and other
Posted: Wed May 23, 2018 10:20 am
by Silvio.Falconi
I wish Know if I can make it with btnbmp
I need to put the number on bottom angle left and a small image on top angle right
the umbrella image at the center
as this image

How I can set the color when I press a button ?
I wish when I select many buttons the buttons must be pressed. this because when I make a multiple selection can I insert on order many umbrellas
it is possible with Btnbmp ?
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 2:09 pm
by nageswaragunupudi
Code: Select all | Expand
function Test()
local oDlg, oFont, aBtn[ 7 ]
local nRow, nCol, n
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 600,200 PIXEL TRUEPIXEL FONT oFont
nRow := 50
nCol := 30
for n := 1 to 7
@ nRow, nCol BTNBMP aBtn[ n ] RESOURCE "c:\fwh\bitmaps\alphabmp\world.bmp" ;
PROMPT LTrim( Str( n ) ) + " " ;
SIZE 64,64 PIXEL OF oDlg FLAT TOP COLOR CLR_WHITE,CLR_GREEN NOBORDER
WITH OBJECT aBtn[ n ]
:Cargo := n
:bAction := { |oBtn| oBtn:Toggle() }
:bPainted := { |hDC| FW_DrawImage( hDC, "c:\fwh\bitmaps\alphabmp\task.bmp", { 2, 30, 34, 62 } ) }
:bClrGrad := { |l,oBtn| If( oBtn:lPressed, CLR_HRED, CLR_GREEN ) }
END
nCol += 80
next n
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil

Re: an image on btnbmp and other
Posted: Wed May 23, 2018 3:56 pm
by Silvio.Falconi
thanks,
but I believe I cannot use it because I also an oldest release of fwh
because I not have FW_DrawImage() is there another solution ?
How I can change the color of text ( back and fore) I need to create a small box to insert the number and change this with different color .
sample :change the box of text with clr_red background if the customer has not payed also
it run also with Png ?
I 'm thinking ...I must make a purchase now
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 6:34 pm
by Otto
Dear Mr Rao,
can you please show me on this example how to get this working.
:bPainted := { |hDC| DrawText( hDC, LTrim( Str( n ) ) + " " , { 2, 30, 34, 62 } ) }
In my case it is always 8.
How can I add to more textlines to the button with different fonts.
Thank you in advance
Otto
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 7:22 pm
by cnavarro
Otto, try with
Code: Select all | Expand
FW_SayText( oWnd, cText, aRect, cAlign, oFont, nClrText, nClrBack, lBorder, nAddStyle ) // oWnd or hDC
Mr Rao, it's Ok ?
Who return these functions?
? FW_SayText( oWnd, cText, aRect, cAlign, oFont, nClrText, nClrBack, lBorder, nAddStyle ) // oWnd or hDC
? FW_DrawImage( hDC, "c:\fwh\bitmaps\alphabmp\task.bmp", { 2, 30, 34, 62 } ) }
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 7:33 pm
by Otto
Dear Cristobal,
here is the same problem with the values.
We need to use detached locals but I can’t get it working.
It it works for the different fonts I have to check.
Best regards
Otto
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 7:58 pm
by Silvio.Falconi
Otto wrote:Dear Mr Rao,
can you please show me on this example how to get this working.
:bPainted := { |hDC| DrawText( hDC, LTrim( Str( n ) ) + " " , { 2, 30, 34, 62 } ) }
In my case it is always 8.
How can I add to more textlines to the button with different fonts.
Thank you in advance
Otto
Also here 
I wish Know :
1. How have an array with the umbrellas selected ...
2. how change the number color background and create a small box as you can see on first snapshot
with FW_SayText(aBtn[ n ], "k", { 2, 30, 34, 62 }, , oFont, CLR_BLACK, CLR_WHITE, .T., ) not happen nothing
with :bPainted := { |hDC| FW_SayText(hdc, "k", { 2, 30, 34, 62 }, , oFont, CLR_BLACK, CLR_WHITE, .T., ) }
I have a result but allways 8

Re: an image on btnbmp and other
Posted: Wed May 23, 2018 8:23 pm
by cnavarro
Otto wrote:Dear Cristobal,
here is the same problem with the values.
We need to use detached locals but I can’t get it working.
It it works for the different fonts I have to check.
Best regards
Otto
Otto, one idea is
Code: Select all | Expand
:Cargo := LTrim( Str( n ) )
:bPainted := { | hDC, cP, oBtn | DrawText( hDC, oBtn:Cargo + " " , { 2, 30, 34, 62 } ) }
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 8:44 pm
by Silvio.Falconi
Cristobal,
Otto's idea run ok here
but I wish is possible create a colored box arround the text is on the left angle

how I can save an array with all btns pressed ?
if aadd(obtn:cargo) give me allways 8
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 9:03 pm
by Silvio.Falconi
Otto,
mycent...
try with
:bPainted := { | hDC, cP, oBtn | DrawText2(hDC, oFont:hFont, 1, LTrim( Str(oBtn:Cargo)) + " " ,2, 30, 34, 62, CLR_WHITE )}
FUNCTION DrawText2( hDC, hFont, nBkMode, cText, nTop, nLeft, nWidth, nHeight,color )
LOCAL hFontOld:= SelectObject( hDC, hFont )
LOCAL nBkOld := SetBkMode( hDC, nBkMode )
SetTextColor( hDC, color )
DrawText( hDC, cText, { nTop, nLeft, nTop+nWidth, nLeft+nHeight } )
SelectObject( hDC, hFontOld )
SetBkMode( hDC, nBkOld )
RETURN( NIL )
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 9:06 pm
by Otto
Dear Cristobal,
thank youso much. With cargo it is working.
Best regards,
Otto
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 9:13 pm
by Silvio.Falconi
and with...
:bPainted := { | hDC, cP, oBtn | DrawText2(hDC, oFont:hFont, 2, LTrim( Str(oBtn:Cargo)) + " " ,2, 20, 34, 62,CLR_WHITE, CLR_RED )}
FUNCTION DrawText2( hDC, hFont, nBkMode, cText, nTop, nLeft, nWidth, nHeight,color,color2 )
LOCAL hFontOld:= SelectObject( hDC, hFont )
LOCAL nBkOld := SetBkMode( hDC, nBkMode )
SetTextColor( hDC, color )
setBkColor( hDC, color2 )
DrawText( hDC, cText, { nTop, nLeft, nTop+nWidth, nLeft+nHeight } )
SelectObject( hDC, hFontOld )
SetBkMode( hDC, nBkOld )
RETURN( NIL )
you have

Otto the button is nice, right?
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 9:44 pm
by Otto
Hello Silvio, yes very nice.
Regards,
Otto
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 10:58 pm
by nageswaragunupudi
Code: Select all | Expand
function TestCurrent()
local oDlg, oFont, oBtn, aBtn[ 7 ]
local nRow, nCol, n
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE DIALOG oDlg SIZE 600,200 PIXEL TRUEPIXEL FONT oFont
nRow := 50
nCol := 30
for n := 1 to 7
@ nRow, nCol BTNBMP aBtn[ n ] RESOURCE "c:\fwh\bitmaps\alphabmp\world.bmp" ;
SIZE 64,64 PIXEL OF oDlg FLAT TOP COLOR CLR_WHITE,CLR_GREEN NOBORDER
WITH OBJECT ( oBtn := aBtn[ n ] )
:Cargo := n
:bAction := { |oBtn| oBtn:Toggle() }
:bClrGrad := { |l,oBtn| If( oBtn:lPressed, CLR_HRED, CLR_GREEN ) }
END
nCol += 80
next n
for each oBtn in aBtn
oBtn:bPainted := { |hDC| FW_DrawImage( hDC, "c:\fwh\bitmaps\alphabmp\task.bmp", { 2, 30, 34, 62 } ), ;
FW_SayText( hDC, oBtn:Cargo, { 40, 2, 63, 25 },,oFont, CLR_HRED, nARGB(255,CLR_YELLOW), .t. ) }
next
ACTIVATE DIALOG oDlg CENTERED
RELEASE FONT oFont
return nil

nClrBack in FW_SayText(...) can be
1) Color value
2) Alpha Color
3) oBrush or hBrush
In case of (2) and (3), entire rectangle is filled with the color/brush.
In case of (1) the text is painted using nClrText/nClrBack within the rectangle.
Re: an image on btnbmp and other
Posted: Wed May 23, 2018 11:37 pm
by nageswaragunupudi
Using FW_SayText() to print multi-line text in multiple fonts:
Code: Select all | Expand
function TestCurrent()
local oWnd, oBold, oMedium, oSmall, cText
DEFINE FONT oBold NAME "COPPERPLATE GOTHIC BOLD" SIZE 0,-24
DEFINE FONT oMedium NAME "VERDANA" SIZE 0,-16
DEFINE FONT oSmall NAME "TAHOMA" SIZE 0,-11
cText := "This is Bold Font" + CRLF + ;
"Text in Medium Font" + CRLF + ;
"Some more text in small font" + CRLF + ;
"spanning multiple lines."
DEFINE WINDOW oWnd
ACTIVATE WINDOW oWnd CENTERED ;
ON PAINT oWnd:SayText( cText, nil, nil, { oBold, oMedium, oSmall, oSmall } )
RELEASE FONT oBold, oMedium, oSmall
return nil
