Code: Select all | Expand
// C:\LEANDRO\DBF2RC2.PRG y DBF2RC2.RC/RES
// MODIFICADO: 26/07/2023 - By Joao Santos/kapiabafwh@gmail.com
// .DBF to .RC generator. Quickly create Dialogs from .DBFs
/*
File Name : DBF2RC.PRG
Description: .DBF to .RC Generator. Quickly develop Dialogs from
your .DBF
Modified :
07/26/95 : CLW : Now creates a VersionInfo and comment in
the .CH to show where the file came from.
10/10/95 : Code partially formatted, Grokked & verified by QA Team
Tested by QA under FiveWin 1.9
12/10/95 : -3 bugs fixed by James Bott (Internet 71706.551@compuserve.com)
-Labels now in proper case (first letter upper, rest lower).
-Labels now right-justified.
-Field lengths are more accurately predicted (a problem with
proportional fonts).
Note: The version info may have to be deleted if you wish to import multiple
RC's into a DLL since each will have the same version info ID.
*/
#include "FiveWin.ch"
#Define CLR_ORANGE nRGB( 255, 165, 000 ) //-> Orange - Laranja
STATIC cIniFile
FUNCTION Main()
LOCAL oDlg, oGet, oIFto, oFnt, oFont
LOCAL cDbfName := Space( 40 )
LOCAL cTemp, oImage
LOCAL cRuta := "..\bitmaps\pngs\2.png"
SET _3DLOOK ON
SetBalloon( .T. ) // Balloon shape required for tooltips
SkinButtons()
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 00, -14 BOLD
DEFINE FONT oFnt NAME "Ms Sans Serif" SIZE 00, -12 BOLD
DEFINE DIALOG oDlg RESOURCE "Dbf2RC2" FONT oFont
REDEFINE SAY ID 401 OF oDlg COLORS CLR_ORANGE, CLR_WHITE UPDATE FONT oFont ;
TRANSPARENT
REDEFINE GET oGet VAR cDbfName ID 110 OF oDlg UPDATE
// REDEFINE XIMAGE oIFto ID 4001 OF oDlg SOURCE cRuta UPDATE
REDEFINE XIMAGE oImage ID 4001 OF oDlg FILE ".\LOGO.jpg" STRECH // RESIZE
// oImage:lCanPaste := .T.
oImage:lBmpTransparent := .T.
// oImage:Refresh()
oImage:cToolTip := "Leandro Usando XIMAGE y FiveWin The Best"
REDEFINE BUTTON ID 120 OF oDlg ;
ACTION ( cTemp := ;
cGetfile( "*.dbf", "Select a DBF",, "..\data" ), ;
if( !Empty( cTemp ), ( cDbfName := cTemp, ;
oGet:Refresh() ), ) )
REDEFINE BUTTON ID 130 OF oDlg ;
ACTION ( CursorWait(), GenRC( cDbfName ), CursorArrow() )
REDEFINE BUTTON ID 140 OF oDlg ACTION( oDlg:End() ) CANCEL
ACTIVATE DIALOG oDlg CENTERED
oFnt:End()
oFont:End()
RETURN NIL
FUNCTION GenRC( cDbfName )
LOCAL n, nId := 110
LOCAL cRC := ""
LOCAL cCH := "// Generated by DBF2RC" + CRLF
LOCAL aFields
LOCAL cRCFile := ""
IF Empty( cDbfName ) .OR. !File( cDbfName )
MsgAlert( "Please select a DBF file first!" )
RETURN NIL
ENDIF
CursorWait()
USE ( cDbfName ) NEW shared
aFields := dbStruct()
cRC += '#include "..\include\WinApi.ch"' + CRLF
cRC += '#include "' + Alias() + '.ch"' + CRLF + CRLF
cRC += Alias() + " DIALOG 32, 18, 236," + ;
Str( ( Len( aFields ) * 14 ) + 20, 4 ) + CRLF
cRC += "STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION |" + ;
" WS_SYSMENU" + CRLF
cRC += 'CAPTION "' + Alias() + '"' + CRLF
cRC += 'FONT 8, "MS Sans Serif"' + CRLF
cRC += "BEGIN" + CRLF
FOR n := 1 TO Len( aFields )
cCH += "#define ID_" + PadR( aFields[ n ][ 1 ], 11 ) + ;
Str( nId, 4 ) + CRLF
DO CASE
CASE aFields[ n ][ 2 ] $ "CND"
cRC += ' RTEXT "' + properCase( aFields[ n ][ 1 ] ) + '"' + ;
Space( 10 - Len( aFields[ n ][ 1 ] ) ) + ", -1, 3," + ;
Str( 5 + 14 * ( n - 1 ), 4 ) + ", 41, 8" + CRLF
cRC += " EDITTEXT ID_" + aFields[ n ][ 1 ] + ;
", 45," + Str( 3 + 14 * ( n - 1 ), 4 ) + ", " + ;
Str( aFields[ n ][ 3 ] * 7 * .5 + 8, 4 ) + ", 12" + CRLF
CASE aFields[ n ][ 2 ] == "L"
cRC += ' CONTROL "' + properCase( aFields[ n ][ 1 ] ) + ;
'", ID_' + aFields[ n ][ 1 ] + ;
', "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, ' + ;
"45, " + Str( 3 + 14 * ( n - 1 ), 4 ) + ;
", 50, 12" + CRLF
CASE aFields[ n ][ 2 ] == "M"
cRC += ' RTEXT "' + properCase( aFields[ n ][ 1 ] ) + '"' + ;
Space( 10 - Len( aFields[ n ][ 1 ] ) ) + ", -1, 100," + ;
Str( 5 + 14 * ( n - 1 ), 4 ) + ", 41, 8" + CRLF
// cRC += ' CONTROL "' + aFields[ n ][ 1 ] + ;
cRC += ' CONTROL "' + "" + ;
'", ID_' + aFields[ n ][ 1 ] + ;
', "EDIT", ES_LEFT | ES_MULTILINE | ES_WANTRETURN | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP , ' + ;
"145, " + Str( 3 + 14 * ( n - 1 ), 4 ) + ", " + "77, 63" + CRLF
// ^^^ gotta put it out to the right somewhere so you can see it
// and not sit under a bunch of other controls
ENDCASE
nId += 10
NEXT
cRC += "END" + CRLF
/* Add version info to .RC */ // CLW
cRC += "" + CRLF
cRC += '1 VERSIONINFO LOADONCALL MOVEABLE ' + CRLF
cRC += 'FILEVERSION 1, 0, 0, 0' + CRLF
cRC += 'PRODUCTVERSION 1, 0, 0, 0' + CRLF
cRC += 'FILEOS VOS__WINDOWS16' + CRLF
cRC += ' {' + CRLF
cRC += ' BLOCK "StringFileInfo"' + CRLF
cRC += ' {' + CRLF
cRC += ' BLOCK "040904E4"' + CRLF
cRC += ' {' + CRLF
cRC += ' VALUE "ProductVersion", "Created by DBF2RC"' + CRLF
cRC += ' VALUE "FileVersion", " Created on ' + ;
DToC( Date() ) + ' at ' + Time() + '"' + CRLF
cRC += ' VALUE "FileDescription", "Generated by DBF2RC"' + CRLF
cRC += ' }' + CRLF
cRC += '' + CRLF
cRC += ' }' + CRLF
cRC += '' + CRLF
cRC += '}' + CRLF
MemoWrit( Alias() + ".ch", cCH )
cRCFile := Alias() + ".rc"
CursorArrow()
IF !File( Alias() + ".rc" )
CursorWait()
MemoWrit( Alias() + ".rc", cRC )
ELSEIF MsgYesno( ;
"That Resource Already Exists - Overwrite it?", "OOPS" )
CursorWait()
MemoWrit( Alias() + ".rc", cRC )
ELSE
MsgStop( "Rename the existing " + cRCFile + " and try again" )
ENDIF
CursorArrow()
WinExec( "workshop" + " " + cRCFile )
dbCloseArea()
RETURN NIL
STATIC FUNCTION properCase( cString )
RETURN Left( cString, 1 ) + Lower( Right( cString, Len( cString ) - 1 ) )
/* // DBF2RC2.RC / .RES
DBF2RC2 DIALOG 136, 48, 349, 247
STYLE DS_ABSALIGN | DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_DLGFRAME | WS_SYSMENU
FONT 8, "Arial"
{
EDITTEXT 110, 4, 42, 137, 12, WS_BORDER | WS_TABSTOP
PUSHBUTTON "&Find", 120, 143, 41, 42, 14
DEFPUSHBUTTON "&Generate", 130, 29, 63, 60, 14
PUSHBUTTON "&Done!", 140, 91, 63, 50, 14
CONTROL "", 4001, "TXImage", 0 | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 93, 106, 162, 100
LTEXT "Select DBF:", 401, 4, 30, 134, 12, NOT WS_GROUP
ICON "fivewin", 201, 4, 60, 21, 18
}
*/
// FIN / END
Regards, saludos.