FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index All products support Due problemini
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Due problemini
Posted: Fri Apr 14, 2006 10:38 PM

1) Qualcuno di voi sa dirmi se è possibile premere su un'immagine con il mouse e la procedura mi restituisce le coordinate esatte dove ha "puntato" il mouse ?

2)E' possibile creare un piccolo cerchio rosso nel punto dove ha cliccato il mouse sempre sull'immagine per determinare appunto l'area interessata ?

Best Regards, Saludos



Falconi Silvio
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Due problemini
Posted: Sat Apr 15, 2006 09:26 AM
Silvio wrote:1) Qualcuno di voi sa dirmi se è possibile premere su un'immagine con il mouse e la procedura mi restituisce le coordinate esatte dove ha "puntato" il mouse ?


Al codeblock bLClicked vengono passate automaticamente tali coordinate:

oImg:bLClicked = { | nRow, nCol | MyFunc( nRow, nCol ) }

Silvio wrote:2)E' possibile creare un piccolo cerchio rosso nel punto dove ha cliccato il mouse sempre sull'immagine per determinare appunto l'area interessata ?


Usa il codeblock di cui sopra unito ai vari esempi di cerchi che ti ho preparato in passato.

EMG
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Due problemini
Posted: Sat Apr 15, 2006 12:54 PM

Grazie Emg
cmq tu credi che si possa fare su un immagine jpg?

Best Regards, Saludos



Falconi Silvio
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Due problemini
Posted: Sat Apr 15, 2006 01:12 PM

Certo, basta utilizzare la classe TImage.

EMG

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Due problemini
Posted: Sat Apr 15, 2006 01:17 PM
mi da errore non trova hdc

Error occurred at: 08/01/03, 14:08:12
   Error description: Error BASE/1003  Variable does not exist: HDC



#include "Fivewin.ch"
#include "Image.ch"

FUNCTION MAIN() 

    LOCAL oDlg 
    Local oImg

    LOCAL nX := 100 
    LOCAL nY := 100 

    LOCAL nMinRad := 20 
    LOCAL nMaxRad := 100 

    LOCAL nStep := 10 

    DEFINE DIALOG oDlg; 
           SIZE 600, 400
           @ 0, 0 IMAGE oImg SIZE 150, 150 OF oDlg  ADJUST
             oImg:Progress( .f. )
           oImg:bLClicked = { | nRow, nCol | CIRCLES( oDlg, hDC, nRow, nCol, nMinRad, nMaxRad, nStep ) }
          @ 1, 28 BUTTON "Select Image" SIZE 50,10 OF oDlg ACTION GetImage( oImg )
    ACTIVATE DIALOG oDlg CENTER
             // ON PAINT CIRCLES( oDlg, hDC, nX, nY, nMinRad, nMaxRad, nStep );
    RETURN NIL

#define BRUSH_NULL 5

STATIC FUNCTION CIRCLES( oDlg, hDC, nX, nY, nMinRad, nMaxRad, nStep ) 

    LOCAL hOldBrush := SELECTOBJECT( hDC, GETSTOCKOBJECT( BRUSH_NULL ) ) 

    LOCAL i 

    FOR i = nMinRad TO nMaxRad STEP nStep 
        oDlg:Circle( nX - i, nY - i, i * 2 ) 
    NEXT 

    SELECTOBJECT( hDC, hOldBrush ) 

    RETURN NIL

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

function GetImage( oImg )

   local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ;
                             "DIB   (*.dib)| *.dib|" +          ;
                             "PCX   (*.pcx)| *.pcx|"  +         ;
                             "JPEG  (*.jpg)| *.jpg|" +          ;
                             "GIF   (*.gif)| *.gif|"  +         ;
                             "TARGA (*.tga)| *.tga|" +          ;
                             "RLE   (*.rle)| *.rle|" +          ;
                             "All Files (*.*)| *.*"             ;
                            ,"Please select a image file", 4 )

   if ! Empty( gcFile ) .and. File( gcFile )
      oImg:LoadBmp( gcFile )
   endif

return nil




[/code]
Best Regards, Saludos



Falconi Silvio
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Due problemini
Posted: Sat Apr 15, 2006 01:26 PM

Devi utilizzare i metodi

hDC = oDlg:GetDC()

e alla fine

oDlg:ReleaseDC()

EMG

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Due problemini
Posted: Sat Apr 15, 2006 01:33 PM

ma dentro alla funzione circle ?
o in main

ma perchè non se lo prende da solo ?

Best Regards, Saludos



Falconi Silvio
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Due problemini
Posted: Sat Apr 15, 2006 02:00 PM

Dentro la funzione Circle(). Non se la prende da solo perché non sei nella ON PAINT. Guardati le classi. Ci sono quanti esempi vuoi di questa tecnica.

EMG

Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Due problemini
Posted: Sat Apr 15, 2006 02:05 PM

SCUSAMI MA
l'avevo già messa dentro circle ma mi dava errore lo stesso
cmq dopo il caffè riprovo....

cmq BUONA PASQUA A TE E ALLA TUA FAMIGLIA

Best Regards, Saludos



Falconi Silvio
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Due problemini
Posted: Sat Apr 15, 2006 02:12 PM
Così funziona:

#include "Fivewin.ch" 
#include "Image.ch" 

FUNCTION MAIN() 

    LOCAL oDlg 
    Local oImg 

    LOCAL nX := 100 
    LOCAL nY := 100 

    LOCAL nMinRad := 20 
    LOCAL nMaxRad := 100 

    LOCAL nStep := 10 

    DEFINE DIALOG oDlg; 
           SIZE 600, 400 
           @ 0, 0 IMAGE oImg SIZE 150, 150 OF oDlg  ADJUST 
             oImg:Progress( .f. ) 
           oImg:bLClicked = { | nRow, nCol | CIRCLES( oDlg, nRow, nCol, nMinRad, nMaxRad, nStep ) } 
          @ 1, 28 BUTTON "Select Image" SIZE 50,10 OF oDlg ACTION GetImage( oImg ) 
    ACTIVATE DIALOG oDlg CENTER 
             // ON PAINT CIRCLES( oDlg, hDC, nX, nY, nMinRad, nMaxRad, nStep ); 
    RETURN NIL 

#define BRUSH_NULL 5 

STATIC FUNCTION CIRCLES( oDlg, nX, nY, nMinRad, nMaxRad, nStep ) 

    LOCAL hDC := oDlg:GetDC()

    LOCAL hOldBrush := SELECTOBJECT( hDC, GETSTOCKOBJECT( BRUSH_NULL ) ) 

    LOCAL i 

    FOR i = nMinRad TO nMaxRad STEP nStep 
        oDlg:Circle( nX - i, nY - i, i * 2 ) 
    NEXT 

    SELECTOBJECT( hDC, hOldBrush ) 

    oDlg:ReleaseDC()

    RETURN NIL 

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

function GetImage( oImg ) 

   local gcFile := cGetFile( "Bitmap (*.bmp)| *.bmp|" +         ; 
                             "DIB   (*.dib)| *.dib|" +          ; 
                             "PCX   (*.pcx)| *.pcx|"  +         ; 
                             "JPEG  (*.jpg)| *.jpg|" +          ; 
                             "GIF   (*.gif)| *.gif|"  +         ; 
                             "TARGA (*.tga)| *.tga|" +          ; 
                             "RLE   (*.rle)| *.rle|" +          ; 
                             "All Files (*.*)| *.*"             ; 
                            ,"Please select a image file", 4 ) 

   if ! Empty( gcFile ) .and. File( gcFile ) 
      oImg:LoadBmp( gcFile ) 
   endif 

return nil


EMG
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Due problemini
Posted: Sat Apr 15, 2006 03:26 PM
si c'ero gia arrivato
Ma...
hai visto cosa fa ?

se io premo in 145,145 lui crea il cerchio a 137 circa

io ho inserito per vedere se crea il cerchio nelle cordinate giuste :
prima :

oImg:bLClicked = { | nRow, nCol |( NMSGBOX(NrOW,NcOL),CIRCLES( oDlg, nRow, nCol, nMinRad, nMaxRad, nStep )) }

e poi nella funzione circle

// PER FARE UN CERCHIETTO
oDlg:Circle( nX , nY , 50 )
? NX
?NY

ho levato i cerchi concentrici in questo programma mi serve un solo cerchio( rosso/verde) max 50/60 di diametro

Best Regards, Saludos



Falconi Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Due problemini
Posted: Sat Apr 15, 2006 03:28 PM
la funzione circle è stata moificata cosi :

STATIC FUNCTION CIRCLES( oDlg, nX, nY, nMinRad, nMaxRad, nStep )
    LOCAL   hDC := oDlg:GetDC()
    LOCAL hOldBrush := SELECTOBJECT( hDC, GETSTOCKOBJECT( BRUSH_NULL ) )

 


         // PER FARE UN CERCHIETTO
       oDlg:Circle( nX , nY , 50 )
       ? NX
       ?NY
    SELECTOBJECT( hDC, hOldBrush )
             oDlg:ReleaseDC()
    RETURN NIL
Best Regards, Saludos



Falconi Silvio

Continue the discussion