round bitmap btn

round bitmap btn

Postby Silvio » Wed Nov 17, 2010 10:59 pm

where I can found a sample of it ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: round bitmap btn

Postby ukoenig » Thu Nov 18, 2010 12:42 am

Have a look at => samples\Testbtn4.prg

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: round bitmap btn

Postby Silvio » Thu Nov 18, 2010 8:17 am

yes but I not see round button but only ellipse button....
try to show exactly this "..\BITMAPS\btnqck2.bmp"
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: round bitmap btn

Postby ukoenig » Thu Nov 18, 2010 1:26 pm

Silvio,

the Button, You are looking for.
Very important, to use the correct Background-functions, to get it working :

Image

Test-Dialog and Functions :

Code: Select all  Expand view

FUNCTION PROJECT( oWnd )
LOCAL oDlg, hDC, oFont, oBtn1, oBtn2

DEFINE FONT oFont NAME "Arial" SIZE 0,-16 BOLD ITALIC

// select Background-Style
// 1 = Color, 2 = Gradient, 3 = Brush, 4 = Image
// -----------------------------------------------------
nDBACK := 4  

// Exe-path
// -----------
c_path := CURDRIVE() + ":\" + GETCURDIR()

// Dialog Background-Values
// -------------------------------
D_COLOR1 := 8388608 // Color 1 Blue
D_COLOR2 := 16312263 // Color 2 for Gradient White
D_MOVE := 0.5 // Gradient-Position
D_DIRECT := .T. // Gradient-Direction
D_BRUSH := c_path + "
\Images\Blustone.bmp"
D_IMAGE := c_path + "
\Images\Backgrd.jpg"

DEFINE DIALOG oDlg RESOURCE "
Test" OF oWnd TRANSPARENT

// NO Buttontext
// -----------------
REDEFINE BTNBMP oBtn1 ID 10 OF oDlg ;
FILENAME c_path + "
\Images\btnqck2.bmp" ;
NOBORDER ;
ACTION MsgAlert ( "
No Buttontext" , "Attention" )

oBtn1:lTransparent = .t.  
oBtn1:cTooltip := { "
Transparent" + CRLF + ;
          "
no Border","Button-Test", 1, CLR_BLACK, 1, 14089979 }

// With Buttontext centered
// ------------------------------
// REDEFINE BTNBMP oBtn1 ID 10 OF oDlg ;
// FILENAME c_path + "
\Images\btnqck2.bmp" ;
// CENTER ; !!!!! added
// PROMPT "
&Test" ;  // !!!!! added
// NOBORDER ;
// FONT oFont ; // !!!!! added
// ACTION MsgAlert ( "
Red centered" + CRLF + "Buttontext" , "Attention" )

// oBtn1:lTransparent = .t.  
// oBtn1:cTooltip := { "
Transparent" + CRLF + ;
//          "
no Border","Button-Test", 1, CLR_BLACK, 1, 14089979 }
// oBtn1:SetColor( 128, ) // !!!!! added

REDEFINE BTNBMP oBtn2 ID 20 OF oDlg  2007 ;
FILENAME c_path + "
\Images\A_Exit.bmp" ;
LEFT ;
PROMPT "
&Exit" ;
FONT oFont ;
ACTION oDlg:End()
oBtn2:cTooltip := { "
Exit " + CRLF + ;
                   "
Project-Editor","Project-Edit", 1, CLR_BLACK, 1, 14089979 }

ACTIVATE DIALOG oDlg NOWAIT ;
ON INIT ( oDlg:Move( 130, 500, NIL, NIL, .T. ), ;
          IIF( nDBACK = 1, DLG_BACK( nDBACK, oDlg, hDC, , D_COLOR1 ), ), ;
          IIF( nDBACK = 2, DLG_BACK( nDBACK, oDlg, hDC, D_MOVE, D_COLOR1, D_COLOR2 ), ), ;
          IIF( nDBACK = 3, DLG_BACK( nDBACK, oDlg, hDC, , , , , D_BRUSH ), ), ;
          IIF( nDBACK = 4, DLG_BACK( nDBACK, oDlg, hDC, , , , , , D_IMAGE ), ) )

oFont:End()

RETURN NIL

// ----------- Backgrounds -----------------

FUNCTION DLG_BACK( nStyle, oWin, hDC, nMove, nColor1, nColor2, lDirect, cBrush, cImage )
LOCAL oBrush, oTmp, oImage, aGrad, hDC1, hBmp, hBmpOld

IF nSTYLE = 1 // Color
    DEFINE BRUSH oBrush COLOR nColor1
    SET BRUSH OF oWin TO oBrush
    RELEASE BRUSH oBrush
ENDIF
IF nSTYLE = 2 // Gradient-Brush
    aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
    IF Empty( oWin:oBrush:hBitmap )
          hDC1 = CreateCompatibleDC( oWin:GetDC() )
          hBmp = CreateCompatibleBitMap( oWin:hDC, oWin:nWidth, oWin:nHeight )
          hBmpOld = SelectObject( hDC1, hBmp )
          GradientFill( hDC1, 0, 0, oWin:nHeight, oWin:nWidth, aGrad, lDirect )
          DeleteObject( oWin:oBrush:hBrush )
          oWin:oBrush:hBitmap = hBmp
          oWin:oBrush:hBrush = CreatePatternBrush( hBmp )
          SelectObject( hDC1, hBmpOld )
          oWin:ReleaseDC()
    ENDIF  
ENDIF
IF nSTYLE = 3 // Brush
    DEFINE BRUSH oBrush FILENAME cBrush
    SET BRUSH OF oWin TO oBrush
    RELEASE BRUSH oBrush
ENDIF
IF nSTYLE = 4 // Image
    DEFINE IMAGE oTmp FILENAME cImage
    oBrush := TBrush():new( ,,,, ResizeBmp( oTmp:hBitmap, oWin:nWidth, oWin:nHeight, .T. ) )
    SET BRUSH OF oWin TO oBrush
    oTmp:End()
    RELEASE BRUSH oBrush
ENDIF

RETURN( NIL )
 


The Resource :

Code: Select all  Expand view

TEST DIALOG 19, 30, 231, 169
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
CAPTION "Button-Test"
{
 CONTROL "", 20, "TBtnBmp", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 167, 122, 56, 38
 CONTROL "", 10, "TBtnBmp", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 95, 42, 31, 30
}
 


Using Red centered Buttontext :

Image

Best Regards
Uwe :lol:
Last edited by ukoenig on Thu Nov 18, 2010 7:37 pm, edited 1 time in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: round bitmap btn

Postby Silvio » Thu Nov 18, 2010 5:39 pm

Sorry Uwe,

I tried with your sample

I tried to insert on a window many balls with numbers from an simply dbf


structure of Balls.dbf
Number N 4
txt c 10


But I not Know How make it ... and your sample here not run ok
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: round bitmap btn

Postby ukoenig » Thu Nov 18, 2010 6:31 pm

Sylvio,

the sample works with Dialogs, for Windows it works different( Background-painting ).
Do You need Buttontext ?
I think it will be 2 arrays like Ball[i].bmp and Prompt[i] ( i = Recno()-info )
If yes, where do You want to place it ( Top, Left, Bottom, Right or Center )
I will add / include a Window-Version.

Because You want to show the Buttons from inside the Mainwindow, a nice Solution could be,
using a transparent VTitle with - or without Border for placing the Bitmaps.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: round bitmap btn

Postby Silvio » Thu Nov 18, 2010 7:45 pm

I wish create to make a test a simply window : 20 rows for 10 colums with bitmaps ( balls) with number
On window we can insert a background simply I see an image on background directory of fwh
and we must have the possibilty to click on each button ...
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: round bitmap btn

Postby ukoenig » Thu Nov 18, 2010 8:36 pm

Silvio,

the Solution I found working on a Mainwindow, with- and without Border using animated REFLEX-Buttons :
Simply show and hide Buttons in Relation to selected DBF-Records with any Text.

Image

Because You cannot use oBtn3:Hide() and oBtn3:Show()
it works a different way.
1. Create a complete transparent BMP ( call it < NIL.bmp > )
2. replace the existing BMP with NIL.bmp and reverse, or use instead of < NIL.bmp > another Color.

Using a Button-switch for the Test :
( BtnBmp can be used inside VTitles as well !!! )
Also You can change the Buttontext.

Code: Select all  Expand view


// 3 means the Button-number from the list, You want to hide
//---------------------------------------------------------------------

@ 450, 30 BTNBMP oBtn7 OF oTITLE1 ;
SIZE 170,60 ;
PROMPT "  &Hide / Show" ;
LEFT FONT oFont2 ;
FILE c_path  + "\Images\A_Select.BMP" 2007 ;      
ACTION ( IIF( lHide = .F., ( lHide := .T., oTITLE1:ChangeImg( c_path  + "\Images\NIL.BMP", 3 ) ), ;
                                      ( lHide := .F., oTITLE1:ChangeImg( c_path  + "\Images\Btnqck2.BMP", 3 ) ) ), oTitle1:Refresh() )
 


Image



Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: round bitmap btn

Postby Silvio » Fri Nov 19, 2010 8:07 am

can have a minimal test to try with classes and bmp fwh ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: round bitmap btn

Postby ukoenig » Fri Nov 19, 2010 1:41 pm

Silvio,

the complete Window-Sample with all Informations You need :

Code: Select all  Expand view

#include "fivewin.ch"
#include "ttitle.ch"

STATIC oWndMain, oFont1, oFont2
STATIC hDC, nWINBACK, c_path
STATIC W_COLOR1, W_COLOR2, W_MOVE, W_DIRECT, W_BRUSH, W_IMAGE

REQUEST DBFCDX

FUNCTION MAIN()
LOCAL oSay[6], lHide := .F.
LOCAL oBtn[8], oTITLE1
local aRect3 := GetSysmetrics( 1 ) // Screen-Height
local aRect4 := GetSysmetrics( 0 ) // Screen-Width
LOCAL cBtnText[6], oBrush

cBtnText[1] := "Button 1"
cBtnText[2] := "Button 2"
cBtnText[3] := "Button 3"
cBtnText[4] := "Button 4"
cBtnText[5] := "Button 5"
cBtnText[6] := "Button 6"

RddSetDefault("DBFCDX")
SET _3DLOOK ON

SetBalloon( .T. ) // Balloon shape required for tooltips

c_path := CURDRIVE() + ":\" + GETCURDIR()  // Appl. Main-Path

// Define a Number for Window-Background
// -------------------------------------------------
nWINBACK := 4 // => 1 = Color, 2 = Brush, 3 = Gradient, 4 = Image

// Window Values
// --------------------
W_COLOR1 := 8355711 // Color 1 Grey
W_COLOR2 := 16312263 // Color 2 White Gradient
W_MOVE := 0.5 // Gradient-Position
W_DIRECT := .T. // Gradient-Direction
W_BRUSH := c_path + "
\Images\Blustone.bmp"
W_IMAGE := c_path + "
\Images\Fantasy4.jpg"

DEFINE FONT oFont2 NAME "
Arial" SIZE 0,-16 BOLD ITALIC

IF nWINBACK = 1
    DEFINE BRUSH oBrush COLOR W_COLOR1
ENDIF
IF nWINBACK = 2
    DEFINE BRUSH oBrush FILENAME W_BRUSH
ENDI

IF nWINBACK < 3
    DEFINE WINDOW oWndMain FROM  0,0 TO aRect3, aRect4 TITLE "
VTitle Buttontest" BRUSH oBrush
ELSE
    DEFINE WINDOW oWndMain FROM  0,0 TO aRect3, aRect4 TITLE "
VTitle Buttontest"
ENDIF

// The VTITLE-Body
// --------------------
@  30, 50 TITLE oTITLE1 SIZE 300, 700 OF oWndMain ;
TRANSPARENT NOBORDER

// The Title of Button 1
// ------------------------
@ 15, 35  TITLETEXT oSay[1] OF oTITLE1 TEXT cBtnText[1]  FONT oFont2  ;
SHADOW BOTTOMRIGHT COLOR 16777215

// Image Button 1
// -------------------
@  25, 30 TITLEIMG oBtn[1] OF oTITLE1 BITMAP c_path + "
\Images\btnqck2.bmp"  TRANSPARENT ;
REFLEX ANIMA LEVEL 255 ;
ACTION MsgAlert( "
Button with Action","Attention" ) 

@ 15, 115  TITLETEXT oSay[2] OF oTITLE1 TEXT cBtnText[2]  FONT oFont2  ;
SHADOW BOTTOMRIGHT COLOR 16777215

@  25, 110 TITLEIMG oBtn[2] OF oTITLE1 BITMAP c_path + "
\Images\btnqck2.bmp"  TRANSPARENT ;
REFLEX ANIMA LEVEL 255 ;
ACTION MsgAlert( "
Button with Action","Attention" ) 

// --- Buttons 3 and 4 ----

@ 155, 35  TITLETEXT oSay[3] OF oTITLE1 TEXT cBtnText[3]  FONT oFont2  ;
SHADOW BOTTOMRIGHT COLOR 16777215

@  175, 30 TITLEIMG oBtn[3] OF oTITLE1 BITMAP c_path + "
\Images\btnqck2.bmp"  TRANSPARENT ;
REFLEX ANIMA LEVEL 255 ;
ACTION MsgAlert( "
Button with Action","Attention" ) 

@ 155, 115  TITLETEXT oSay[4] OF oTITLE1 TEXT cBtnText[4]  FONT oFont2  ;
SHADOW BOTTOMRIGHT COLOR 16777215

@  175, 110 TITLEIMG oBtn[4] OF oTITLE1 BITMAP c_path + "
\Images\btnqck2.bmp"  TRANSPARENT ;
REFLEX ANIMA LEVEL 255 ;
ACTION MsgAlert( "
Button with Action","Attention" ) 

// --- Buttons 5 and 6 ------

@ 300, 35  TITLETEXT oSay[5] OF oTITLE1 TEXT cBtnText[5]  FONT oFont2  ;
SHADOW BOTTOMRIGHT COLOR 16777215

@  320, 30 TITLEIMG oBtn[5] OF oTITLE1 BITMAP c_path + "
\Images\btnqck2.bmp"  TRANSPARENT ;
REFLEX ANIMA LEVEL 255 ;
ACTION MsgAlert( "
Button with Action","Attention" ) 

@ 300, 115  TITLETEXT oSay[6] OF oTITLE1 TEXT cBtnText[6]  FONT oFont2  ;
SHADOW BOTTOMRIGHT COLOR 16777215

@  320, 110 TITLEIMG oBtn{6[ OF oTITLE1 BITMAP c_path + "
\Images\btnqck2.bmp"  TRANSPARENT ;
REFLEX ANIMA LEVEL 255 ;
ACTION MsgAlert( "
Button with Action","Attention" ) 

// Change BMP ( Button 3 )
//----------------------------------
@ 450, 30 BTNBMP oBtn[7] OF oTITLE1 ;
SIZE 170,60 ;
PROMPT "
Change &BMP" ;
LEFT FONT oFont2 ;
FILE c_path  + "
\Images\A_Select.BMP" 2007 ;      
ACTION ( IIF( lHide = .F., ( lHide := .T., oTITLE1:ChangeImg( c_path  + "
\Images\NIL.BMP", 3 ) ), ;
          ( lHide := .F., oTITLE1:ChangeImg( c_path  + "
\Images\btnqck2.BMP", 3 ) ) ), oTitle1:Refresh() )
oBtn7:cTooltip :=  { "
Show" + CRLF + ;
          "
Tooltip","Button 7", 1, CLR_BLACK, 14089979 }

// Change Text ( Text = Array-Element 3 of aText for Button 3 )
// -------------------------------------------------------------------------
@ 520, 30 BTNBMP oBtn[8] OF oTITLE1 ;
SIZE 170,60 ;
PROMPT "
Change &Text" ;
LEFT FONT oFont2 ;
FILE c_path  + "
\Images\A_Select.BMP" 2007 ;      
ACTION  ( IIF( lHide = .F., ( lHide := .T., oTitle1:aText[ 3, 3 ] := "
New"), ;
         ( lHide := .F., oTitle1:aText[ 3, 3 ] := "
Button 3" ) ), oTitle1:Refresh() )

ACTIVATE WINDOW oWndMain MAXIMIZED VALID QuitApp() ;
ON PAINT ( IIF( nWINBACK = 3, WIN_BACK( nWINBACK, oWndMain, hDC, W_MOVE, W_COLOR1, W_COLOR2, W_DIRECT ), ), ;
                    IIF( nWINBACK = 4, WIN_BACK( nWINBACK, oWndMain, hDC, , , , , W_IMAGE ), ) )

RETURN NIL

// --------- Gradient and Image-Function for WINDOWS -------------------

FUNCTION WIN_BACK( nStyle, oWin, hDC, nMove, nColor1, nColor2, lDirect, cImage )
LOCAL oImage, aGrad

IF nSTYLE = 3 // Gradient-Color
    aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
    GradientFill( oWin:GetDC(),  0, 0, oWin:nHeight, oWin:nWidth, aGrad, lDirect )
ENDIF
IF nSTYLE = 4 // Image
    DEFINE IMAGE oImage FILENAME cImage
    DRAWBITMAP( hDC, oImage:hbitmap, 0, 0, GetSysMetrics(0), GetSysMetrics(1) )
    RELEASE IMAGE oImage
ENDIF

RETURN NIL


It works perfect, selecting Bmp`s and Text from a DBF :

Rddsetdefault( "DBFCDX" )
DBSELECTAREA(1)
USE PROJECT NEW

// Change BMP
//-----------------
@ 450, 30 BTNBMP oBtn[7] OF oTITLE1 ;
SIZE 170,60 ;
PROMPT " Select &BMP" ;
LEFT FONT oFont2 ;
FILE c_path + "\Images\A_Select.BMP" 2007 ;
ACTION ( oTITLE1:ChangeImg( c_path + "\Images\" + ALLTRIM((1)->IMAGE), (1)->(RECNO()) ), oTitle1:Refresh() )
oBtn[7]:cTooltip := { "Show" + CRLF + ;
"Monitor 1","Monitor", 1, CLR_BLACK, 14089979 }

// Change Text
// ----------------
@ 520, 30 BTNBMP oBtn[8] OF oTITLE1 ;
SIZE 170,60 ;
PROMPT " Select &Text" ;
LEFT FONT oFont2 ;
FILE c_path + "\Images\A_Select.BMP" 2007 ;
ACTION ( oTitle1:aText[ (1)->(RECNO()), 3 ] := Alltrim((1)->BTNTEXT), oTitle1:Refresh() )

To clear the Buttonlist :
Code: Select all  Expand view

FUNCTION RESET()

DBSELECTAREA(1)
DBGOTOP()
Do While !eof()
     oTITLE1:ChangeImg( c_path  + "\Images\NIL.BMP", Recno() ) // a Empty transparent BMP
     oTitle1:aText[ Recno(), 3 ] := ""
     DBSKIP(+1)
Enddo
oTITLE1:Refresh()

RETURN NIL
 


Image

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: round bitmap btn

Postby Silvio » Sat Nov 20, 2010 8:58 am

THANKS Uwe
there are these errors :

error 113 line

quitapp () not exit

Error description: Error BASE/1003 Variable does not exist: OBTN7


then the test here not run I not have image folder

But we must use TTitle to create a round button ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: round bitmap btn

Postby ukoenig » Sat Nov 20, 2010 9:23 am

Heloo Silvio,

error 113 line
quitapp () not exit
Error description: Error BASE/1003 Variable does not exist: OBTN7
then the test here not run I not have image folder
But we must use TTitle to create a round button ?

1. no need of a End-Appl.-Function, just a Sample
2. use Say- and BTn`s as a Array. I changed to a Array aBtn[1] - aBtn[8] and oSay[1] - oSay[6]
3. no need of a Image- Sub-Drectory, You can change it and copy the BMP's to Your Main-directory.
4. There is a Problem, to paint transparent Buttons directly on a Main-Window with different Backgrounds.
Using the VTitle as a Frame, solves this Problem.
Optional, You can use the Dialog from my 1. sample and adjust it to Screen-size,
but I think. the VTitle is the better Solution.
Have a look at my Sample, how it works to gether with a DBF.
I can include a Download-link on this place, if it helps.

Best Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 53 guests