Button-Actions added to new Class VTitle FWH 9.07

Button-Actions added to new Class VTitle FWH 9.07

Postby ukoenig » Mon Aug 10, 2009 11:33 am

Hello,

I started with the new Vtitle-Class and added Button-Actions :

Image

As a Standard, it is not included.
I used oTitle:bLDblClick from TControl and
selected the 4 Positions ( Top, Left, Right, Bottom ) of the different Images.

How it works :
I know the Click-Position < nRow > and < nCol >
Next scanning the Images and check if the Click-Position is inside the Image-Area.
If YES, I start a Action for this Button.

The working Function with all Image-Values I need for the Calculation :
Code: Select all  Expand view

FUNCTION BTN_ACTION( nRow, nCol, oTitle, oDlg )
local nAt, aPOS[Len( oTitle:aImgs )][4]

// Scanning all Images of the Title and saving the Values to a Array
// ---------------------------------------------------------------------------
FUNCTION BTN_ACTION( nRow, nCol, oTitle, oDlg )
local nAt, aPOS[Len( oTitle:aImgs )][4]

FOR nAt := 1 to Len( oTitle:aImgs )
   // Img-Height
   aPOS[Len( oTitle:aImgs )][1] := nBmpHeight( oTitle:aImgs[ nAt, 0x03 ] )
   // Img-Width
   aPOS[Len( oTitle:aImgs )][2] := nBmpWidth( oTitle:aImgs[ nAt, 0x03 ] )
   // Img-Top
   aPOS[Len( oTitle:aImgs )][3] := oTitle:aImgs[ nAt, 0x01 ]
   // Img-Left
   aPOS[Len( oTitle:aImgs )][4] := oTitle:aImgs[ nAt, 0x02 ] // Img-Left

   // only for Tests
   // msgalert( aPOS[Len( oTitle:aImgs )][1], LTRIM(STR(nAt)) + " Height" )
   // msgalert( aPOS[Len( oTitle:aImgs )][2], LTRIM(STR(nAt)) + " Width" )
   // msgalert( aPOS[Len( oTitle:aImgs )][3], LTRIM(STR(nAt)) + " Top" )
   // msgalert( aPOS[Len( oTitle:aImgs )][4], LTRIM(STR(nAt)) + " Left" )

   IF aPOS[Len( oTitle:aImgs )][3] <= nRow .and. ; // Top <= Row-Click
      aPOS[Len( oTitle:aImgs )][3] + aPOS[Len( oTitle:aImgs )][1] >= nRow .and. ; // Top + Height > Row-Click
      aPOS[Len( oTitle:aImgs )][4] <= nCol .and. ;  // Left <= Row-Click
      aPOS[Len( oTitle:aImgs )][4] + aPOS[Len( oTitle:aImgs )][2] >= nCol // Left + Width > Col-Click
      MsgAlert( "I am Button : " + LTRIM(STR(nAt)),"Attention" )
   ENDIF
NEXT

RETURN( NIL )
 

Working with the Function :
Code: Select all  Expand view

FUNCTION TEST_TITLE(oWnd,oBrush1,oFont1)
LOCAL oDlg, oTitle, hDC, oButt1

aDLG := { { 0.60, 16752190, 16777215 }, ;  
                 { 0.60, 16777215, 16752190 } }    

nMainStyle = nOR( WS_OVERLAPPED | WS_VISIBLE )
DEFINE DIALOG oDlg FROM 15, 15 TO 320, 580 OF oWnd PIXEL

@ 20, 20  TITLE oTitle size 242, 115 of oDlg SHADOW BOTTOMLEFT SHADOWSIZE 10

oTitle:aGrdBack := { { 1, 8553215, 16777215 } }

*oTitle:lTransparent := .T.

@  20, 60  TITLETEXT OF oTitle TEXT "FIVEWIN 9.07"  FONT oFont1 BRUSH oBrush1

@  85, 40 TITLEIMG OF oTitle BITMAP "explorer.BMP" SIZE 50, 50 REFLEX ANIMA

@  85, 140 TITLEIMG OF oTitle BITMAP "keys.bmp"  SIZE 30, 30 REFLEX TRANSPARENT

@  85,  240 TITLEIMG OF oTitle BITMAP "explorer.BMP"    SIZE 50, 50 ANIMA LEVEL 100

@  85, 340  TITLEIMG  OF oTitle BITMAP "explorer.bmp" SIZE 50, 50 REFLEX TRANSPARENT ANIMA

oTitle:bLDblClick := { | nRow, nCol | BTN_ACTION( nRow, nCol, oDlg ) }

oTitle:nShadowIntensity = 70

ACTIVATE DIALOG oDlg CENTERED ;
ON INIT DLG_GRAD( oDlg, .T. )

RETURN( NIL )

// -------------  DIALOG-GRADIENT for transparent SAY  -------

FUNCTION DLG_GRAD( oDlg, lDir)
local hDC, hBmp, hBmpOld, nWidth, nHeight, oBrush

IF Empty( oDlg:oBrush:hBitmap )
      nHeight := if(lDir,oDlg:nHeight,1)
      nWidth  := if(lDir,1,oDlg:nWidth)
       hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, nHeight, nWidth, aDLG, lDir )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
ENDIF

RETURN NIL
 


Best Regards
Uwe :lol:
Last edited by ukoenig on Mon Aug 10, 2009 5:25 pm, edited 11 times 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: Background Tests

Postby ukoenig » Mon Aug 10, 2009 2:58 pm

I tested Titles with different Dialog-Backgrounds.
There seems to be a Shadow-problem with Image-Background.
All other Backgrounds are working.

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: Button-Actions added to new Class VTitle FWH 9.07

Postby Antonio Linares » Mon Aug 10, 2009 5:33 pm

Uwe,

Nice contribution :-) We should implement it as a new method of the Class TTitle

We are going to check the shadow issue, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42081
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Button-Actions added to new Class VTitle FWH 9.07

Postby Silvio » Mon Aug 10, 2009 7:21 pm

Antonio, Can Give you an idea ?

I made on my Painttitle class also animation bitmaps.....
Best Regards, Saludos

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

VTitle Background-Tests with < transparent >

Postby ukoenig » Tue Aug 11, 2009 10:11 am

Antonio,

all Tests with oTitle:lTransparent := .T.
Image-Background :

Image

Testing all possible Combinations :
Code: Select all  Expand view

FUNCTION START_DLG(oWnd,oBrush1,oFont1)
LOCAL oDlg, oTitle, hDC, oButt1

aDLG := { { 0.60, 16752190, 16777215 }, ;  
                 { 0.60, 16777215, 16752190 } }    

nMainStyle = nOR( WS_OVERLAPPED | WS_VISIBLE )
DEFINE DIALOG oDlg FROM 15, 15 TO 320, 580 OF oWnd PIXEL STYLE nMainStyle PIXEL TRANSPARENT

// Select the needed Background
// --------------------------------------
// D_COLOR( oDlg )   // Color
// DB_IMAGE( oDlg )  // Image-Brush
// D_BRUSH( oDlg )   // Style-Brush

@ 20, 20  TITLE oTitle size 242, 115 of oDlg SHADOW BOTTOMLEFT SHADOWSIZE 10

oTitle:aGrdBack := { { 1, 8553215, 16777215 } }

oTitle:lTransparent := .T.

@  20, 60  TITLETEXT OF oTitle TEXT "FIVEWIN 9.07"  FONT oFont1 BRUSH oBrush1

@  85, 40 TITLEIMG OF oTitle BITMAP "explorer.BMP" SIZE 50, 50 REFLEX ANIMA

@  85, 140 TITLEIMG OF oTitle BITMAP "keys.bmp"  SIZE 30, 30 REFLEX TRANSPARENT

@  85,  240 TITLEIMG OF oTitle BITMAP "explorer.BMP"    SIZE 50, 50 ANIMA LEVEL 100

@  85, 340  TITLEIMG  OF oTitle BITMAP "explorer.bmp" SIZE 50, 50 REFLEX TRANSPARENT ANIMA

oTitle:bLDblClick := { | nRow, nCol | BTN_ACTION( nRow, nCol, oTitle, oDlg ) }

oTitle:nShadowIntensity = 70

ACTIVATE DIALOG oDlg CENTERED ;
ON PAINT DL_IMAGE( hDC, oDlg)

*ON INIT DLG_GRAD( oDlg, .T. ) // Gradient
*ON PAINT DL_IMAGE( hDC, oDlg) // Image

RETURN( NIL )


// --------- DIALOG COLOR --------------------------------------

STATIC FUNCTION D_COLOR( oDlg )
local oNewbrush

DEFINE BRUSH oNewBrush COLOR 128
SET BRUSH OF oWnd TO oNewBrush
RELEASE BRUSH oNewbrush

RETURN NIL

//---------- DIALOG IMAGE -----------------------

FUNCTION DL_IMAGE( hDC, oDlg )
LOCAL oImage

aRect := GETCLIENTRECT( oDlg:hWnd )
@ 0, 0 IMAGE oImage SIZE aRect[4], aRect[3] OF oDlg ADJUST
oImage:Progress( .f. )
oImage:LoadBmp( "FANTASY.jpg" )

RETURN NIL

//------- DIALOG IMAGE-Brush --------------------------

FUNCTION DB_IMAGE( oDlg )
LOCAL oImage

DEFINE BRUSH oImage FILE "Paper.bmp"
SET BRUSH OF oDlg TO oImage

RETURN NIL

