Recientemente mientras chateaba con Ariel me hizo darme cuenta de que dicha dificultad sigue ahí, asi que hoy que tenía algo de tiempo libre, he escrito esta utilidad REDEFINE.prg que escribe los REDEFINEs para vosotros
Aún no está terminado, lo completaré en los próximos dias, pero ya podeis empezar a utilizarlo
redefine.prg
- Code: Select all Expand view
- // Automatic REDEFINEs generator
#include "FiveWin.ch"
static cRCSrcCode, aDialogs := {}
function Main()
local oDlg, oGet, cRCFileName := Space( 250 )
local oLbx, cDlgName := Space( 50 ), oMemo1, cCode := ""
local oFont, oMemo2, cPrg := ""
SetDlgGradient( { { 1, RGB( 199, 216, 237 ), RGB( 237, 242, 248 ) } } )
DEFINE FONT oFont NAME "Courier New" SIZE 0, -14
DEFINE DIALOG oDlg TITLE "RCs REDEFINEs builder" ;
SIZE 900, 700
@ 0.7, 1.5 SAY "RC filename:" OF oDlg SIZE 80, 9
@ 0.8, 6 GET oGet VAR cRCFileName OF oDlg SIZE 200, 12 ;
ACTION ( cRCFileName := cGetFile( "*.rc", "Please select a RC file" ),;
oGet:oBtn:Refresh(), oGet:SetFocus(),;
aDialogs := {}, ListDialogs( cRCFileName, oLbx ) )
@ 2, 1.5 SAY "Dialogs in the RC file:" OF oDlg SIZE 80, 9
@ 3, 1 LISTBOX oLbx VAR cDlgName ITEMS {} OF oDlg SIZE 80, 164 ;
ON CHANGE ShowCode( cDlgName, oMemoRC, oMemoPrg )
@ 2, 16.4 SAY "RC dialog source:" OF oDlg SIZE 80, 9
@ 3.3, 12 GET oMemoRC VAR cCode MEMO OF oDlg SIZE 345, 157 ;
FONT oFont HSCROLL
@ 16, 1 GET oMemoPrg VAR cPrg MEMO OF oDlg SIZE 433, 135 ;
FONT oFont HSCROLL
ACTIVATE DIALOG oDlg CENTERED
oFont:End()
return nil
function ListDialogs( cRCFileName, oLbx )
local n, cDlgName, lDone
if ! File( cRCFileName )
MsgAlert( cRCFileName + " does not exist" )
return nil
endif
cRCSrcCode = MemoRead( cRCFileName )
oLbx:Reset()
for n = 1 to MLCount( cRCSrcCode )
cLine = MemoLine( cRCSrcCode,, n )
SysRefresh()
if ! SubStr( cLine, 1, 2 ) $ "//,/*"
if Upper( StrToken( MemoLine( cRCSrcCode,, n ), 2 ) ) == "DIALOG"
oLbx:Add( cDlgName := StrToken( MemoLine( cRCSrcCode,, n ), 1 ) )
AAdd( aDialogs, { cDlgName, { cLine } } )
lDone = .F.
else
if ! Empty( aDialogs )
if Len( AllTrim( cLine ) ) == 1 .and. SubStr( cLine, 1, 1 ) == "}"
AAdd( ATail( aDialogs )[ 2 ], "}" )
lDone = .T.
else
if ! lDone
AAdd( ATail( aDialogs )[ 2 ], cLine )
endif
endif
endif
endif
endif
next
oLbx:GoTop()
return nil
function ShowCode( cDlgName, oMemoRC, oMemoPrg )
local nAt := AScan( aDialogs, { | aDlg | aDlg[ 1 ] == cDlgName } )
if nAt != 0
oMemoRC:SetText( ArrayToText( aDialogs[ nAt ][ 2 ] ) )
oMemoPrg:SetText( RcToPrg( cDlgName, aDialogs[ nAt ][ 2 ] ) )
endif
return nil
function ArrayToText( aArray )
local n, cText := ""
for n = 1 to Len( aArray )
cText += aArray[ n ] + CRLF
next
return cText
function RcToPrg( cDlgName, aRCSource )
local cFuncName := "function " + cDlgName + "()" + CRLF + CRLF
local n, cCode := "", aTokens, cToken
local nSay := 0, nGet := 0, cVars := " local "
for n = 1 to Len( aRCSource )
aTokens = hb_ATokens( aRCSource[ n ] )
cToken = AllTrim( aTokens[ 1 ] )
// MsgInfo( aTokens[ 1 ] )
do case
case cToken == "EDITTEXT"
cCode += " REDEFINE GET oGet" + AllTrim( Str( ++nGet ) ) + ;
" ID " + StrTran( aTokens[ 2 ], ",", "" ) + ;
" OF oDlg" + CRLF + CRLF
cVars += "oGet" + AllTrim( Str( nGet ) ) + ", "
case cToken == "LTEXT"
cCode += " REDEFINE SAY oSay" + AllTrim( Str( ++nSay ) ) + ;
" ID " + StrTran( aTokens[ 3 ], ",", "" ) + ;
" OF oDlg" + " // " + StrTran( aTokens[ 2 ], ",", "" ) + CRLF + CRLF
cVars += "oSay" + AllTrim( Str( nSay ) ) + ", "
endcase
next
return cFuncName + cVars + CRLF + CRLF + cCode + "return nil"
redefine.rc
- Code: Select all Expand view
- ico ICON "./../ICONS/fivewin.ico"
#ifdef __FLAT__
1 24 "WinXP/WindowsXP.Manifest"
#endif
#ifdef __64__
1 24 "WinXP/WindowsXP.Manifest64"
#endif