use FMG more than once

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

User avatar
andyglezl
Posts: 1191
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 37 times
Been thanked: 85 times
Contact:

Re: use FMG more than once

Post by andyglezl » Wed Nov 27, 2019 5:31 am

mmmm...
Senti curiosidad por el manejo de las formas FMG y me puse a la tarea de ver como funcionaban.

Pero resulta que como nunca las había manejado, no sabía de donde salian, y veo que el IDE de HMG
las genera, pero como tampoco nunca he manejado el IDE, pues quede en las mismas.

Tomando como base el ejemplo compartido por EDK, (Gracias !)
( https://www.hmgforum.com/viewtopic.php? ... 105#p60105 )
empece a programarlo de la forma en que yo lo se hacer y pues esto resulto.

P.D. Tengo el problema de que al dar doble click en el GRID, deja de funcionar el ratón en el mismo GRID.
Si señalo con el ratón y oprimo la tecla ENTER, si funciona bien.

(Se tratara de un bug ?)
A ver si alguien le encuentra solución y nos la comparte. ;)
*------------------------------------------------------------------------------
mmm...
I was curious about the handling of FMG forms and I
put the task to see how they worked.

But it turns out that since I had never handled them, I didn't know where they came from, and I see that the HMG
IDE generates them, but neither have I ever managed the IDE, then stay in them.

