FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) Defining labels, checkboxes and so on by macro substitution
Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Defining labels, checkboxes and so on by macro substitution
Posted: Mon Sep 26, 2016 06:38 PM
Is it possible to define labels and checkboxes with macrosubstitution. Sometimes I want to define several labels images and chackboxes in a FOR NEXT loop.
Code (fw): Select all Collapse
    LOCAL nFoto := 1
        FOR r = 1 TO 3
        FOR k = 1 TO 5
            cImage := aFotoNaam[nFoto]
            oImgName := 'oImg' + STR(nFoto)
            IF FILE(cImage)
                @ nRow, nColumn IMAGE &oImgName FILENAME cImage OF oFld:aControls[ 3 ] SIZE 110, 110
                &oImgName:bLButtonDown = { || RK_FotoGroot( cImageGroot ) }
            ENDIF
            nColumn := nColumn + 120
            nFoto++
        NEXT
        nColumn := 10
        nRow := nRow - 120
    NEXT

Is this possible?
Kind regards,



René Koot
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Defining labels, checkboxes and so on by macro substitution
Posted: Mon Sep 26, 2016 06:46 PM

Rene,

It seems to compile fine

Do you get an error at runtime ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Defining labels, checkboxes and so on by macro substitution
Posted: Mon Sep 26, 2016 06:51 PM

Yes. Just move the GET command to a function passing it the index as parameter. I had a sample but I couldn't find it... :-(

EMG

Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Defining labels, checkboxes and so on by macro substitution
Posted: Mon Sep 26, 2016 08:09 PM
Yes, I did get an error on compiling. The name of the object was not correct.

oImgName := 'oImg' + STR(nFoto) -> oImgName := 'oImg' + ALLTRIM(STR(nFoto))

But in another function can I retrieve the name of the object, this doesn't work:
Code (fw): Select all Collapse
    FOR r = 1 TO 3
        FOR k = 1 TO 5
            cImage := aFotoNaam[nFoto]
            oImgName := 'oImg' + ALLTRIM(STR(nFoto))
            IF FILE(cImage)
                @ nRow, nColumn IMAGE &oImgName FILENAME cImage OF oFld:aControls[ 3 ] SIZE 110, 110
                &oImgName:bLButtonDown = { || RK_FotoGroot( oImgName ) }
            ENDIF
            nColumn := nColumn + 120
            nFoto++
        NEXT
        nColumn := 10
        nRow := nRow - 120
    NEXT

FUNCTION RK_FotoGroot(cImage)
*to show a big picture

LOCAL oWndFoto
LOCAL oFoto
LOCAL nWidth := 0
MsgInfo(cImage) <--this gives always oImg15
Kind regards,



René Koot
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Defining labels, checkboxes and so on by macro substitution
Posted: Mon Sep 26, 2016 09:00 PM

You have to use a detached local:

&oImgName:bLButtonDown = CreateBlock( oImgName )

...

function CreateBlock( cName )

return { || RK_FotoGroot( cName ) }

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Defining labels, checkboxes and so on by macro substitution
Posted: Tue Sep 27, 2016 08:16 AM

You didn't make as I said. You have to take the GET command and move it to a separate function.

EMG

Posts: 166
Joined: Wed Nov 25, 2015 07:13 PM
Re: Defining labels, checkboxes and so on by macro substitution
Posted: Tue Sep 27, 2016 08:40 PM
Hello Antonio,
The detached local function works perfect. Now I only want to make the image bigger or smaller. The window resizing goes well, but not the image.

Code (fw): Select all Collapse
FUNCTION RK_FotoGroot(cImage)
*to show a big picture

LOCAL oWndFoto
LOCAL oFoto
LOCAL nFoto := VAL(SUBSTR(cImage, 5))
LOCAL cFoto := aFotoNaam[nFoto]
LOCAL nWidth := 80
LOCAL nHeight := 80

    DEFINE DIALOG oWndFoto TITLE "big picture" ;
        FROM 0, 0 TO 10, 10
        
        @ 40, 10 IMAGE oFoto FILENAME cFoto OF oWndFoto SIZE 640, 480

        nWidth := oFoto:GetWidth()    && I suppose I can get the Width and Height of the image after defining it?
        nHeight := oFoto:GetHeight()
*       oFoto:Size(nHeight, nWidth)
        oWndFoto:ChangeSize( nHeight+40, nWidth+20)
                
        @ 10, 250 BUTTON "Zoom" OF oWndFoto ACTION { || oFoto:SetScaling(1) }

    ACTIVATE DIALOG oWndFoto

RETURN NIL

Also I want to use the SetScaling in a button, so I can zoom the image. Any solution?
Kind regards,



René Koot
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Defining labels, checkboxes and so on by macro substitution
Posted: Tue Sep 27, 2016 09:00 PM

Rene,

Try it this way:

oFoto:SetSize( nWidth, nHeight )

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion