I started with the new Vtitle-Class and added Button-Actions :
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