Based on the example shared by EDK, (Thanks !)
( https://www.hmgforum.com/viewtopic.php? ... 105#p60105 )
I started to program it the way I know how to do it, and this resulted.

P.S. I have the problem that by double clicking on the GRID,
the mouse stops working on the same GRID.
If I point the mouse and press the ENTER key, it works fine.

(Is it a bug?)
Let's see if someone finds a solution and shares it with us. ;)


2019-11-26.png
2019-11-26.png (59.24 KiB) Viewed 200 times
Main.zip
(2.17 KiB) Downloaded 29 times
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
serge_girard
Posts: 2371
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 628 times
Been thanked: 126 times
Contact:

Post by serge_girard » Wed Nov 27, 2019 7:24 am

Andrés,
P.S. I have the problem that by double clicking on the GRID,
the mouse stops working on the same GRID.
If I point the mouse and press the ENTER key, it works fine.
I sometimes have the same problem and can not find cause and solution. I live with it....

Serge

User avatar
AUGE_OHR
Posts: 290
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 32 times
Been thanked: 39 times

Post by AUGE_OHR » Wed Nov 27, 2019 11:04 pm

hi,
andyglezl wrote:
Wed Nov 27, 2019 5:31 am
I started to program it the way I know how to do it, and this resulted.
YES, that is the Way i'm searching while User want more than SDI like Cl*pper

i have play with your Sample an include some Textbox.

i play with your Array and can "load" from Array an "store" it to Textbox this Way

Code: Select all

PROCEDURE DoStoreData(ChildForm)
LOCAL nRow := Getproperty("FormMain", "Grid_1", "CellRowFocused")
LOCAL cText1,cText2,cText3

   cText1 := GetProperty( "FormMain","Grid_1", "Cell", nRow, 1 )
   cText2 := GetProperty( "FormMain","Grid_1", "Cell", nRow, 2 )
   cText3 := GetProperty( "FormMain","Grid_1", "Cell", nRow, 3 )

   SetProperty( ChildForm, "TEXT_1", "Value", cText1 )
   SetProperty( ChildForm, "TEXT_2", "Value", cText2 )
   SetProperty( ChildForm, "TEXT_3", "Value", cText3 )

RETURN
now the opposite is need to "write-back" but again i got Problem with Syntax

Code: Select all

PROCEDURE DoReplaceData(ChildForm,nID)
LOCAL nRow := nID
LOCAL cText1,cText2,cText3

   cText1 := GetProperty( ChildForm, "TEXT_1", "Value" )
   cText2 := GetProperty( ChildForm, "TEXT_2", "Value" )
   cText3 := GetProperty( ChildForm, "TEXT_3", "Value" )
ALTD()
   // how is the right Syntax
   SetProperty( "FormMain","Grid_1", "Cell", nRow, 1, cText1)
   SetProperty( "FormMain","Grid_1", "Cell", nRow, 2, cText2)
   SetProperty( "FormMain","Grid_1", "Cell", nRow, 3, cText3)

   FormMain.Grid_1.refresh
RETURN
please have a look into Attachment, Thx

---

ok have fix it with direct write into Array and Refresh Grid

Code: Select all

   // update Array direct
   aRows[nRow][1] := cText1
   aRows[nRow][2] := cText2
   aRows[nRow][3] := cText3

   FormMain.Grid_1.refresh
all seems to work ... but Refresh does not show change but i can see it in Debugger that aRows have change it :!:
Grid_Refresh.jpg
Grid_Refresh.jpg (107.55 KiB) Viewed 140 times
so why Refresh does not work ... is there a RefreshALL or do i need some Parameter :?:

attached Sample
MAIN02.ZIP
(2.63 KiB) Downloaded 10 times
have fun

User avatar
andyglezl
Posts: 1191
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 37 times
Been thanked: 85 times
Contact:

Post by andyglezl » Thu Nov 28, 2019 3:21 am

Change :

// update Array direct
* aRows[nRow][1] := cText1
* aRows[nRow][2] := cText2
* aRows[nRow][3] := cText3

FormMain.Grid_1.Cell( nID , 1 ) := cText1
FormMain.Grid_1.Cell( nID , 2 ) := cText2
FormMain.Grid_1.Cell( nID , 3 ) := cText3

or

FormMain.Grid_1.Cell( nID , 1 ) := GetProperty( ChildForm, "TEXT_1", "Value" )
FormMain.Grid_1.Cell( nID , 2 ) := GetProperty( ChildForm, "TEXT_2", "Value" )
FormMain.Grid_1.Cell( nID , 3 ) := GetProperty( ChildForm, "TEXT_3", "Value" )
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
AUGE_OHR
Posts: 290
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 32 times
Been thanked: 39 times

Post by AUGE_OHR » Thu Nov 28, 2019 4:03 am

andyglezl wrote:
Thu Nov 28, 2019 3:21 am
Change :

Code: Select all

	FormMain.Grid_1.Cell( nID , 1 ) := cText1
	FormMain.Grid_1.Cell( nID , 2 ) := cText2
	FormMain.Grid_1.Cell( nID , 3 ) := cText3
or

Code: Select all

	FormMain.Grid_1.Cell( nID , 1 ) := GetProperty( ChildForm, "TEXT_1", "Value" )
	FormMain.Grid_1.Cell( nID , 2 ) := GetProperty( ChildForm, "TEXT_2", "Value" )
	FormMain.Grid_1.Cell( nID , 3 ) := GetProperty( ChildForm, "TEXT_3", "Value" )
OK, that work , THX

but i still wonder why Refresh does not work :?:

p.s. how to set Color for one Cell :?:

User avatar
andyglezl
Posts: 1191
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 37 times
Been thanked: 85 times
Contact:

Post by andyglezl » Sun Dec 01, 2019 4:25 am

Alguna idea de porque no se pueden abrir varias ventanas con un FOR-NEXT ?
Tengo que cerrar cada una de ellas para que se pueda abrir la siguiente...
*----------------------------------------------------------------------------------------------
Any idea why you can't open several windows with a FOR-NEXT?
I have to close each of them so that the next one can be opened ...


Code: Select all

****************************************************************
FUNCTION MultiWin( nCol )
	aNombMulti := { 2, 4, 6, 8 }
	FOR i1 = 1 TO HMG_LEN( aNombMulti )
		ChildForm( aNombMulti[i1] )
		*MSGDEBUG( aNombMulti, aNombMulti[i1] )
	NEXT
RETURN
***************************************************************************

Code: Select all

//[•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•]
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
//  * Ejemplo de Multiventanas CHILD desde un GRID hecho por AndyGlezL (Andrés González López) 26/NOV/2019
//  * Tomado del Ejemplo compartido por EDK.   https://www.hmgforum.com/viewtopic.php?f=12&t=6209&p=60105#p60105
//  * ---------------------------------------------------------------------------------------------------
//  * Example of CHILD Multiwindows from a GRID made by AndyGlezL (Andrés González López) 26/NOV/2019
//  * Taken from the Example shared by EDK.    https://www.hmgforum.com/viewtopic.php?f=12&t=6209&p=60105#p60105
//  * ---------------------------------------------------------------------------------------------------
//  * E-mail: andyglezl@hotmail.com   -   dari_disenos@hotmail.com
//  * http://daridisenos.wix.com/dariweb
//  * Desarrollado en HMG 3.4.4                 VIVA HMG !!!
//_______________________________________________________________________________________________________
//[•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•.•]
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
#include <hmg.ch>

#define  fColor { || if ( This.CellRowIndex/2 == int(This.CellRowIndex/2) , WHITE , { 235, 245, 245 } ) }

#xtranslate _HMG_aFormNames => _HMG_SYSDATA\[66\]

FUNCTION Main()
   PUBLIC nForm  := 1
   PUBLIC  aRows [20] [3]

      aRows [1]   := {'Simpson','Homer','555-5555'}
      aRows [2]   := {'Mulder','Fox','324-6432'}
      aRows [3]   := {'Smart','Max','432-5892'}
      aRows [4]   := {'Grillo','Pepe','894-2332'}
      aRows [5]   := {'Kirk','James','346-9873'}
      aRows [6]   := {'Barriga','Carlos','394-9654'}
      aRows [7]   := {'Flanders','Ned','435-3211'}
      aRows [8]   := {'Smith','John','123-1234'}
      aRows [9]   := {'Pedemonti','Flavio','000-0000'}
      aRows [10]  := {'Gomez','Juan','583-4832'}
      aRows [11]  := {'Fernandez','Raul','321-4332'}
      aRows [12]  := {'Borges','Javier','326-9430'}
      aRows [13]  := {'Alvarez','Alberto','543-7898'}
      aRows [14]  := {'Gonzalez','Ambo','437-8473'}
      aRows [15]  := {'Batistuta','Gol','485-2843'}
      aRows [16]  := {'Vinazzi','Amigo','394-5983'}
      aRows [17]  := {'Pedemonti','Flavio','534-7984'}
      aRows [18]  := {'Samarbide','Armando','854-7873'}
      aRows [19]  := {'Pradon','Alejandra','???-????'}
      aRows [20]  := {'Reyes','Monica','432-5836'}

   DEFINE WINDOW FormMain AT 0 , 0 WIDTH GetDesktopWidth() HEIGHT GetDesktopHeight()-5 NOSIZE MAIN  BACKCOLOR { 230 , 230 , 250 }
      DEFINE MAIN MENU
         DEFINE POPUP "Menu"
            MENUITEM "Open several Windows" ACTION MultiWin()
            MENUITEM "Exit"      			ACTION ReleaseAllForms()
         END POPUP
      END MENU

      @ 010,010 GRID Grid_1 OF FormMain WIDTH 450 HEIGHT 600 ITEMS aRows FONT "Verdana" SIZE 10 HEADERS { 'Last Name', 'First Name', 'Phone' }  WIDTHS { 140 , 140 , 140 } ;
              VALUE 1 DYNAMICBACKCOLOR { fColor, fColor, fColor } ON DBLCLICK ( ChildForm( GetProperty( "FormMain","Grid_1", "Value" ) ) ) ;
              TOOLTIP "DblClick para Abrir" JUSTIFY { GRID_JTFY_CENTER, GRID_JTFY_RIGHT, GRID_JTFY_RIGHT }

              FOR i1=1 TO 3                                                                  // Colores al ENCABEZADO de las 3 Columnas
                 SetProperty( "FormMain", "Grid_1", "HeaderDYNAMICFONT",      i1, { || ARRAY FONT "Consolas" SIZE 12 ITALIC BOLD } )
                 SetProperty( "FormMain", "Grid_1", "HeaderDYNAMICFORECOLOR", i1, { || { 100 , 149 , 237 } } )
              NEXT
              CellNavigationColor( _SELECTEDROW_FORECOLOR, WHITE )   ;  CellNavigationColor( _SELECTEDROW_BACKCOLOR, BLUE )   // Renglon seleccionado
   END WINDOW
    ACTIVATE WINDOW FormMain
RETURN
***************************************************************************
FUNCTION ReleaseAllForms()
   LOCAL i
   FOR i = Len( _HMG_aFormNames ) TO 1 STEP -1        // Ir cerrando las ventanas de la última a la primera
      IF IsWindowDefined( &( _HMG_aFormNames [i] ) )
         DoMethod( _HMG_aFormNames [i], "Release")
      ENDIF
   NEXT i
RETURN
**************************************************************************
FUNCTION ChildForm( nIndexRow )
   LOCAL ChildForm :="ChildForm_", i

   cNombre :=  GetProperty( "FormMain","Grid_1", "Cell", nIndexRow, 1 ) + "  " +  ;
               GetProperty( "FormMain","Grid_1", "Cell", nIndexRow, 2 ) + "  " +  ;
               GetProperty( "FormMain","Grid_1", "Cell", nIndexRow, 3 )

   ChildForm := hb_StrReplace( cNombre, { ' ' => '', '-' => '', '?' => '' } )    // Dejo ChildForm sin espacios o carateres "raros"

   IF ! IsWindowDefined( &( ChildForm ) )
      DEFINE WINDOW &ChildForm AT 0 , 0 WIDTH 550 HEIGHT 350 CHILD NOSIZE NOMINIMIZE NOMAXIMIZE ;
			 ON INIT DoStoreData(ChildForm)

         @ 000 , 000 LABEL Label_1 OF &ChildForm VALUE "Simple context Menu of Grid" WIDTH 550 HEIGHT 20 FONT 'Arial' SIZE 9 CENTERALIGN
         SetProperty( ChildForm, "Title", "#" +  Alltrim( Str( nForm )+SPACE(15)+cNombre ) )
         SetProperty( ChildForm, "Col", 440 + (25 * nForm ) )
         SetProperty( ChildForm, "Row", 30  + (25 * nForm ) )
         nForm ++

         @ 060,125 TEXTBOX TEXT_1 ;
           MAXLENGTH 40

         @ 090,125 TEXTBOX TEXT_2 ;
           MAXLENGTH 40

         @ 120,125 TEXTBOX TEXT_3 ;
           MAXLENGTH 40

         @ 150,125 BUTTON SaveButton ;
            PARENT ChildForm         ;
            CAPTION "&Save"          ;
            WIDTH   40               ;
            HEIGHT  40               ;
            ONCLICK DoReplaceData(ChildForm,nIndexRow)

      END WINDOW
      ACTIVATE WINDOW &ChildForm
   ELSE
      FOR i = 1 TO Len( _HMG_aFormNames )
         IF ChildForm = GetProperty( _HMG_aFormNames[i], "Title" )
            DoMethod( ChildForm, "SetFocus")
            EXIT
         ENDIF
      NEXT i
   ENDIF
RETURN NIL
****************************************************************
PROCEDURE DoStoreData(ChildForm)
	LOCAL nRow := Getproperty("FormMain", "Grid_1", "Value")
	SetProperty( ChildForm, "TEXT_1", "Value", GetProperty( "FormMain","Grid_1", "Cell", nRow, 1 ) )
	SetProperty( ChildForm, "TEXT_2", "Value", GetProperty( "FormMain","Grid_1", "Cell", nRow, 2 ) )
	SetProperty( ChildForm, "TEXT_3", "Value", GetProperty( "FormMain","Grid_1", "Cell", nRow, 3 ) )
RETURN
****************************************************************
PROCEDURE DoReplaceData(ChildForm,nID)
	FormMain.Grid_1.Cell( nID , 1 ) := GetProperty( ChildForm, "TEXT_1", "Value" )
	FormMain.Grid_1.Cell( nID , 2 ) := GetProperty( ChildForm, "TEXT_2", "Value" )
	FormMain.Grid_1.Cell( nID , 3 ) := GetProperty( ChildForm, "TEXT_3", "Value" )
	FormMain.Grid_1.refresh
	DoMethod( ChildForm, "Release")
RETURN
****************************************************************
FUNCTION MultiWin(  )
	aNombMulti := { 2, 4, 6, 8 }
	FOR i1 = 1 TO HMG_LEN( aNombMulti )
		ChildForm( aNombMulti[i1] )
		*MSGDEBUG( aNombMulti, aNombMulti[i1] )
	NEXT
RETURN
***************************************************************************
Andrés González López
Desde Guadalajara, Jalisco. México.

User avatar
andyglezl
Posts: 1191
Joined: Fri Oct 26, 2012 7:58 pm
Location: Guadalajara Jalisco, MX
Has thanked: 37 times
Been thanked: 85 times
Contact:

Post by andyglezl » Sat Dec 07, 2019 3:55 pm

Hola

Seguí "jugando" con esto de los MultiForms...
*---------------------------------------------------------
HI

I kept "playing" with this MultiForms ...

MiSystem.png
MiSystem.png (215.49 KiB) Viewed 15 times
MySystem.zip
(4.19 MiB) Downloaded 12 times
Andrés González López
Desde Guadalajara, Jalisco. México.

Post Reply