Controls automatic alignments

Controls automatic alignments

Postby Enrico Maria Giordano » Sat Feb 10, 2007 5:57 pm

This is a sample showing how to automatize the alignment of source-code-defined controls:

Code: Select all  Expand view
#include "Fwce.ch"


FUNCTION MAIN()

    LOCAL oWnd

    LOCAL cli := SPACE( 35 )
    LOCAL ind := SPACE( 35 )

    DEFINE WINDOW oWnd;
           TITLE "Test"

    @ 1, 0 SAY "Cliente:"

    @ 1, 7 COMBOBOX cli;
           SIZE 100, 20

    @ 1, 28 BUTTON "Test1";
            SIZE 45, 20

    @ 2, 0 BUTTON "Nuovo";
           SIZE 50, 20

    @ 2, 9 BUTTON "Cambia";
           SIZE 50, 20

    @ 2, 18 BUTTON "Chiudi";
            SIZE 50, 20

    @ 2, 27 BUTTON "Svuota";
            SIZE 50, 20

    @ 2, 36 BUTTON "C";
            SIZE 24, 20

    @ 3, 0 LISTBOX FIELDS;
           SIZE 240, 125

    @ 9, 0 SAY "Indirizzo:"

    @ 9, 7 COMBOBOX Ind;
           SIZE 100, 20

    @ 9, 28 BUTTON "Test2";
            SIZE 45, 20

    @ 12, 0 SAY "Indirizzo:"

    @ 12, 7 COMBOBOX Ind;
            SIZE 100, 20

    @ 12, 28 BUTTON "Test2";
             SIZE 45, 20

    ACTIVATE WINDOW oWnd;
             ON INIT ADJCTRLS( oWnd )

    RETURN NIL


STATIC FUNCTION ADJCTRLS( oWnd )

    LOCAL oCtl, nTop, nHeight

    LOCAL i

    IF EMPTY( oWnd:aControls ); RETURN NIL; ENDIF

    FOR i = 1 TO LEN( oWnd:aControls )
        oCtl = oWnd:aControls[ i ]

        nTop = ( oCtl:nTop - 11 ) * 1.41
        nHeight = oCtl:nHeight

        DO CASE
            CASE oCtl:ClassName = "TBUTTON"
                nTop = ( nTop - 4 ) * 0.83
                nHeight *= 0.96
            CASE oCtl:ClassName = "TCOMBOBOX"
                nTop = ( nTop - 1 ) * 1.07
            CASE oCtl:ClassName = "TGET"
                nTop *= 1.15
            CASE oCtl:ClassName = "TSAY"
                nTop -= 2
            CASE oCtl:ClassName = "TWBROWSE"
                nTop *= 1.07
        ENDCASE

        oCtl:Move( nTop, oCtl:nLeft, oCtl:nWidth, nHeight )
    NEXT

    RETURN NIL


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

Postby Antonio Linares » Sat Feb 10, 2007 6:26 pm

Enrico,

Thanks
regards, saludos

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


Return to FiveWin for Pocket PC

Who is online

Users browsing this forum: No registered users and 4 guests