Code: Select all
// Testing Unicode Chinese Language
#include "fivewin.ch"
#include "Report.ch"
#include "print.ch"
REQUEST DBFCDX
REQUEST DBFFPT
//----------------------------------------------------------------------------//
Function Main()
LOCAL oApp
InitApp()
oApp := TUnicodeChinese():New()
RETURN NIL
FUNCTION InitApp()
RddSetDefault("DBFCDX")
SET DATE FORMAT "YYYY-MM-DD"
SET DELETE ON
RETURN NIL
//
//
CLASS TUnicodeChinese
DATA oWnd
DATA oBar
METHOD New() CONSTRUCTOR
METHOD MenuBuild()
METHOD DrawBar()
METHOD DrawMsgBar()
METHOD TestChinese_Code()
METHOD TestChinese_Resource()
METHOD PrnDataResource()
ENDCLASS
METHOD New() CLASS TUnicodeChinese
DEFINE WINDOW ::oWnd TITLE "測試 Unicode ç¹é«”ä¸æ–‡(Traditional Chinese)-ä¾‹å¦‚å ƒ,å™" ;
MENU ::MenuBuild()
::DrawBar()
::DrawMsgBar()
ACTIVATE WINDOW ::oWnd MAXIMIZED
RETURN Self
//
METHOD MenuBuild() CLASS TUnicodeChinese
LOCAL oMenu
MENU oMenu 2007
MENUITEM "測試-ä¾‹å¦‚å ƒ,å™"
MENU
MENUITEM "測試CODE-ä¾‹å¦‚å ƒ,å™" ACTION ::TestChinese_Code()
SEPARATOR
MENUITEM "測試RESOURCE-ä¾‹å¦‚å ƒ,å™" ACTION ::TestChinese_Resource()
SEPARATOR
MENUITEM "離開" ACTION ::oWnd:End()
ENDMENU
MENUITEM "編輯" WHEN .F.
oMenu:AddHelp()
ENDMENU
RETURN oMenu
//
METHOD DrawBar() CLASS TUnicodeChinese
DEFINE BUTTONBAR ::oBar OF ::oWnd SIZE 60, 60 2007
DEFINE BUTTON OF ::oBar ACTION ::TestChinese_Code();
RESOURCE "new" TOOLTIP "測試ä¸æ–‡è¼¸å…¥-Code/-ä¾‹å¦‚å ƒ,å™" PROMPT "å ƒ-C"
DEFINE BUTTON OF ::oBar ACTION ::TestChinese_Resource();
RESOURCE "new" TOOLTIP "測試ä¸æ–‡è¼¸å…¥-Resource/-ä¾‹å¦‚å ƒ,å™" PROMPT "å™-R"
DEFINE BUTTON OF ::oBar ACTION ::oWnd:End() ;
RESOURCE "quit" TOOLTIP "離開系統" PROMPT "離開"
RETURN NIL
//
METHOD DrawMsgBar() CLASS TUnicodeChinese
SET MESSAGE OF ::oWnd TO "測試 Unicode ç¹é«”ä¸æ–‡(Traditional Chinese)-ä¾‹å¦‚å ƒ,å™" CENTERED 2007 CLOCK KEYBOARD
RETURN NIL
//
METHOD TestChinese_Code() CLASS TUnicodeChinese
LOCAL oDlg
LOCAL oSay2 , cSay2 := "地å€-ä¾‹å¦‚å ƒ,å™"
LOCAL oSay , cSay := "姓å-ä¾‹å¦‚å ƒ,å™"
LOCAL oGet1 , cGet1 := SPACE( 100 )
LOCAL oGet2 , cGet2 := SPACE( 100 )
LOCAL oBut1 , oBut2
USE testchinese alias TEST
GO BOTTOM
cGet1 := TEST->NAME
cGet2 := TEST->ADDR
DEFINE DIALOG oDlg FROM 10 , 10 TO 40 , 150
@ 1 , 1 SAY oSay2 PROMPT cSay2 OF oDlg
@ 2 , 1 SAY oSay PROMPT cSay OF oDlg
@ 4 , 1 GET oGet1 VAR cGet1 OF oDlg
@ 5 , 1 GET oGet2 VAR cGet2 OF oDlg
@ 6 , 1 BUTTON oBut2 PROMPT "å˜æª”" ACTION write_dbf( cGet1 , cGet2 )
@ 6 , 10 BUTTON oBut1 PROMPT "列å°" ACTION printtest()
ACTIVATE DIALOG oDlg
CLOSE DATABASE
RETURN NIL
FUNCTION WRITE_DBF( cGet1 , cGet2 )
Append Blank
TEST->( DbRLock() )
TEST->NAME := cGet1
TEST->ADDR := cGet2
TEST->( DbCommit() )
TEST->( DbUnLock() )
RETURN NIL
function PrintTest()
local oPrn := TPrinter():New( "Test" ) // "Test" is the name for the printout
local fntArial
local nRow := 1
DEFINE FONT fntArial NAME "細明體" SIZE 0 , -80
oPrn:StartPage()
TEST->( DbGoTop() )
// starts a new page
DO WHILE !EOF()
oPrn:Say( nRow * 100 , 10 , TEST->NAME , fntArial )
oPrn:Say( nRow * 100 , 1000 , TEST->ADDR , fntArial )
nRow ++
SKIP
ENDDO
oPrn:EndPage() // ends this page
RELEASE FONT fntArial
oPrn:End()
return nil
//
//
METHOD TestChinese_Resource() CLASS TUnicodeChinese
local oDlg, oBrw, oReport, oGet[2], oSay[2], oBtn[3], oFont[4]
local lOK := .F.
local cNAME := space(100)
local cADDR := space(100)
local cAlias := ""
USE testchinese alias TEST
DEFINE DIALOG oDlg RESOURCE "TEST"
REDEFINE SAY oSay[1] ID 101 OF oDlg
REDEFINE SAY oSay[2] ID 102 OF oDlg
REDEFINE GET oGet[1] Var cNAME ID 201 OF oDlg
REDEFINE GET oGet[2] Var cADDR ID 202 OF oDlg
REDEFINE BUTTON oBtn[1] ID 301 OF oDlg ;
ACTION ( lOK := .T. , oDlg:End() )
REDEFINE BUTTON oBtn[2] ID 302 OF oDlg ;
ACTION ( lOK := .F. , oDlg:End() )
REDEFINE BUTTON oBtn[3] ID 303 OF oDlg ;
ACTION ( ::PrnDataResource(), oDlg:End() )
ACTIVATE DIALOG oDlg CENTERED
IF lOK
Append Blank
TEST->( DbRLock() )
TEST->NAME := cNAME
TEST->ADDR := cADDR
TEST->( DbCommit() )
TEST->( DbUnLock() )
ENDIF
RETURN NIL
//
//
METHOD PrnDataResource() CLASS TUnicodeChinese
local oReport, oFont[4]
TEST->( DbGoTop() )
DEFINE FONT oFont[1] NAME "細明體" SIZE 0,12
DEFINE FONT oFont[2] NAME "標楷體" SIZE 0,16 BOLD
DEFINE FONT oFont[3] NAME "細明體" SIZE 0,12 BOLD
DEFINE FONT oFont[4] NAME "標楷體" SIZE 0,22 BOLD
REPORT oReport ;
TITLE Trim("å®¢æˆ¶è³‡æ–™å ±è¡¨-ä¾‹å¦‚å ƒ,å™") ,;
"" ,;
"列å°æ—¥æœŸ:"+DTOC(DATE())+ REPL(" ",4) + ;
"é 次: "+str(oReport:nPage,3) CENTER ;
HEADER "" ,;
" " CENTER ;
FONT oFont[1],oFont[2],oFont[3],oFont[4] ;
CAPTION "å®¢æˆ¶è³‡æ–™å ±è¡¨-ä¾‹å¦‚å ƒ,å™" ;
PREVIEW
COLUMN TITLE "ä¸æ–‡å§“å-ä¾‹å¦‚å ƒ,å™" DATA TEST->NAME
COLUMN TITLE "ä¸æ–‡åœ°å€-ä¾‹å¦‚å ƒ,å™" DATA TEST->ADDR
END REPORT
IF oReport:lCreated
oReport:oHEADER:aFONT[1]:={|| 4 }
oReport:oTITLE:aFONT[1]:={|| 2 }
oReport:oTITLE:aFONT[2]:={|| 1 }
oReport:oTITLE:aFONT[3]:={|| 1 }
ENDIF
oReport:nTotalLine := RPT_SINGLELINE
ACTIVATE REPORT oReport ON STARTGROUP oReport:NewLine()
oFont[1]:End()
oFont[2]:End()
oFont[3]:End()
oFont[4]:End()
CLOSE DATABASE
RETURN NIL