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 )
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
}
// 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() )
#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
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
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot], nageswaragunupudi and 41 guests