#include "FiveWin.ch"
#include "constant.ch"
Static c_Path
Static c_Path1
Function Main()
聽 聽local oWnd
聽 聽local oBtn[10]
聽 聽local oTextFont
聽 聽local cImage 聽 聽:= "Logo.png"
聽 聽local nLeft 聽 聽 := 10
聽 聽local nTop 聽 聽 聽:= 10
聽 聽local oBmp
聽 聽local oImg1
聽 聽local oImg2
聽 聽local oImg3
聽 聽local lIni 聽 聽 聽:= .T.
聽 聽c_Path 聽:= cFilePath(GetModuleFileName( GetInstance() ) )
聽 聽c_Path1 := c_Path + "IMAGES\"
聽 聽DEFINE IMAGE oBmp FILENAME c_path1 + "Back.png"
聽 聽oTextFont := TFont():New( "Arial", 0, 20,.F.,.F., 聽0, 聽0, 聽0,.F.,.F.)
聽 聽DEFINE WINDOW oWnd 聽FROM 10, 10 TO 700, 900 TITLE "GDI+ TEST" PIXEL // ;
聽 聽 聽 // STYLE WS_POPUP BRUSH oBrush1
聽 聽oWnd:bRClicked := {|| oWnd:End() }
聽 聽@ oWnd:nHeight - 100, oWnd:nWidth - 370 BTNBMP oBtn[1] SIZE 100, 50 OF oWnd 聽2007 ;
聽 聽 聽 FILENAME c_path1 + "Paint.bmp" ;
聽 聽 聽 LEFT ;
聽 聽 聽 PROMPT "&Paint 1" ;
聽 聽 聽 FONT oTextFont ;
聽 聽 聽 ACTION ( cImage := "Logo.png", ; //nLeft := 500, nTop := 10, ;
聽 聽 聽 聽 聽 聽 聽 聽oImg1 聽:= DRAWIMAGE(oWnd, cImage, 500, 10 ) )
聽 聽 聽 oBtn[1]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
聽 聽 聽 聽 { { 0.5, 10526975, 16777215 }, ;
聽 聽 聽 聽 聽 { 0.5, 16777215, 10526975 } }, ;
聽 聽 聽 聽 { { 0.5, 16768185, 16777215 }, ;
聽 聽 聽 聽 聽 聽{ 0.5, 16777215, 16768185 聽} } ) }
聽 聽 聽 oBtn[1]:nLayout := 2
聽 聽 聽 oBtn[1]:SetColor( 128 )
聽 聽 聽 oBtn[1]:cTooltip := 聽{ "Exit" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"GDI-test","EXIT", 1, CLR_BLACK, 14089979 }
聽 聽@ oWnd:nHeight - 100, oWnd:nWidth - 260 BTNBMP oBtn[2] SIZE 100, 50 OF oWnd 聽2007 ;
聽 聽 聽 FILENAME c_path1 + "Paint.bmp" ;
聽 聽 聽 LEFT ;
聽 聽 聽 PROMPT "&Paint 2" ;
聽 聽 聽 FONT oTextFont ;
聽 聽 聽 ACTION ( cImage := "Logo.png", ; //nLeft := 250, nTop := 250, ;
聽 聽 聽 聽 聽 聽 聽 聽oImg2 聽:= DRAWIMAGE( oWnd, "Logo.png", 250, 250 ) )
聽 聽 聽 oBtn[2]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
聽 聽 聽 聽 { { 0.5, 10526975, 16777215 }, ;
聽 聽 聽 聽 聽 { 0.5, 16777215, 10526975 } }, ;
聽 聽 聽 聽 { { 0.5, 16768185, 16777215 }, ;
聽 聽 聽 聽 聽 聽{ 0.5, 16777215, 16768185 聽} } ) }
聽 聽 聽 oBtn[2]:nLayout := 2
聽 聽 聽 oBtn[2]:SetColor( 128 )
聽 聽 聽 oBtn[2]:cTooltip := 聽{ "Image 2" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"test","TEST", 1, CLR_BLACK, 14089979 }
聽 聽 聽
// -------------
@ oWnd:nHeight - 100, 20 BTNBMP oBtn[6] SIZE 110, 50 OF oWnd 聽2007 ;
FILENAME c_path1 + "Color.bmp" ;
LEFT ;
PROMPT "&Color" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 1, 3194624 )
oBtn[6]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
聽 聽 { { 0.5, 16765863, 16777215 }, ;
聽 聽 聽 { 0.5, 16777215, 16765863 } }, ;
聽 聽 { { 0.5, 16768185, 16777215 }, ;
聽 聽 聽 聽{ 0.5, 16777215, 16768185 聽} } ) }
oBtn[6]:nLayout := 2
oBtn[6]:SetColor( 128 )
oBtn[6]:cTooltip := 聽{ "use color" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Background","COLOR", 1, CLR_BLACK, 14089979 }
@ oWnd:nHeight - 100, 135 BTNBMP oBtn[7] SIZE 110, 50 OF oWnd 聽2007 ;
FILENAME c_path1 + "Gradient.bmp" ;
LEFT ;
PROMPT "&Gradient" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 2, 16762767, 16773088, .T., 0.5 )
oBtn[7]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
聽 聽 { { 0.5, 16765863, 16777215 }, ;
聽 聽 聽 { 0.5, 16777215, 16765863 } }, ;
聽 聽 { { 0.5, 16768185, 16777215 }, ;
聽 聽 聽 聽{ 0.5, 16777215, 16768185 聽} } ) }
oBtn[7]:nLayout := 2
oBtn[7]:SetColor( 128 )
oBtn[7]:cTooltip := 聽{ "use Gradient" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Background","GRADIENT", 1, CLR_BLACK, 14089979 }
@ oWnd:nHeight - 100, 250 BTNBMP oBtn[8] SIZE 110, 50 OF oWnd 聽2007 ;
FILENAME c_path1 + "Brush.bmp" ;
LEFT ;
PROMPT "&Brush" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 3, , , , , "Brush.bmp" )
oBtn[8]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
聽 聽 { { 0.5, 16765863, 16777215 }, ;
聽 聽 聽 { 0.5, 16777215, 16765863 } }, ;
聽 聽 { { 0.5, 16768185, 16777215 }, ;
聽 聽 聽 聽{ 0.5, 16777215, 16768185 聽} } ) }
oBtn[8]:nLayout := 2
oBtn[8]:SetColor( 128 )
oBtn[8]:cTooltip := 聽{ "use Brush" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Background","BRUSH", 1, CLR_BLACK, 14089979 }
@ oWnd:nHeight - 100, 365 BTNBMP oBtn[9] SIZE 110, 50 OF oWnd 聽2007 ;
FILENAME c_path1 + "Image.bmp" ;
LEFT ;
PROMPT "&Image" ;
FONT oTextFont ;
ACTION DRAW_BACK( oWnd, 4, , , , , ,"Backgrd.jpg" )
oBtn[9]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
聽 聽 { { 0.5, 16765863, 16777215 }, ;
聽 聽 聽 { 0.5, 16777215, 16765863 } }, ;
聽 聽 { { 0.5, 16768185, 16777215 }, ;
聽 聽 聽 聽{ 0.5, 16777215, 16768185 聽} } ) }
oBtn[9]:nLayout := 2
oBtn[9]:SetColor( 128 )
oBtn[9]:cTooltip := 聽{ "use Image" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "Background","IMAGE", 1, CLR_BLACK, 14089979 }
@ oWnd:nHeight - 100, oWnd:nWidth - 150 BTNBMP oBtn[10] SIZE 100, 50 OF oWnd 聽2007 ;
FILENAME c_path1 + "Exit.bmp" ;
LEFT ;
PROMPT "&Exit" ;
FONT oTextFont ;
ACTION oWnd:End()
oBtn[10]:bClrGrad = { | lMouseOver | If( ! lMouseOver,;
聽 聽 { { 0.5, 10526975, 16777215 }, ;
聽 聽 聽 { 0.5, 16777215, 10526975 } }, ;
聽 聽 { { 0.5, 16768185, 16777215 }, ;
聽 聽 聽 聽{ 0.5, 16777215, 16768185 聽} } ) }
oBtn[10]:nLayout := 2
oBtn[10]:SetColor( 128 )
oBtn[10]:cTooltip := 聽{ "Exit" + CRLF + ;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "GDI-test","EXIT", 1, CLR_BLACK, 14089979 }
//oWnd:bPainted := {|| DRAWIMAGE(oWnd, cImage, nLeft, nTop ) }
ACTIVATE WINDOW oWnd CENTER ;
ON INIT ( oImg3 := DRAWIMAGE( oWnd, cImage, nLeft, nTop ) ) ;
ON PAINT ( ABPaint( oWnd:hDC, 30, 30, oBmp:hBitmap, 255 ), ;
聽 聽 聽 聽 聽 聽if( !lIni, ( DrawImage( oWnd, oImg1, 500, 10 ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 DrawImage( oWnd, oImg2, 250, 250 ),;
聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 DrawImage( oWnd, oImg3, nLeft, nTop ) ), lIni := .F. ) ) //; 聽 聽 聽 聽 聽
oTextFont:End()
RETURN NIL
// -------------
FUNCTION DRAWIMAGE( oWnd, cImage, nLeft, nTop )
聽 聽
聽 聽local hDC 聽 聽 聽 := oWnd:GetDc()
聽 聽local cNew
聽 聽local oGraphics := Graphics():New( oWnd:hDC )
聽 聽local oImage
聽 聽if Valtype( cImage ) = "C"
聽 聽 聽 cNew 聽 聽 聽:= c_Path1 + cImage
聽 聽 聽 oImage 聽 聽:= GDIBmp():New( cNew ) 聽
聽 聽else
聽 聽 聽 oImage 聽 聽:= cImage
聽 聽endif
聽 聽if !Empty( oImage )
聽 聽 聽 oGraphics:DrawImage( oImage, nTop, nLeft 聽) //, nTop )
聽 聽 聽 oGraphics:Destroy()
聽 聽endif
聽 聽oWnd:ReleaseDc()
Return oImage
// -------- 聽Background ---------------
FUNCTION DRAW_BACK( oWnd, nStyle, nColor1, nColor2, lDirect, nMove, cBrush, cImage )
聽 聽local hDC
聽 聽local oBrush
聽 聽local oImage
聽 聽local aGrad
聽 聽local aRect 聽 := GETCLIENTRECT( oWnd:hWnd )
聽 聽local hBmp
聽 聽local hBmpOld
聽 聽IF nStyle = 1 // COLOR
聽 聽聽DEFINE BRUSH oBrush COLOR nColor1
聽 聽ENDIF
聽 聽IF nStyle = 2 // GRADIENT
聽 聽聽aGrad := { { nMove, nColor1, nColor2 }, { nMove, nColor2, nColor1 } }
聽 聽聽hDC = CreateCompatibleDC( oWnd:GetDC() )
聽 聽聽hBmp = CreateCompatibleBitMap( oWnd:hDC, aRect[4], aRect[3] )
聽 聽聽hBmpOld = SelectObject( hDC, hBmp )
聽 聽聽GradientFill( hDC, 0, 0, aRect[3], aRect[4], aGrad, lDirect )
聽 聽聽oBrush := TBrush():New( ,,,, hBmp )
聽 聽聽oBrush:Cargo 聽:= aGrad
聽 聽聽SelectObject( hDC, hBmpOld )
聽 聽聽ReleaseDC(hDC)
聽 聽ENDIF
聽 聽IF nStyle = 3 // BMP-BRUSH
聽 聽聽IF FILE( c_path1 + cBrush )
聽 聽聽聽 聽 DEFINE BRUSH oBrush FILE c_path1 + cBrush
聽 聽聽ELSE
聽 聽聽聽 聽 IF !EMPTY(cImage)
聽 聽聽聽 聽 聽 聽 MsgAlert( "File : " + cBrush + CRLF + ;
聽 聽聽聽 聽 聽 聽 聽 聽 聽 聽 "does not exist" + CRLF + ;
聽 聽聽聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 "to create Background !", "ATTENTION" )
聽 聽聽聽 聽 ENDIF
聽 聽聽ENDIF
聽 聽ENDIF
聽 聽IF nStyle = 4 // Image ADJUSTED
聽 聽聽IF FILE( c_path1 + cImage )
聽 聽聽聽 聽 DEFINE IMAGE oImage FILE c_path1 + cImage
聽 聽聽聽 聽 oBrush := TBrush():new( ,,,, ResizeBmp( oImage:hBitmap, aRect[4], aRect[3], .T. ) )
聽 聽聽聽 聽 oImage:End()
聽 聽聽ELSE
聽 聽聽聽 聽 IF !EMPTY(cImage)
聽 聽聽聽 聽 聽 聽 MsgAlert( "File 聽: " + cImage + CRLF + ;
聽 聽聽聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"does not exist" + CRLF + ;
聽 聽聽聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽 聽"to create Background !", "ATTENTION" )
聽 聽聽聽 聽 ENDIF
聽 聽聽ENDIF
聽 聽ENDIF
聽 聽oWnd:Setbrush( oBrush )
聽 聽oBrush:End()
聽 聽
RETURN( NIL)