Defining labels, checkboxes and so on by macro substitution

Defining labels, checkboxes and so on by macro substitution

Postby plantenkennis » Mon Sep 26, 2016 6: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: Select all  Expand view
    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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

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

Postby Antonio Linares » Mon Sep 26, 2016 6:46 pm

Rene,

It seems to compile fine

Do you get an error at runtime ?
regards, saludos

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

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

Postby Enrico Maria Giordano » Mon Sep 26, 2016 6: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
User avatar
Enrico Maria Giordano
 
Posts: 8243
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

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

Postby plantenkennis » Mon Sep 26, 2016 8: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: Select all  Expand view
    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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

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

Postby Antonio Linares » Mon Sep 26, 2016 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41205
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Enrico Maria Giordano » Tue Sep 27, 2016 8:16 am

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

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

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

Postby plantenkennis » Tue Sep 27, 2016 8: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: Select all  Expand view
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
plantenkennis
 
Posts: 166
Joined: Wed Nov 25, 2015 7:13 pm
Location: the Netherlands

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

Postby Antonio Linares » Tue Sep 27, 2016 9:00 pm

Rene,

Try it this way:

oFoto:SetSize( nWidth, nHeight )
regards, saludos

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


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 5 guests