//------ DIALOG STYLE-Brush ---------------------------

FUNCTION D_BRUSH( oDlg )
LOCAL oBrush1

DEFINE BRUSH oBrush1  STYLE "TILED"      
SET BRUSH OF oDlg TO oBrush1
RELEASE BRUSH oBrush1

RETURN NIL

//  -------------  normal DIALOG-GRADIENT -------------------------

FUNCTION DLG_GRAD1( oDlg, hDC )

GradientFill( hDC, 0, 0, oDlg:nHeight, oDlg:nWidth, aDLG, .T. )

RETURN  ( NIL )

// -------------  DIALOG-GRADIENT for transparent SAY  -------

FUNCTION DLG_GRAD( oDlg, lDir)
local hDC, hBmp, hBmpOld, nWidth, nHeight, oBrush

IF Empty( oDlg:oBrush:hBitmap )
      nHeight := if(lDir,oDlg:nHeight,1)
      nWidth  := if(lDir,1,oDlg:nWidth)
       hDC = CreateCompatibleDC( oDlg:GetDC() )
      hBmp = CreateCompatibleBitMap( oDlg:hDC, nWidth, nHeight )
      hBmpOld = SelectObject( hDC, hBmp )
      GradientFill( hDC, 0, 0, nHeight, nWidth, aDLG, lDir )
      DeleteObject( oDlg:oBrush:hBrush )
      oDlg:oBrush:hBitmap = hBmp
      oDlg:oBrush:hBrush = CreatePatternBrush( hBmp )
      SelectObject( hDC, hBmpOld )
      oDlg:ReleaseDC()
ENDIF

RETURN NIL

// ----------------------------

FUNCTION BTN_ACTION( nRow, nCol, oTitle, oDlg )
local nAt, aPOS[Len( oTitle:aImgs )][4]

FOR nAt := 1 to Len( oTitle:aImgs )
   // Img-Height
   aPOS[Len( oTitle:aImgs )][1] := nBmpHeight( oTitle:aImgs[ nAt, 0x03 ] )
   // Img-Width
   aPOS[Len( oTitle:aImgs )][2] := nBmpWidth( oTitle:aImgs[ nAt, 0x03 ] )
   // Img-Top
   aPOS[Len( oTitle:aImgs )][3] := oTitle:aImgs[ nAt, 0x01 ]
   // Img-Left
   aPOS[Len( oTitle:aImgs )][4] := oTitle:aImgs[ nAt, 0x02 ] // Img-Left

   // msgalert( aPOS[Len( oTitle:aImgs )][1], LTRIM(STR(nAt)) + " Height" )
   // msgalert( aPOS[Len( oTitle:aImgs )][2], LTRIM(STR(nAt)) + " Width" )
   // msgalert( aPOS[Len( oTitle:aImgs )][3], LTRIM(STR(nAt)) + " Top" )
   // msgalert( aPOS[Len( oTitle:aImgs )][4], LTRIM(STR(nAt)) + " Left" )

   IF aPOS[Len( oTitle:aImgs )][3] <= nRow .and. ; // Top <= Row-Click
      aPOS[Len( oTitle:aImgs )][3] + aPOS[Len( oTitle:aImgs )][1] >= nRow .and. ; // Top + Height > Row-Click
      aPOS[Len( oTitle:aImgs )][4] <= nCol .and. ;  // Left <= Row-Click
      aPOS[Len( oTitle:aImgs )][4] + aPOS[Len( oTitle:aImgs )][2] >= nCol // Left + Width > Col-Click
      MsgAlert( "I am Button : " + LTRIM(STR(nAt)),"Attention" )
   ENDIF
NEXT

RETURN( NIL )
 


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: Button-Actions added to new Class VTitle FWH 9.07

Postby Daniel Garcia-Gil » Mon Aug 24, 2009 12:11 pm

Hello Uwe...

i think that it is correct way
we need convert image to brush
Code: Select all  Expand view

FUNCTION DL_IMAGE( hDC, oDlg )
LOCAL oImage

aRect := GETCLIENTRECT( oDlg:hWnd )

DEFINE BRUSH oImage FILE "C:\FWH\bitmaps\olga1.jpg"
SET BRUSH OF oDlg TO oImage:Resized( aRect[4], aRect[3], 1 )

RETURN NIL
 


I changed resize function at TBrush Class...
ResizeBmp to ResizeImg( hBmp, nWidth, nHeight )
This function show better image quality

Image
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Background Tests

Postby Daniel Garcia-Gil » Mon Aug 24, 2009 12:24 pm

ukoenig wrote:I tested Titles with different Dialog-Backgrounds.
There seems to be a Shadow-problem with Image-Background.
All other Backgrounds are working.

Image

Best regards
Uwe :lol:


Like a previous post...

Image
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 90 guests