How to force for edting at GRID

Moderator: Rathinagiri

Post Reply
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

How to force for edting at GRID

Post by Pablo César »

Recently I have improved the TableMaker her for downloading.

I have implemented this:

_DefineHotKey ( "Form_2" , 0 , VK_RETURN , {|| MoveToNext()} )

Just to navigate in all cell sequentially from left to right and when reach at last column return at first column at below line. I do this in MoveToNext()

In that function I wish to "force" for editing lnke is being done by doubleclisk of mouse and I have no idea how to do it.

Is this possible at grid to force for editing cell (by pressing key Return) ? Is there any function that could be triggered ?
Screen1.png
Screen1.png (28.58 KiB) Viewed 7257 times
All of these in the black and red colors, does not belongs to the app. This is just to ilustrate I wish this edit frame inside of cell of grid.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: How to force for edting at GRID

Post by srvet_claudio »

Pablo, see:

Code: Select all

 <ParentWindowName>.<GridControlName>.EditOption      :=  GRID_EDIT_DEFAULT | GRID_EDIT_SELECTALL |
                                                                     GRID_EDIT_INSERTBLANK | GRID_EDIT_INSERTCHAR |
                                                                     GRID_EDIT_REPLACEALL
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

How to force for edting at GRID

Post by Pablo César »

