Page 10 of 30

Re: HMG 3.4.3

Posted: Tue Nov 15, 2016 1:20 pm
by mol
I've found strange behaviour of grid.
It's impossible to edit last column of grid which width is equal or less to sum of widths of all columns (remember, vertival lines separating columns count too as 1 px) by pressing ENTER key. When you double click with mouse, everything is OK.
I've lost half a day for this :evil: :oops: :x
Try my little sample

Code: Select all

#include "hmg.ch"

Function Main

local i

private aHeaders, aWidths, aJust
private aRows := {}
private aValid := {}
private aWhen := {}
private aControls := {}

	aHeaders := {"Name","Age"}
	aWidths := {200, 100}
	aJust := { 0,1}
	
	aValid	:= { {|| DataValidation()},  {|| DataValidation()} }
	aWhen	:= { {|| .t.}, {||.t.} }
	aControls := { {"TEXTBOX","CHARACTER"}, {"TEXTBOX","NUMERIC","999"} }
	
	
	aADD(aRows, {"Simpson", 65 } )
	aADD(aRows, {"Mulder",41 } )
	aADD(aRows, {"Smart Max", 25} )
	
	
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 500 ;
		HEIGHT 550 ;
		TITLE 'Editable Virtual Grid Test' ;
		MAIN 
	

		@ 10,10 GRID Grid_1 ;
			WIDTH 300 ;
			HEIGHT 240 ;
			HEADERS aHeaders ;
			WIDTHS aWidths;
			VALUE {1,1} ;
			TOOLTIP 'Editable Grid Control' ;
			EDIT ;
			COLUMNCONTROLS aControls;
			COLUMNVALID aValid;
			COLUMNWHEN aWhen;
			VIRTUAL ;
            ITEMCOUNT len(aRows) ;
            ON QUERYDATA OnQuery() ;        
	        JUSTIFY aJust;
			CELLNAVIGATION 
		
		@ 400, 10 BUTTON B_1 ;
			CAPTION "EXPAND GRID +10px";
			ACTION SetProperty("Form_1","Grid_1","Width", GetProperty("Form_1","Grid_1","Width")+10) ;
			WIDTH 120 ;
			HEIGHT 30
			
	END WINDOW

	
	Form_1.Grid_1.EditOption := GRID_EDIT_REPLACEALL

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return
*----------------
function OnQuery
	local nRow, nCol

	nRow := This.QueryRowIndex
	nCol := This.QueryColIndex
	if nRow>0 .and. nCol >0
		This.QueryData := aRows[nRow,nCol]
	endif
return .t.	
*-----------------------
function DataValidation
	nRow := this.Value[1]
	nCol := this.Value[2]
	
	if empty(This.CellValue)
		return .f.
	endif
	aRows[nRow,nCol] := This.CellValue
return .t.

Re: HMG 3.4.3

Posted: Tue Nov 15, 2016 1:52 pm
by mol
My another question is:
Is it possible to use different colors for two grids in one form?
I'm changing color by set of calls:

Code: Select all

	CellNavigationColor ( _SELECTEDROW_FORECOLOR, {255,255,255} )
	CellNavigationColor ( _SELECTEDROW_BACKCOLOR, {0,196,128} )
	CellNavigationColor ( _SELECTEDCELL_BACKCOLOR, {0,128,0} )
	CellNavigationColor ( _SELECTEDROW_DISPLAYCOLOR, .t. )
