HMG 3.4.3

HMG Unicode versions 3.1.x related

Moderator: Rathinagiri

User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG 3.4.3

Post 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.
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: HMG 3.4.3

Post 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
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.4.3

Post 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.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
srvet_claudio
Posts: 2193
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Contact:

Re: HMG 3.4.3

Post 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.
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

mol

Post by mol »

Thank you for answer
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

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

Post 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 248 times
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG 3.4.3

Post by Rathinagiri »

People1.txt is encoded as ANSI. Please encode it as UTF-8 and try.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: HMG 3.4.3

Post 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.
User avatar
Rathinagiri
Posts: 5471
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: HMG 3.4.3

Post by Rathinagiri »

Can you send me the saved utf file? I shall try.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: HMG 3.4.3

Post by huiyi_ch »

Of course! Please receive.
PEOPLES1.rar
(111 Bytes) Downloaded 235 times
Post Reply