home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SAMPLES / VBXCLASS.PRG < prev    next >
Text File  |  1994-04-14  |  3KB  |  117 lines

  1. // VBX support is under development
  2.  
  3. #include "FiveWin.ch"
  4.  
  5. #define CRLF Chr(13)+Chr(10)
  6.  
  7. //----------------------------------------------------------------------------//
  8.  
  9. function Main()
  10.  
  11.    local oDlg, oGet, oPrg, oCode
  12.    local cFile := Space( 30 )
  13.    local cPrg  := ""
  14.    local cText := ""
  15.  
  16.    SET 3DLOOK ON
  17.  
  18.    DEFINE DIALOG oDlg RESOURCE "Main"
  19.  
  20.    REDEFINE GET oGet VAR cFile ID 100 OF oDlg
  21.    REDEFINE GET oPrg VAR cPrg  ID 120 OF oDlg
  22.  
  23.    REDEFINE GET oCode VAR cText MULTILINE ID 140 OF oDlg
  24.  
  25.    REDEFINE BUTTON ID 110 OF oDlg ;
  26.       ACTION GetVbx( @cFile, @cPrg, @cText, oGet, oPrg, oCode )
  27.  
  28.    REDEFINE BUTTON ID 130 OF oDlg ACTION oDlg:End()
  29.  
  30.    REDEFINE BUTTON ID 150 OF oDlg ;
  31.       ACTION ( cText := ClassGen( cFile ), oCode:Refresh() )
  32.  
  33.    REDEFINE BUTTON ID 160 OF oDlg ;
  34.       ACTION SaveFile( cPrg, cText )
  35.  
  36.    ACTIVATE DIALOG oDlg CENTERED
  37.  
  38. return
  39.  
  40. //----------------------------------------------------------------------------//
  41.  
  42. function ClassGen( cVbx )
  43.  
  44.    local hVbx  := LoadLibrary( cVbx )
  45.    local nVbx  := LoadVbx( hVbx )
  46.    local n     := 1
  47.    local cText := '#include "FiveWin.ch"' + CRLF + CRLF
  48.    local cData
  49.  
  50.    MsgInfo( "LoadVBX OK" )
  51.  
  52.    cText += "CLASS TVb" + VbxClassName( nVbx ) + " FROM TVbControl" + CRLF + CRLF
  53.  
  54.    MsgInfo( "VBXClassName OK" )
  55.  
  56.    while ! Empty( cData := VbxDataName( nVbx, n++ ) )
  57.       cText += "   DATA    " + cData + CRLF
  58.    end
  59.  
  60.    MsgInfo( "VBXDataName OK" )
  61.  
  62.    n = 1
  63.    cText += CRLF
  64.    while ! Empty( cData := VbxMethName( nVbx, n++ ) )
  65.       cText += "   METHOD " + cData + "()" + CRLF
  66.    end
  67.  
  68.    MsgInfo( "VBXMethName OK" )
  69.  
  70.  
  71.    cText += CRLF + "ENDCLASS" + CRLF
  72.  
  73.    FreeLibrary( hVbx )
  74.  
  75. return cText
  76.  
  77. //----------------------------------------------------------------------------//
  78.  
  79. function GetVbx( cFile, cPrg, cText, oGet, oPrg, oCode )
  80.  
  81.    local cFileName := cGetFile( "*.vbx", "Select a VBX file" )
  82.  
  83.    if ! Empty( cFileName )
  84.       cFile = cFileName
  85.       cPrg  = SubStr( cFileName, 1, RAt( ".", cFileName ) ) + "prg"
  86.       cText = ""
  87.       oGet:Refresh()
  88.       oPrg:Refresh()
  89.       oCode:Refresh()
  90.    endif
  91.  
  92. return
  93.  
  94. //----------------------------------------------------------------------------//
  95.  
  96. function SaveFile( cFile, cText )
  97.  
  98.    local cFileName := cGetFile( cFile, "Save PRG source to..." )
  99.  
  100.    if ! Empty( cFileName )
  101.       if File( cFileName )
  102.          if MsgYesNo( "File already exist" + CRLF + "Overwrite?" )
  103.             if MemoWrit( cFileName, cText )
  104.                MsgInfo( "PRG generated", "OK" )
  105.             endif
  106.           endif
  107.       else
  108.          if MemoWrit( cFileName, cText )
  109.             MsgInfo( "PRG generated", "OK" )
  110.          endif
  111.       endif
  112.    endif
  113.  
  114. return
  115.  
  116. //----------------------------------------------------------------------------//
  117.