Gracias Claudio por responder, pero no es eso lo que busco. :(
Talvez no supe expresarme bien. :oops:

Si ejecutas el exe en anexo, después de confirmar la cantidad de líneas y columnas, irás ver que al dar ENTER, irá navegar (cambiar de célula) de forma sequencial.
TableMaker.rar
Executable file of "lastest" version (Unfinished)
(1.06 MiB) Downloaded 390 times
Eso porque alteré el VK_RETURN para llamar la funcion MoveToNext. En ella quiero que se movimente de acuerdo (sequencialmente) y que luego haga un DBLCLICK para activar la ediccion de la célula y es eso que no consigo lograr.

Sé tambien que el SET NAVIGATION EXTENDED hace navegar atravéz del ENTER, pero quiero que navegue de forma sequencial. Es decir, que cambien al próximo a la derecha, cuando llegue a la ultima columna que salte en la próxima linea y vaya a la primera columna y cuando llegue a la ultima columna y ultima linea que vaya para la primera célula del GRID.

Y si no hago pasar por la funcion MoveToNext() con solo usando el SET NAVIGATION EXTENDED cuando llega a la ultima columna este no se mueve (como en las otras columnas)... :(

Remark: This message was re-edited for updated executable file and remove previous source code version.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

How to force for edting at GRID

Post by Pablo César »

Dear Claudio, I done some changings at my source code. Many I improved but still I have some strange behaviour at GRID.

If you run this latest version, you will see that is possible to navigate and edit all cells except last column cell... :o
But if you make double-click on the last column cell you can edit the cell and after that MoveToNext() works properly moving to the next cell on it below.

I tried many options and the simulate of mouse double-click I got it. The problem is to make position of mouse cursor at cell of last columnn which is trying to edit. Because I need to know the pos x and y (in pixels) of current cell just to simulate the double-click and take effects in that specific cell.

I also tried simulate RETURN and SHIFT-RETURN which normally works, but in this last column is not working.

My big question is: At GRID could it has a bug at HMG source codes for editing in this last column ?

Please Claudio, I kindly ask to run this latest executable file and see my source code hereunder:

Code: Select all

#include <hmg.ch>
#include "hbgtinfo.ch"

#define WM_USER             0x400
#define TTM_SETMAXTIPWIDTH  (WM_USER + 24)

#define  ASPAS              Chr(034)
#define  VAZIO              Chr(160)
#define  LINEBUFF           1024
#define  TITULO             "Table Maker, Ver. 1.4"
#define  COPYRIGHT          "Pablo César Arrascaeta"

Function Main()
Local cExeFName := ExeName()
Local cExeFPath := Left( cExeFName, RAt( "\", cExeFName ) )

Private lSai_Form_2 
Private cFormatar:="1", cBordas:="1", cCabecarios:="1", cVisualizar:="1"
Public aLng := {}, cFixedLang:=""

SET TOOLTIPSTYLE BALLOON

If Upper(hb_UserLang())="PT-BR"
   cFixedLang:="Portuguese.Lng"
Else
   cFixedLang:="English.Lng"
Endif
If !File(cExeFPath+cFixedLang)
   MsgInfo("Language file not found !"+CRLF+CRLF+"English language was fixed.")
   aLng := {"Table's sizes","Number of columns:","Number of rows:","Min 1 and max 20",;
            "Min 1 and max 40","&Ok","&Quit","Table Edition"," columns x "," rows",;
            "&Configurations","&Table Generate","&New Table","&Quit","Configurations",;
            " Enable Formatting","Define Header and Boarder format"," With Borders",;
            " With Header"," Preview in Internet Browser","&Cancel","No table generated !",;
            "Attention","Table available on the clipboard !"}
Else
   aLng := Le_Lng(cExeFPath+cFixedLang)
Endif

Carregar()

DEFINE WINDOW Form_1 AT 332 , 472 WIDTH 256 HEIGHT 170 TITLE TITULO ICON NIL MAIN NOSIZE NOMAXIMIZE NOMINIMIZE CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil

    ON KEY ESCAPE ACTION Thiswindow.Release()

    DEFINE FRAME Frame_1
        ROW    10
        COL    12
        WIDTH  222
        HEIGHT 80
        FONTNAME "Arial"
        FONTSIZE 9
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        CAPTION aLng[001]
        BACKCOLOR Nil
        FONTCOLOR Nil
        OPAQUE .T.
    END FRAME

    DEFINE LABEL Label_1
        ROW    30
        COL    30
        WIDTH  120
        HEIGHT 20
        VALUE aLng[002]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR Nil
        FONTCOLOR Nil
    END LABEL

    DEFINE LABEL Label_2
        ROW    60
        COL    30
        WIDTH  120
        HEIGHT 24
        VALUE aLng[003]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION Nil
        AUTOSIZE .F.
        BACKCOLOR Nil
        FONTCOLOR Nil
    END LABEL

    DEFINE SPINNER Spinner_1
        ROW    25
        COL    150
        WIDTH  60
        HEIGHT 24
        RANGEMIN 1
        RANGEMAX 20
        VALUE 4
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP aLng[004]
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        WRAP .F.
        READONLY .F.
        INCREMENT 1
        BACKCOLOR Nil
        FONTCOLOR Nil
    END SPINNER

    DEFINE SPINNER Spinner_2
        ROW    55
        COL    150
        WIDTH  60
        HEIGHT 24
        RANGEMIN 1
        RANGEMAX 40
        VALUE 3
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP aLng[005]
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        WRAP .F.
        READONLY .F.
        INCREMENT 1
        BACKCOLOR Nil
        FONTCOLOR Nil
    END SPINNER
	
	DEFINE BUTTON Button_1
        ROW    100
        COL    12
        WIDTH  100
        HEIGHT 28
        ACTION Tabela()
        CAPTION aLng[006]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

    DEFINE BUTTON Button_2
        ROW    100
        COL    134
        WIDTH  100
        HEIGHT 28
        ACTION Thiswindow.Release()
        CAPTION aLng[007]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON
END WINDOW
Form_1.Button_1.SetFocus
CENTER   WINDOW Form_1
ACTIVATE WINDOW Form_1
SendMessage( GetFormToolTipHandle ("Form_1"), TTM_SETMAXTIPWIDTH, 0, 128)
Return Nil

Function Tabela()
Local nCols:=Form_1.Spinner_1.Value, nLins:=Form_1.Spinner_2.Value
Local aItens[nLins,nCols], aTams:={}, aHeads:={}, aValids:={}, i
Local cTit:=TITULO+" - "+aLng[008]+" ("+AllTrim(Str(nCols))+aLng[009]+AllTrim(Str(nLins))+aLng[010]+")"
Local nH_Grid:=(18*nLins)+18,nW_Grid:=(120*nCols)+14
Local nR_Grid,nC_Grid

Form_1.Hide
lSai_Form_2:=.T.
For i=1 to nCols
    AaDd(aTams,120)
	AaDd(aHeads,"")
	AaDd(aValids,{||MoveToNext()})
Next

If nCols>6
   nW_Grid:=nW_Grid+12
   If nLins>16
      nH_Grid:=nH_Grid+2
   Else
      nH_Grid:=nH_Grid+21 // case SHOHEADER=.T. -> +41
   Endif
Else
   If nLins>13
      nW_Grid:=nW_Grid+34
      nH_Grid:=nH_Grid+2
   Else
      nW_Gcrid:=nW_Grid+28
      nH_Grid:=nH_Grid+22 // case SHOHEADER=.T. -> +42
   Endif
Endif

If nW_Grid>744
   nW_Grid:=744
Endif
If nH_Grid>270
   nH_Grid:=270
Endif
nR_Grid:=((270-nH_Grid)/2)+10
nC_Grid:=((744-nW_Grid)/2)+20

SET NAVIGATION STANDARD
// SET NAVIGATION EXTENDED
// SET CELLNAVIGATIONMODE EXCEL

DEFINE WINDOW Form_2 AT 167 , 120 WIDTH 800 HEIGHT 392 TITLE cTit ICON NIL CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Sair() NOSIZE NOMAXIMIZE ON MINIMIZE Nil ON PAINT Nil BACKCOLOR Nil
    
	ON KEY ESCAPE ACTION ThisWindow.Release()
	// _DefineHotKey ( "Form_2" , 0 , VK_RETURN , {|| TypingInCell()} )
	
    DEFINE GRID Grid_1
        ROW    nR_Grid
        COL    nC_Grid
        WIDTH  nW_Grid
        HEIGHT nH_Grid
        ITEMS aItens
        VALUE {1,1}
        WIDTHS aTams
        HEADERS aHeads
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONDBLCLICK Nil
        ONHEADCLICK Nil
        ONQUERYDATA Nil
        MULTISELECT .F.
        ALLOWEDIT .T.
        VIRTUAL .F.
        DYNAMICBACKCOLOR Nil
        DYNAMICFORECOLOR Nil
        COLUMNWHEN Nil
        COLUMNVALID aValids  // InsertShiftReturn()
        COLUMNCONTROLS Nil
        SHOWHEADERS .F.
        CELLNAVIGATION .T.
        NOLINES .F.
        HELPID Nil
        IMAGE Nil
        JUSTIFY Nil
        ITEMCOUNT Nil
        BACKCOLOR {212,208,200}
        FONTCOLOR Nil
        HEADERIMAGES Nil
        ROWSOURCE Nil
        COLUMNFIELDS Nil
        ALLOWAPPEND .F.
        ALLOWDELETE .F.
        BUFFERED .F.
        DYNAMICDISPLAY Nil
        ONSAVE Nil
		ONKEY Nil // TypingInCell()
        LOCKCOLUMNS Nil
		EDITOPTION GRID_EDIT_DEFAULT + GRID_EDIT_INSERTCHAR
    END GRID
	
	DEFINE BUTTON Button_1
        ROW    310
        COL    40
        WIDTH  130
        HEIGHT 32
        ACTION Configurar()
        CAPTION aLng[011]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON
	
	DEFINE BUTTON Button_2
        ROW    310
        COL    228
        WIDTH  130
        HEIGHT 32
        ACTION Exibir()
        CAPTION aLng[012]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

    DEFINE BUTTON Button_3
        ROW    310
        COL    417
        WIDTH  130
        HEIGHT 32
        ACTION Nova()
        CAPTION aLng[013]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

    DEFINE BUTTON Button_4
        ROW    310
        COL    606
        WIDTH  130
        HEIGHT 32
        ACTION Sair()
        CAPTION aLng[014]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON
	
	DEFINE LABEL Label_1
        ROW    335
        COL    755
        WIDTH  20
        HEIGHT 24
        VALUE "©"
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP COPYRIGHT
        FONTBOLD .T.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        HELPID Nil
        VISIBLE .T.
        TRANSPARENT .F.
        ACTION MsgDebug(Len(aValids))
        AUTOSIZE .F.
        BACKCOLOR Nil
        FONTCOLOR {0,0,232}
        CENTERALIGN .T. 
    END LABEL
	
END WINDOW
CENTER   WINDOW Form_2
For i=1 To nCols
    Form_2.Grid_1.ColumnDYNAMICBACKCOLOR(i) := {|| WHITE}
Next
ACTIVATE WINDOW Form_2
SendMessage( GetFormToolTipHandle ("Form_2"), TTM_SETMAXTIPWIDTH, 0, 128)
Return Nil

Function MoveToNext()
Local nCols:=Form_1.Spinner_1.Value, nRows:=Form_1.Spinner_2.Value
Local nCelRow := Form_2.Grid_1.CellRowFocused
Local nCelCol := Form_2.Grid_1.CellColFocused

If nCelCol=nCols
   If nCelRow=nRows
	  Form_2.Grid_1.Value := {1,1}
   Else
      Form_2.Grid_1.Value := {nCelRow+1,1}
   Endif
Else
   Form_2.Grid_1.Value := {nCelRow,nCelCol}
Endif
_HMG_GRID_KBDSCROLL(GetControlIndex("Grid_1","Form_2"))
Return .T.

Function TypingInCell()
Local nCols:=Form_1.Spinner_1.Value
Local nCelCol := Form_2.Grid_1.CellColFocused

If nCelCol=nCols
   // GuiKeyboard(VK_RETURN, 0, 0, 0)
   // InsertShiftReturn()
   DoMouseClick()
   
   DOEVENTS()
Endif
// MoveToNext()
Return Nil

Function Configurar()
DEFINE WINDOW Form_3 AT 284 , 465 WIDTH 257 HEIGHT 256 TITLE aLng[015] ICON NIL MODAL CURSOR NIL ON INIT Nil ON RELEASE Nil ON INTERACTIVECLOSE Nil ON SIZE Nil ON PAINT Nil BACKCOLOR Nil ON GOTFOCUS Nil ON LOSTFOCUS Nil

    ON KEY ESCAPE ACTION ThisWindow.Release

    DEFINE FRAME Frame_1
        ROW    16
        COL    20
        WIDTH  210
        HEIGHT 90
        FONTNAME "Arial"
        FONTSIZE 9
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        CAPTION "                                               "
        BACKCOLOR Nil
        FONTCOLOR Nil
        OPAQUE .T.
    END FRAME

    DEFINE CHECKBOX Check_1
        ROW    10
        COL    32
        WIDTH  136
        HEIGHT 28
        CAPTION aLng[016]
        VALUE (If(cFormatar="1",.T.,.F.))
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP aLng[017]
        ONCHANGE Desabilitar()
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        BACKCOLOR Nil
        FONTCOLOR Nil
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
    END CHECKBOX

    DEFINE CHECKBOX Check_2
        ROW    40
        COL    50
        WIDTH  100
        HEIGHT 28
        CAPTION aLng[018]
        VALUE (If(cBordas="1",.T.,.F.))
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        BACKCOLOR Nil
        FONTCOLOR Nil
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
    END CHECKBOX

    DEFINE CHECKBOX Check_3
        ROW    70
        COL    50
        WIDTH  120
        HEIGHT 28
        CAPTION aLng[019]
        VALUE (If(cCabecarios="1",.T.,.F.))
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        BACKCOLOR Nil
        FONTCOLOR Nil
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
    END CHECKBOX

    DEFINE CHECKBOX Check_4
        ROW    120
        COL    32
        WIDTH  166
        HEIGHT 28
        CAPTION aLng[020]
        VALUE (If(cVisualizar="1",.T.,.F.))
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        ONCHANGE Nil
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        BACKCOLOR Nil
        FONTCOLOR Nil
        HELPID Nil
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
    END CHECKBOX
	
	DEFINE BUTTON Button_1
        ROW    178
        COL    20
        WIDTH  100
        HEIGHT 28
        ACTION Gravar()
        CAPTION aLng[006]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

    DEFINE BUTTON Button_2
        ROW    178
        COL    130
        WIDTH  100
        HEIGHT 28
        ACTION ThisWindow.Release()
        CAPTION aLng[021]
        FONTNAME "Arial"
        FONTSIZE 9
        TOOLTIP ""
        FONTBOLD .F.
        FONTITALIC .F.
        FONTUNDERLINE .F.
        FONTSTRIKEOUT .F.
        ONGOTFOCUS Nil
        ONLOSTFOCUS Nil
        HELPID Nil
        FLAT .F.
        TABSTOP .T.
        VISIBLE .T.
        TRANSPARENT .F.
        MULTILINE .F.
        PICTURE Nil
        PICTALIGNMENT TOP
    END BUTTON

END WINDOW
CENTER   WINDOW Form_3
ACTIVATE WINDOW Form_3
SendMessage( GetFormToolTipHandle ("Form_3"), TTM_SETMAXTIPWIDTH, 0, 128)
Return Nil

Function Desabilitar()
Local lHabil:=Form_3.Check_1.Value

If lHabil
   Form_3.Check_2.Enabled:=.T.
   Form_3.Check_3.Enabled:=.T.
Else
   Form_3.Check_2.Enabled:=.F.
   Form_3.Check_3.Enabled:=.F.
Endif   
Return Nil

Function Gravar()
cFormatar  := (If(Form_3.Check_1.Value,"1","0"))
cBordas    := (If(Form_3.Check_2.Value,"1","0"))
cCabecarios:= (If(Form_3.Check_3.Value,"1","0"))
cVisualizar:= (If(Form_3.Check_4.Value,"1","0"))
BEGIN INI FILE ("TableMaker.ini")
	SET SECTION "Config" ENTRY "Formatted" To cFormatar   
	SET SECTION "Config" ENTRY "Border"    To cBordas     
	SET SECTION "Config" ENTRY "Header"    To cCabecarios 
	SET SECTION "Config" ENTRY "PreView"   To cVisualizar 
END INI
ThisWindow.Release()
Return Nil

Function Carregar()
If File("TableMaker.ini")
   BEGIN INI FILE ("TableMaker.ini")
       GET cFormatar   SECTION "Config" ENTRY "Formatted"
	   GET cBordas     SECTION "Config" ENTRY "Border"
	   GET cCabecarios SECTION "Config" ENTRY "Header"
	   GET cVisualizar SECTION "Config" ENTRY "PreView"
   END INI
Endif
Return Nil

Function Sair()
If lSai_Form_2
   RELEASE WINDOW ALL
Endif
Delete File(GetCurrentFolder()+"\Temp.html")
Return Nil

Function Nova()
lSai_Form_2:=.F.
Form_2.Release
Form_1.Show
Form_1.Spinner_1.SetFocus
Return Nil

Function Exibir()
Local hWnd:=GetFormHandle("Form_2")
Local nW_Grid:=(Form_2.Grid_1.WIDTH)+10, nH_Grid:=(Form_2.Grid_1.HEIGHT)+140

If !Gerar()
   MsgStop(aLng[022],aLng[023])
   Return Nil
Endif
If File(GetCurrentFolder()+"\Temp.html")
   If cVisualizar="1"
      Form_2.Minimize()
      EXECUTE FILE "Temp.html"
      HB_IDLESLEEP( 1 )
      If IsIconic( hWnd )
         Restore( hWnd )
      ELSE
         SetForeGroundWindow( hWnd )
      Endif
   Else
      MsgInfo(aLng[024])
   Endif
Endif
Return Nil

Function Gerar()
Local nCols:=Form_1.Spinner_1.Value, nLins:=Form_1.Spinner_2.Value
Local lCab:=(If(cFormatar="1",(If(cCabecarios="1",.T.,.F.)),.F.)), lBord:=(If(cFormatar="1",(If(cBordas="1",.T.,.F.)),.F.)), lRet:=.F.
Local cFile:=GetCurrentFolder()+"\Temp.html"
Local cTxtHtml:="", cTxtClpBrd:=""
Local aTupla:={}
Local i, u

If lBord
   cTxtClpBrd:=cTxtClpBrd+"[table boder="+ASPAS+"1"+ASPAS+"]"
   cTxtHtml:=cTxtHtml+"<table border="+ASPAS+"1"+ASPAS+" align="+ASPAS+"center"+ASPAS+">"
Else
   cTxtClpBrd:=cTxtClpBrd+"[table boder="+ASPAS+"0"+ASPAS+"]"
   cTxtHtml:=cTxtHtml+"<table border="+ASPAS+"0"+ASPAS+" align="+ASPAS+"center"+ASPAS+">"
Endif
For i=1 To nLins
    aTupla:=GetTupla( "Grid_1", "Form_2", i )
	cTxtHtml:=cTxtHtml+"<tr>"
	cTxtClpBrd:=cTxtClpBrd+"[tr]"
    For u=1 To nCols
	    If i=1 .and. lCab
		   cTxtClpBrd:=cTxtClpBrd+"[th]"+If(Empty(aTupla[u]),VAZIO,aTupla[u])+"[/th]"
		   cTxtHtml:=cTxtHtml+"<th>"+If(Empty(aTupla[u]),VAZIO,aTupla[u])+"</th>"
		Else
		   cTxtClpBrd:=cTxtClpBrd+"[td]"+If(Empty(aTupla[u]),VAZIO,aTupla[u])+"[/td]"
		   cTxtHtml:=cTxtHtml+"<td>"+If(Empty(aTupla[u]),VAZIO,aTupla[u])+"</td>"
		Endif
    Next
	cTxtHtml:=cTxtHtml+"</tr>"
	cTxtClpBrd:=cTxtClpBrd+"[/tr]"
Next
cTxtHtml:=cTxtHtml+"</table>"
cTxtClpBrd:=cTxtClpBrd+"[/table]"
lRet:=HB_MemoWrit(cFile,cTxtHtml)
HB_GTINFO( HB_GTI_CLIPBOARDDATA, cTxtClpBrd )
Return lRet

Function GetTupla( ControlName, ParentForm, nLin )
Local aRet := {}
If GetControlType (ControlName,ParentForm) != "GRID"
   Return( aRet )
EndIf
aRet := GetProperty ( ParentForm, ControlName, "Item", nLin )
Return aRet

Function Le_Lng(cLangFNam)
Local i, cLinha := "", aLinha := {}

Private lEof:= .f.
nArquivo:=FOpen(cLangFNam,0)
If nArquivo # -1
   Do While !lEof
      cLinha := CharRem( Chr(26), LinhaArq(nArquivo,LINEBUFF) )
	  If NumAt(Chr(34),cLinha)=2
         If Len(cLinha)>0
            Aadd(aLinha,&(cLinha))
         Endif
	  Endif
   Enddo
Endif
FClose(nArquivo)
Return aLinha

Static Function LinhaArq(nHandle,nBuffSize)
Local cRet:= cBuff:="", nPos:= nEol:= nRead:=0

cBuff := Space(nBuffSize)
nPos := FSeek(nHandle,0,1)
If ( nRead:=FRead(nHandle,@cBuff,nBuffSize) ) > 0
   If ( nEol:=At(CRLF,SubStr(cBuff,1,nRead)) ) == 0
      cRet:=SubStr(cBuff,1)+chr(26)
      lEof:=.T.
   Else
      cRet:=SubStr(cBuff,1,nEol-1)
      FSeek(nHandle,nPos+nEol+1,0)
   Endif
Else
   lEof:=.T.
Endif
Return cRet

#pragma BEGINDUMP

#define HB_OS_WIN_USED
#define _WIN32_WINNT 0x0400

#include <windows.h>
#include "hbapi.h"
#include "hbapiitm.h"

HB_FUNC( ISICONIC )
{
   hb_retl( IsIconic( ( HWND ) hb_parnl( 1 ) ) );
}

HB_FUNC ( INSERTSHIFTRETURN )
{
   keybd_event( VK_SHIFT,  0, 0, 0 );
   keybd_event( VK_RETURN,	0, 0, 0	);
   keybd_event( VK_SHIFT,	0, KEYEVENTF_KEYUP,	0 );
}

HB_FUNC( GUIKEYBOARD )
{
   keybd_event( hb_parni(1), hb_parni(2), hb_parni(3), hb_parni(4) ); 
}

HB_FUNC ( DOMOUSECLICK )
{
   mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,0,0,0,0);
   mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP,0,0,0,0);
}
#pragma ENDDUMP
Thanks in advanced for your attention.

Remark: I know you use to write in English but I wrote in spanish for your just for your better understanding.
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: How to force for edting at GRID

Post by srvet_claudio »

Pablo, see:

Code: Select all

    DEFINE GRID Grid_1
        ROW    nR_Grid
        COL    nC_Grid
        WIDTH  (nW_Grid + 25)
        HEIGHT nH_Grid

Code: Select all

Function MoveToNext()
Local nCols:=Form_1.Spinner_1.Value, nRows:=Form_1.Spinner_2.Value
Local nCelRow := Form_2.Grid_1.CellRowFocused
Local nCelCol := Form_2.Grid_1.CellColFocused

If nCelCol=nCols
   If nCelRow=nRows
     Form_2.Grid_1.Value := {1,1}
     keybd_event ( VK_LEFT )
   Else
      Form_2.Grid_1.Value := {nCelRow+1,1}
      keybd_event ( VK_LEFT )
   Endif
Else
//   Form_2.Grid_1.Value := {nCelRow,nCelCol}
Endif
_HMG_GRID_KBDSCROLL(GetControlIndex("Grid_1","Form_2"))
Return .T.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
Pablo César
Posts: 4059
Joined: Wed Sep 08, 2010 1:18 pm
Location: Curitiba - Brasil

Re: How to force for edting at GRID

Post by Pablo César »

Bravo !! Claudio, what it was happining is about size of Grid.
I have to right the right size counting with scrollbars, because when columns are more than 6 not working the RETURN for editing because is cutten (limited by GRID size).

I noted keybd_event just to correct cursor movement. :)

Thank you very much, Claudio and sorry to disturb you. I tought it was any GRID bug. :oops:
HMGing a better world
"Matter tells space how to curve, space tells matter how to move."
Albert Einstein
Post Reply