Defining labels, checkboxes and so on by macro substitution

Post Reply
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Defining labels, checkboxes and so on by macro substitution

Post by plantenkennis »

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: Select all

    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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Defining labels, checkboxes and so on by macro substitution

Post by Antonio Linares »

Rene,

It seems to compile fine

Do you get an error at runtime ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Defining labels, checkboxes and so on by macro substitution

Post by Enrico Maria Giordano »

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
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: Defining labels, checkboxes and so on by macro substitution

Post by plantenkennis »

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: Select all

    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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Defining labels, checkboxes and so on by macro substitution

Post by Antonio Linares »

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
User avatar
plantenkennis
Posts: 151
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands
Contact:

Re: Defining labels, checkboxes and so on by macro substitution

Post by plantenkennis »

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: Select all

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Defining labels, checkboxes and so on by macro substitution

Post by Antonio Linares »

Rene,

Try it this way:

oFoto:SetSize( nWidth, nHeight )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply