CONTROLS IN A WINDOW

User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

CONTROLS IN A WINDOW

Post by Silvio »

I must create a window with a wbrowse ( size 450,450) and many buttons

I wanted that the user when shrink the window or increase the window with the mouse the procedure must repaint all the controls (lbx and buttons) :

there is an sample work as it ?

regards
Best Regards, Saludos

Falconi Silvio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Silvio,

Windows may do it automatically, if you want to force it then you can do oWnd:Refresh()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

ok ,
perhaps you not understand me
or I not I explain you well
I'm sorry for my english...


when I shrink the window or increase the window with the mouse all controls on this window(olbx and buttons) must be shrunk theyself
I can see a small window but I can see all the controls of the window

YOu have understand now ?
Best Regards, Saludos

Falconi Silvio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Silvio,

Do you mean that you want the controls to resize as the window resizes too ? If yes, then you have to code it yourself. Its not difficult.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

yes you have understand NOw !!!!

Can I have a small sample ?

Is there an sample of this on samples of fwh ?
Best Regards, Saludos

Falconi Silvio
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Silvio,

You have to change the position of the controls changing DATAs nTop, nLeft and dimensions using DATAs nWidth and nHeight. i.e.:

for n ...
oWnd:aControls[ n ]:nTop = ...
oWnd:aControls[ n ]:nLeft = ...
oWnd:aControls[ n ]:nWidth = ...
oWnd:aControls[ n ]:nHeight = ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

CAN i USE THE CLAUSOLE :
ACTIVATE WINDOWS OwND ;
ON RESIZE....

BUT i NOT kNOW HOW MAKE IT
LOOK THIS TEST SAMPLE :

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN() 

    LOCAL oWnd 

    LOCAL aBtn := {} 

    LOCAL n := 1 

    LOCAL i, j

    DEFINE WINDOW oWnd

        @20,5 LISTBOX oLbx FIELDS "";
                         HEADER "ARTICOLO",  "QTA",  ;
                                "PREZZO", "TOTALE"                     ;
                         OF oWnd SIZE 200,200 PIXEL                     ;
                         SIZES  230, 80,90,90



                MAKEBUTTON( 10,40, 10 )

    ACTIVATE WINDOW oWnd

    RETURN NIL 


STATIC FUNCTION MAKEBUTTON( nRow, nCol, n )

    LOCAL oBtn

    @ nRow, nCol BUTTON oBtn PROMPT "Test";
                 SIZE 200, 50;
                 ACTION MAKEMENU( oBtn, n )

    RETURN oBtn 


STATIC FUNCTION MAKEMENU( oBtn, n ) 

    LOCAL oMenu 

    MENU oMenu POPUP 
        MENUITEM "Button number?" ACTION MSGINFO( n ) 
    ENDMENU 

    ACTIVATE MENU oMenu AT 0, 0 OF oBtn 

    RETURN NIl

WHERE I CAN MODIFY IT TO RESIZE THW WINDOW AND MY ALL CONTROLS ?

REGARDS
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

I try this but if I try the program make the same :

Code: Select all

function Main()

   local oBar

   DEFINE WINDOW oWnd MDI ;
      TITLE "Browsing a DataBase"

   DEFINE BUTTONBAR oBar 3D OF oWnd

   DEFINE BUTTON OF oBar ACTION CustomerBrowse()

   SET MESSAGE OF oWnd TO "FiveWin xBase power!" CENTERED

   ACTIVATE WINDOW oWnd MAXIMIZED

   return nil
FUNCTION CustomerBrowse()
LOCAL  oWndChild,oFont,oFont2,oFont3

 DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, -20
  DEFINE FONT oFont2 NAME "MS Sans Serif" SIZE 0, -40
  DEFINE FONT oFont3 NAME "ARIAL" SIZE 0, -50


  DEFINE WINDOW oWndChild  COLOR GetSysColor(13), GetSysColor(1)
  *STYLE nOr( WS_POPUP, WS_VISIBLE ) COLOR GetSysColor(13), GetSysColor(1)


