.prg encode is ansi/big5
- Code: Select all Expand view RUN
#include 'fivewin.ch'
REQUEST HB_CODEPAGE_BIG5
func test()
Local oDlg, oBtn, oGet, oProgress
Priv cSrc := space(256),;
cDes := space(256),;
cProgressText := ''
//
hb_cdpSelect('BIG5')
//
DEFINE DIALOG oDlg RESOURCE "FUN01_DLG" TITLE '工具程式'
oDlg:bKeyDown := {|nKey|If( nKey == VK_ESCAPE, oDlg:End(), NIL )}
//
REDEFINE BUTTON oBtn ID 101 OF oDlg UPDATE;
ACTION SelectFile(1, oDlg)
REDEFINE GET oGet VAR cSrc ID 201 OF oDlg UPDATE
//
REDEFINE BUTTON oBtn ID 102 OF oDlg UPDATE;
ACTION SelectFile(2, oDlg)
REDEFINE GET oGet VAR cDes ID 202 OF oDlg UPDATE
//
REDEFINE SAY oSay VAR cProgressText ID 301 OF oDlg UPDATE
REDEFINE PROGRESS oProgress ID 401 OF oDlg
//
REDEFINE BUTTON oBtn ID 901 OF oDlg UPDATE;
ACTION testrun() CANCEL
REDEFINE BUTTON oBtn ID 902 OF oDlg UPDATE;
ACTION oDlg:End() CANCEL
//
ACTIVATE DIALOG oDlg
return
func testrun()
Local hDes, cDes
Local hSrc := fOpen( cSrc, 1 )
// test fail!!
If fError() != 0
msgstop( 'Source file:['+cSrc+']Open fail!['+Str(fError())+']', "Error!"+ProcName()+"("+LTrim( Str( ProcLine()))+")" )
Else
msgInfo('Open Success')
fClose(hSrc)
EndIf
// test ok
cDes := 'D:\myprog\win\six\prg6\2020.03.31\071002(38總結)圖表-00.txt'
hDes := fOpen( cDes, 1 )
// test fail!!
If fError() != 0
msgstop( 'Source File:['+cDes+']Open Fila!['+Str(fError())+']', "Error!"+ProcName()+"("+LTrim( Str( ProcLine()))+")" )
Else
msgInfo('Open Success')
fClose(hDes)
EndIf
return
func SelectFile(nType, oDlg)
Local nHrc
Local cFile := cGetFile32( "Text|*.txt", "Select File", 0, .T., .T. )
If ! Empty( cFile )
If nType == 1
cSrc := cFile
//---[test fail]---
hSrc := fOpen( cFile, 1 )
If fError() != 0
msgstop( 'Source file:['+cSrc+']Open fail!['+Str(fError())+']', "Error!"+ProcName()+"("+LTrim( Str( ProcLine()))+")" )
Else
msgInfo('Open Success')
fClose(hSrc)
EndIf
Else
cDes := cFile
EndIf
oDlg:UpDate()
EndIf
RETURN NIL
Select the file through cGetFile32(), open the file error If the file name contains Chinese characters
filename ex: 'D:\myprog\win\six\prg6\2020.03.31\071002(38總結)圖表-00.txt'
test.rc
- Code: Select all Expand view RUN
FUN01_DLG DIALOG 6, 5, 298, 96
EXSTYLE WS_EX_DLGMODALFRAME
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "功能選擇"
FONT 12, "細明體"
{
CONTROL "Select Source:", 101, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 3, 4, 72, 12
CONTROL "Select destination:", 102, "button", BS_PUSHBUTTON | BS_CENTER | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 3, 16, 72, 12
CONTROL "123456789", 201, "edit", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 76, 4, 220, 12
CONTROL "123456789", 202, "edit", ES_LEFT | ES_AUTOHSCROLL | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_TABSTOP, 76, 16, 220, 12
CONTROL "[&Y]Run", 901, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 89, 33, 60, 20
CONTROL "[&X]Exit", 902, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 149, 33, 60, 20
CONTROL "", 401, "msctls_progress32", WS_CHILD | WS_VISIBLE | WS_BORDER, 4, 71, 291, 17
CONTROL "", 301, "static", SS_LEFT | WS_CHILD | WS_VISIBLE, 4, 60, 290, 9
}