How to change the cursor of a defined image-area ?

How to change the cursor of a defined image-area ?

Postby ukoenig » Tue Sep 10, 2013 6:30 am

Hello,

is it possible, to change a cursor of a defined image-area ?
( painted a second image with ABPaint on the main-image )

Image

// the main-image
DEFINE BRUSH oNewBrush ;
COLOR GradientFill( hDC, 0, 0, aRect[3], aRect[4], aGrad, lDirect )


DEFINE CURSOR oCrsHand RESOURCE "Hand"
// changes the cursor of the main-image
// oBitmap:oCursor := oCrsHand

hBitmap2 := ReadBitmap( 0, c_path1 + cBitmap2 )
ABPaint( hDC, aRect[4] - 30, nBTop, hBitmap2, 255 )
oBitmap:bLClicked = { | nRow, nCol | IIF( nCol > aRect[4] - 24, oDlg:End(), NIL ) }


Best Regards
Uwe :?:
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: How to change the cursor of a defined image-area ?

Postby Antonio Linares » Tue Sep 10, 2013 8:34 am

Uwe,

I have not tested it myself, but basically you have to define oTitle:bMMoved = { | nX, nY | CheckArea( nX, nY ) } and if the mouse is in the area where you want to change the cursor, simply do oTitle:oCursor = oHandCursor and previously DEFINE CURSOR oHandCursor HAND, setting oCursor back to nil, will make oTitle use the default cursor :-)
regards, saludos

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

Re: How to change the cursor of a defined image-area ?

Postby ukoenig » Tue Sep 10, 2013 10:33 am

Antonio,
Thank You very much.
oBitmap:bMMoved works fine,
but I had to define a extra MAIN-cursor, to switch back from HAND
The solution is included in my new MESSAGE-PAINTER

Code: Select all  Expand view

....
....
FUNCTION DRAW_TITLE( oDlg, oBitmap, nStyle, hDC, lDirect, nVColor, ;
     nBColor, nMove, cBrush, cImage, nLeft, oFont, nTColor, ;
     cTitle, lLine, lBox, nPen, nPColor, cBitmap1, nBTop, nBLeft, cBitmap2, nMultiH )

LOCAL aGrad := { { nMove, nVColor, nBColor }, { nMove, nBColor, nVColor } }
LOCAL aRect := GETCLIENTRECT( oBitmap:hWnd )
LOCAL oNewBrush, oImage, nRow := 0, nCol := 0, n, hPen, hOldPen, hBitmap1, hBitmap2

// The MAIN-image
DEFINE BRUSH oNewBrush ;
COLOR GradientFill( hDC,  0, 0, aRect[3], aRect[4], aGrad, lDirect )
// The left Image
IF !EMPTY ( cBitmap1 ) .and. FILE( c_path1 + cBitmap1 )
     hBitmap1 := ReadBitmap( 0, c_path1 + cBitmap1 )
     ABPaint( hDC, nBLeft, nBTop, hBitmap1, 255 )
ENDIF
// The EXIT-image
IF !EMPTY ( cBitmap2 ) .and. FILE( c_path1 + cBitmap2 )
     oBitmap:bMMoved = { | nX, nY | IIF( nY > aRect[4] - 24, ;
          CHANGECURS(oBitmap, .F.), ;
          CHANGECURS(oBitmap, .T.) ) }

     hBitmap2 := ReadBitmap( 0, c_path1 + cBitmap2 )
     ABPaint( hDC, aRect[4] - 30, nBTop, hBitmap2, 255 )
     oBitmap:bLClicked = { | nRow, nCol | IIF( nCol > aRect[4] - 24, oDlg:End(), NIL ) }
ENDIF
...
...

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

FUNCTION CHANGECURS(oBitmap, lShow)
LOCAL oArrow, oCrsHand

IF lShow = .F.
     DEFINE CURSOR oCrsHand  RESOURCE "Hand"
     oBitmap:oCursor := oCrsHand
ELSE
     DEFINE CURSOR oArrow  RESOURCE "Arrow"
     oBitmap:oCursor := oArrow
ENDIF

RETURN NIL
 
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: How to change the cursor of a defined image-area ?

Postby Enrico Maria Giordano » Tue Sep 10, 2013 3:40 pm

Uwe,

ukoenig wrote:
Code: Select all  Expand view
FUNCTION CHANGECURS(oBitmap, lShow)
LOCAL oArrow, oCrsHand

IF lShow = .F.
     DEFINE CURSOR oCrsHand  RESOURCE "Hand"
     oBitmap:oCursor := oCrsHand
ELSE
     DEFINE CURSOR oArrow  RESOURCE "Arrow"
     oBitmap:oCursor := oArrow
ENDIF

RETURN NIL


You are creating cursors over and over again without releasing them, if I'm not missing something.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: How to change the cursor of a defined image-area ?

Postby ukoenig » Tue Sep 10, 2013 4:10 pm

Enrico,

Thank You very much.
The Cursors are defined on Top of the App. together with the fonts.
There is only a SWITCH needed ( NO function ) :

oBitmap:bMMoved = { | nX, nY | IIF( nY > aRect[4] - 24, ;
oBitmap:oCursor := oCrsHand, ;
oBitmap:oCursor := oArrow ) }


Best Regards
Uwe :oops:
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 79 guests