@20,5 LISTBOX oLbx FIELDS "";
                         HEADER "ARTICOLO",  "QTA",  ;
                                "PREZZO", "TOTALE"                     ;
                         OF oWndChild SIZE 650,600 PIXEL                     ;
                         SIZES  230, 80,90,90;
                         FONT oFont




  makebuttons(20,660,oWndChild,oFont,oLBX)


  ACTIVATE WINDOW oWndChild MAXIMIZED;
  ON RESIZE RESIZE_WINDOW(oWndChild)
RETURN NIL





STATIC FUNCTION  makebuttons(X,y,ownd,oFont,oLBX)
   LOCAL k


   BOTTONI :=40     // but I want see 160 buttons !!!!!!!!!!!!!



                 n  := 1
                 aBtn := Array(BOTTONI)
                 X = 20
                 Y = 660

                USE LISTBAR Alias LISTBAR INDEX BAR


                 FOR k := 1 TO BOTTONI
                    cCaption := ""

                       nBottone:=n
                      LISTBAR->(DbSeek(nBottone))
                      cCaption := AllTrim(LISTBAR->CODICE)

                       IF !Empty( cCaption )

              @ X+2  ,Y BUTTON aBtn[n] PROMPT cCaption OF oWnd FONT oFont ;
              SIZE 140,85 PIXEL
           ELSE
                 @ X+2  ,Y BUTTON aBtn[n] PROMPT Str(nBottone,3,0) OF oWnd FONT oFont ;
              SIZE 140,85 PIXEL

                 ENDIF

                     /*
                              aBtn[n]:bAction := {|oBtn| AddLbx(oGet,oBtn,oLbx) }


                              IF !Empty(cCaption )
                                   aBtn[n]:cargo := { 'Full', n }
                                ELSE
                                   aBtn[n]:cargo := { 'Empty', n }
                                ENDIF

*/









                   X +=85
                    n++
                    // LISTBAR->(dbskip())
                    IF n= 11  .OR. n=21 .OR. n=31  .OR. n=41
                        X=20
                       Y=Y+145
                    ENDIF





                    NEXT



                    // bottoni per le pagine ???????
                    // ma come cambiare pagina ??????
                    // Pagina1  da 1a 40
                    // pagina 2 da 41 a 80
                    // pagina 3 da 81 a 120
                    // pagina 4 da 121 a 160

                     X=900
                    y=660
                @ X+2  ,Y BUTTON aPag1 PROMPT PAGINA1  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION Pagina1( oWnd )
                Y=Y+145

                 @ X+2  ,Y BUTTON aPag2 PROMPT PAGINA2  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION Pagina2( oWnd )
                 Y=Y+145
                @ X+2  ,Y BUTTON aPag1 PROMPT PAGINA3  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION Pagina3( oWnd )
                     Y=Y+145
                 @ X+2  ,Y BUTTON aPag1 PROMPT PAGINA4  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION SUBTOTALE(oWnd)

               * CLOSE LISTBAR
               * Select 1




                // PULSANTE FINE
                @ 980 ,1100 BUTTON aSTOR PROMPT "USCITA" OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL  ACTION oWnd:END()

                  * oWnd:SetControl( aBtn )

                RETURN NIL

           function Pagina1( oWnd )

         local n

         for n = 2 to 41
            oWnd:aControls[ n ]:SetText( AllTrim( Str( n -1) ) )
         next

      return nil





   FUNCTION RESIZE_WINDOW(oWndChild)

      // on resize
    for n = 1 to 41

 oWndChild:aControls[ n ]:nTop = (oWndChild:aControls[ n ]:nTop )-2
 oWndChild:aControls[ n ]:nLeft = ( oWndChild:aControls[ n ]:nLeft)-2
 oWndChild:aControls[ n ]:nWidth = ( oWndChild:aControls[ n ]:nWidth)-1
 oWndChild:aControls[ n ]:nHeight = (oWndChild:aControls[ n ]:nHeight)-1

      next
     * oWndChild:refresh()
        RETURN nil

Dear Antonio,
Can Help me
Best Regards, Saludos

Falconi Silvio
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

I don't know what you exactly want to do but this is a sample that can give you at least some ideas:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd

    LOCAL cVar := SPACE( 35 )

    DEFINE WINDOW oWnd

    @ 1, 1 GET cVar

    @ 6, 1 BUTTON "&Close";
           ACTION oWnd:End()

    ACTIVATE WINDOW oWnd;
             ON RESIZE RESIZECONTROLS( oWnd );

    RETURN NIL


STATIC FUNCTION RESIZECONTROLS( oWnd )

    LOCAL oCtl

    LOCAL i

    STATIC aRMarg := {}
    STATIC aBMarg := {}

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

            AADD( aRMarg, oWnd:nWidth() - ( oCtl:nLeft + oCtl:nWidth() ) )
            AADD( aBMarg, oWnd:nHeight() - ( oCtl:nTop + oCtl:nHeight() ) )
        NEXT
    ENDIF

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

        oCtl:Move( oCtl:nTop, oCtl:nLeft, oWnd:nWidth() - aRMarg[ i ], oWnd:nHeight() - aBMarg[ i ], .T. )
    NEXT

    RETURN NIL
EMG
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

I suppose that the goal is that when the window is reduced with 50% , also the objects (nWidth , nHeight) are reduced with 50%

Same can be done with ntop , nleft

Frank

Code: Select all

# include "Fivewin.ch" 


FUNCTION MAIN() 

    LOCAL oWnd 

    LOCAL cVar := SPACE( 35 ) 

    DEFINE WINDOW oWnd 

    @ 1, 1 GET cVar 

    @ 6, 1 BUTTON "&Close"; 
           ACTION oWnd:End() 

    ACTIVATE WINDOW oWnd; 
             ON RESIZE RESIZECONTROLS(nSizeType,nWidth,nHeight,oWnd ); 

    RETURN NIL 


STATIC FUNCTION RESIZECONTROLS(nSizeType,nWidth,nHeight, oWnd ) 

LOCAL oCtl 

LOCAL i

STATIC aWidth  := {}
STATIC aHeight := {}
		 
STATIC StartWidth , StartHeight


IF EMPTY( aWidth ) 
   FOR EACH oCtl IN oWnd:aControls 
      AADD( aWidth , oCtl:nWidth() )
      AADD( aHeight , oCtl:nHeight() )
   NEXT 
   StartWidth  := oWnd:nWidth()
   StartHeight := oWnd:nHeight()
ENDIF 
FOR EACH oCtl IN oWnd:aControls 
  i := Hb_EnumIndex()
  oCtl:Move( oCtl:nTop, oCtl:nLeft, aWidth[i]* oWnd:nWidth()/StartWidth , aHeight[i] * oWnd:nHeight()/StartHeight , .T. )        
NEXT 

RETURN NIL
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

OK
i WANTED TO RESIZE ALL CONTROLS ON THE WND
i MADE A WINDOW MAXIMIZED BUT i WANTED THE USER CAN RESIZE THE WINDOW TO A SMALL WINDOW SEEING ALL THE CONTROLS AND OPERATING INTO

i TRY YOUR SAMPLE WITH MY MODIFIES

Code: Select all

# include "Fivewin.ch"

#define PAGINA1     "Pag1"
#define PAGINA2     "Pag2"
#define PAGINA3     "Pag3"
#define PAGINA4     "Pag4"

FUNCTION MAIN() 

    LOCAL oWnd ,oLbx ,oFont

    LOCAL cVar := SPACE( 35 ) 

    DEFINE WINDOW oWnd
              DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, -20

    @20,5 LISTBOX oLbx FIELDS "";
                         HEADER "ARTICOLO",  "QTA",  ;
                                "PREZZO", "TOTALE"                     ;
                         OF oWnd SIZE 650,600 PIXEL                     ;
                         SIZES  230, 80,90,90  ;
                         FONT oFont




             makebuttons(20,660,oWnd,oFont,oLBX)




    ACTIVATE WINDOW oWnd MAXIMIZED;
             ON RESIZE RESIZECONTROLS(nSizeType,nWidth,nHeight,oWnd );

    RETURN NIL


STATIC FUNCTION RESIZECONTROLS(nSizeType,nWidth,nHeight, oWnd ) 

LOCAL oCtl

LOCAL i

STATIC aWidth  := {}
STATIC aHeight := {}

STATIC StartWidth , StartHeight


IF EMPTY( aWidth )
   FOR EACH oCtl IN oWnd:aControls
      AADD( aWidth , oCtl:nWidth() )
      AADD( aHeight , oCtl:nHeight() )
   NEXT
   StartWidth  := oWnd:nWidth()
   StartHeight := oWnd:nHeight()
ENDIF
FOR EACH oCtl IN oWnd:aControls
  i := Hb_EnumIndex()
  oCtl:Move( oCtl:nTop, oCtl:nLeft, aWidth[i]* oWnd:nWidth()/StartWidth , aHeight[i] * oWnd:nHeight()/StartHeight , .T. )
NEXT

RETURN NIL



  STATIC FUNCTION  makebuttons(X,y,ownd,oFont,oLBX)
   LOCAL k


   BOTTONI :=40     // but I want see 160 buttons !!!!!!!!!!!!!



                 n  := 1
                 aBtn := Array(BOTTONI)
                 X = 20
                 Y = 660

                USE LISTBAR Alias LISTBAR INDEX BAR


                 FOR k := 1 TO BOTTONI
                    cCaption := ""

                       nBottone:=n
                      LISTBAR->(DbSeek(nBottone))
                      cCaption := AllTrim(LISTBAR->CODICE)

                       IF !Empty( cCaption )

              @ X+2  ,Y BUTTON aBtn[n] PROMPT cCaption OF oWnd FONT oFont ;
              SIZE 140,85 PIXEL
           ELSE
                 @ X+2  ,Y BUTTON aBtn[n] PROMPT Str(nBottone,3,0) OF oWnd FONT oFont ;
              SIZE 140,85 PIXEL

                 ENDIF

                     /*
                              aBtn[n]:bAction := {|oBtn| AddLbx(oGet,oBtn,oLbx) }


                              IF !Empty(cCaption )
                                   aBtn[n]:cargo := { 'Full', n }
                                ELSE
                                   aBtn[n]:cargo := { 'Empty', n }
                                ENDIF

*/









                   X +=85
                    n++
                    // LISTBAR->(dbskip())
                    IF n= 11  .OR. n=21 .OR. n=31  .OR. n=41
                        X=20
                       Y=Y+145
                    ENDIF





                    NEXT



                    // bottoni per le pagine ???????
                    // ma come cambiare pagina ??????
                    // Pagina1  da 1a 40
                    // pagina 2 da 41 a 80
                    // pagina 3 da 81 a 120
                    // pagina 4 da 121 a 160

                     X=900
                    y=660
                @ X+2  ,Y BUTTON aPag1 PROMPT PAGINA1  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION Pagina1( oWnd )
                Y=Y+145

                 @ X+2  ,Y BUTTON aPag2 PROMPT PAGINA2  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION Pagina2( oWnd )
                 Y=Y+145
                @ X+2  ,Y BUTTON aPag1 PROMPT PAGINA3  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION Pagina3( oWnd )
                     Y=Y+145
                 @ X+2  ,Y BUTTON aPag1 PROMPT PAGINA4  OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL
              *ACTION SUBTOTALE(oWnd)

               * CLOSE LISTBAR
               * Select 1




                // PULSANTE FINE
                @ 980 ,1100 BUTTON aSTOR PROMPT "USCITA" OF oWnd FONT oFont ;
              SIZE 140,50 PIXEL  ACTION oWnd:END()

                  * oWnd:SetControl( aBtn )

                RETURN NIL







BUT NOT WORK GOOD !!

WHEN i RESIZE THE WINDOW i WANT SEE ALL THE CONTROLS !!!!
i THINK IT MUST CHANGE ALL THE COORDINATES X,Y OF EACH CONTROLS ?

CAN YOU HELP ME ?
Best Regards, Saludos

Falconi Silvio
User avatar
Ugo
Posts: 283
Joined: Sat Oct 15, 2005 6:40 am
Location: Turin, Italy

Post by Ugo »

Try it:

Code: Select all

...
  ACTIVATE WINDOW oDlg MAXIMIZED ON INIT ResizeDlg( oCassa )
...

Code: Select all

// Now set the default oDlg measure
#define WIN_DEFAULT_WIDTH  1280
#define WIN_DEFAULT_HEIGHT 1024

STATIC FUNCTION ResizeDlg( oDlg )

   LOCAL nXZoom, nYZoom, nWidth, nHeight

   nXZoom    := WndWidth( GetDesktopWindow() )  / WIN_DEFAULT_WIDTH
   nYZoom    := WndHeight( GetDesktopWindow() ) / WIN_DEFAULT_HEIGHT

   AEval( oDlg :aControls, {| a | a:nTop *= nYZoom, a:nHeight *= nYZoom, a:nLeft *= nXZoom, a:nWidth *= nXZoom } )

   RETURN Nil
It is good? :wink:

This code don't resize the Font of the control :-(
Ciao, best regards,
Ugo
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

the sample not work for me

the samples of emg and frank is good but if I rezise the window the procedura must resize all the controls and I must see all ( listbox, button,get ecc.) into smal window if you open outlook window and resize it you can see al the controls smaller into small window and you could operate into.

I hope you understand me ....

the sample od EMG is good but the button rest on x.y initial but the must move to left if I resize the window on the left ....
Best Regards, Saludos

Falconi Silvio
Frank Demont
Posts: 142
Joined: Sun Oct 09, 2005 10:59 am

Post by Frank Demont »

Also nTop and nleft can be changed

Code: Select all

STATIC FUNCTION RESIZECONTROLS(nSizeType,nWidth,nHeight, oWnd ) 

    LOCAL oCtl 

    LOCAL i , aHlp[4] , j , Factor := Hash()

		STATIC aCoordinates := {}
		 
		STATIC StartWidth , StartHeight


    IF EMPTY( aCoordinates ) 
				FOR EACH oCtl IN oWnd:aControls
						AADD(aCoordinates , Array(4))
						i := Hb_EnumIndex() //LEN(aCoordinates)          
						aCoordinates[i,1] := oCtl:nTop
						aCoordinates[i,2] := oCtl:nLeft
						aCoordinates[i,3] := oCtl:nWidth()
						aCoordinates[i,4] := oCtl:nHeight()
        NEXT 
    		StartWidth  := oWnd:nWidth()
				StartHeight := oWnd:nHeight()
		ENDIF 
		Factor["H"] := oWnd:nWidth()/StartWidth
		Factor["V"] := oWnd:nHeight()/StartHeight
		FOR EACH oCtl IN oWnd:aControls
				i := Hb_EnumIndex()
				aHlp[1] := aCoordinates[i,1]*Factor["V"]
				aHlp[2] := aCoordinates[i,2]*Factor["H"]
				aHlp[3] := aHlp[1] + aCoordinates[i,3]*Factor["H"]
				aHlp[4] := aHlp[2] + aCoordinates[i,4]*Factor["V"]
        oCtl:Move( aHlp[1] , aHlp[2] , aHlp[3] , aHlp[4] , .T. ) 
    NEXT 

    RETURN NIL 

Frank
Last edited by Frank Demont on Sat Aug 12, 2006 3:10 pm, edited 1 time in total.
User avatar
Silvio
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Post by Silvio »

GOOOOOOOODDD MR FRANK

How I can make to resize also the font into listbox and buttons ?

I use only this font into wnd

DEFINE FONT oFont NAME "MS Sans Serif" SIZE 0, -20



BEST BEST REGARDS
Best Regards, Saludos

Falconi Silvio
Post Reply