My idea was to call these function everytime when grid gets focus. But, colors changes for two grids simultanously. (when changing actice grid with Tab key - colors stay as defined, but when moving focus with mouse - two grid changes.

Image

Re: HMG 3.4.3

Posted: Tue Nov 15, 2016 3:24 pm
by srvet_claudio
mol wrote:I've found strange behaviour of grid.
It's impossible to edit last column of grid which width is equal or less to sum of widths of all columns (remember, vertival lines separating columns count too as 1 px) by pressing ENTER key. When you double click with mouse, everything is OK.
I've lost half a day for this :evil: :oops: :x
Try my little sample

Code: Select all

#include "hmg.ch"

Function Main

local i

private aHeaders, aWidths, aJust
private aRows := {}
private aValid := {}
private aWhen := {}
private aControls := {}

	aHeaders := {"Name","Age"}
	aWidths := {200, 100}
	aJust := { 0,1}
	
	aValid	:= { {|| DataValidation()},  {|| DataValidation()} }
	aWhen	:= { {|| .t.}, {||.t.} }
	aControls := { {"TEXTBOX","CHARACTER"}, {"TEXTBOX","NUMERIC","999"} }
	
	
	aADD(aRows, {"Simpson", 65 } )
	aADD(aRows, {"Mulder",41 } )
	aADD(aRows, {"Smart Max", 25} )
	
	
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 500 ;
		HEIGHT 550 ;
		TITLE 'Editable Virtual Grid Test' ;
		MAIN 
	

		@ 10,10 GRID Grid_1 ;
			WIDTH 300 ;
			HEIGHT 240 ;
			HEADERS aHeaders ;
			WIDTHS aWidths;
			VALUE {1,1} ;
			TOOLTIP 'Editable Grid Control' ;
			EDIT ;
			COLUMNCONTROLS aControls;
			COLUMNVALID aValid;
			COLUMNWHEN aWhen;
			VIRTUAL ;
            ITEMCOUNT len(aRows) ;
            ON QUERYDATA OnQuery() ;        
	        JUSTIFY aJust;
			CELLNAVIGATION 
		
		@ 400, 10 BUTTON B_1 ;
			CAPTION "EXPAND GRID +10px";
			ACTION SetProperty("Form_1","Grid_1","Width", GetProperty("Form_1","Grid_1","Width")+10) ;
			WIDTH 120 ;
			HEIGHT 30
			
	END WINDOW

	
	Form_1.Grid_1.EditOption := GRID_EDIT_REPLACEALL

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return
*----------------
function OnQuery
	local nRow, nCol

	nRow := This.QueryRowIndex
	nCol := This.QueryColIndex
	if nRow>0 .and. nCol >0
		This.QueryData := aRows[nRow,nCol]
	endif
return .t.	
*-----------------------
function DataValidation
	nRow := this.Value[1]
	nCol := this.Value[2]
	
	if empty(This.CellValue)
		return .f.
	endif
	aRows[nRow,nCol] := This.CellValue
return .t.
I will check.

Re: HMG 3.4.3

Posted: Tue Nov 15, 2016 3:28 pm
by srvet_claudio
mol wrote:My another question is:
Is it possible to use different colors for two grids in one form?
I'm changing color by set of calls:

Code: Select all

	CellNavigationColor ( _SELECTEDROW_FORECOLOR, {255,255,255} )
	CellNavigationColor ( _SELECTEDROW_BACKCOLOR, {0,196,128} )
	CellNavigationColor ( _SELECTEDCELL_BACKCOLOR, {0,128,0} )
	CellNavigationColor ( _SELECTEDROW_DISPLAYCOLOR, .t. )
My idea was to call these function everytime when grid gets focus. But, colors changes for two grids simultanously. (when changing actice grid with Tab key - colors stay as defined, but when moving focus with mouse - two grid changes.

Image
HMG uses a single global color for all grid controls.

mol

Posted: Tue Nov 15, 2016 3:35 pm
by mol
Thank you for answer

Hmg.3.4.3 The Chinese can not be correctly read into the table

Posted: Tue Nov 22, 2016 3:43 am
by huiyi_ch
Hmg.3.4.3不能将中文正确读入表中
请看下面例子:
假如我要把下列文本添加到表中:
People2.txt(CHINESE、AMERICANE、RUSSIAN、JAPANINESE)
运行程序后可将文本正确读入表中.
如果我想把下列中文文本添加到表中:
People1.txt(中国、美国、俄国、日本)
程序将不能正确读入表中。


Hmg.3.4.3 The Chinese can not be correctly read into the table
Consider the following example:
Suppose I want to add the following text to the table
People2.txt(CHINESE、AMERICANE、RUSSIAN、JAPANINESE)
After the program can be run correctly read the text into the table,

If I want to add the following Chinese text to the table:
People1.txt(中国、美国、俄国、日本)
The program will not be correctly read into the table.

Code: Select all

#include <hmg.ch>

Function Main
open_table("2")
dbEval({||msginfo(PEOPLES->PEOPLE)})
use 
open_table("1")
dbEval({||msginfo(PEOPLES->PEOPLE)})
USE
Return

function open_table(ctype)
local astru:={{"PEOPLE","c",30,0}}
dbCreate("PEOPLES",astru)
use PEOPLES new
if ctype="1"
append from PEOPLES1.txt delimited
else
append from PEOPLES2.txt delimited
endif
return
test.rar
main.prg
(632 Bytes) Downloaded 261 times

Re: HMG 3.4.3

Posted: Tue Nov 22, 2016 4:06 am
by Rathinagiri
People1.txt is encoded as ANSI. Please encode it as UTF-8 and try.

Re: HMG 3.4.3

Posted: Tue Nov 22, 2016 6:13 am
by huiyi_ch
Thank you for your answer, however, will the file with Chinese save as utf8 format can not read correctly into the table too.

Re: HMG 3.4.3

Posted: Tue Nov 22, 2016 7:51 am
by Rathinagiri
Can you send me the saved utf file? I shall try.

Re: HMG 3.4.3

Posted: Tue Nov 22, 2016 8:24 am
by huiyi_ch
Of course! Please receive.
PEOPLES1.rar
(111 Bytes) Downloaded 252 times