RC to PRG generator

RC to PRG generator

Postby Antonio Linares » Sun Feb 11, 2024 3:10 pm

many times when we are done designing a dialog box, it is tedious to write the code for each control using REDEFINE ...

Here you have an utility that automatically writes the code for you: (work in progress, we do appreciate your feedback)
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

static nButtons := 0, nLbxs := 0, nGets := 0, nTrackBars := 0

function Main()

   local oDlg

   DEFINE DIALOG oDlg RESOURCE "Test"

   ACTIVATE DIALOG oDlg CENTERED ;
      ON RIGHT CLICK WritePrg( oDlg )

return nil

function WritePrg( oDlg )

   local cPrg := ""

   EnumChildWindows( oDlg:hWnd, { | hCtrl | cPrg += GenCode( hCtrl ) } )
   
   FW_memoEdit( cPrg )

return nil  

function GenCode( hCtrl )

   local cCode := "REDEFINE "
   local cClass := GetClassName( hCtrl )
   
   do case
      case cClass == "Button"
        cCode += "BUTTON oBtn" + AllTrim( Str( ++nButtons ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                 " OF oDlg ACTION ''"

      case cClass == "Edit"
        cCode += "GET oGet" + AllTrim( Str( ++nGets ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                 " OF oDlg"
   
      case cClass == "ListBox"
         cCode += "LISTBOX oLbx" + AllTrim( Str( ++nLbxs ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                  " OF oDlg ON CHANGE ''"

      case cClass == "msctls_trackbar32"  
        cCode += "TRACKBAR oTrb" + AllTrim( Str( ++nTrackBars ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
            " OF oDlg ON CHANGE ''"

      otherwise
         MsgInfo( cClass )  
    endcase
   
return cCode + CRLF + CRLF

Image
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RC to PRG generator

Postby Antonio Linares » Mon Feb 12, 2024 9:09 am

Enhanced version:
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

#define GWL_STYLE         -16

static nButtons := 0, nLbxs := 0, nGets := 0, nTrackBars := 0

function Main()

   local oDlg

   DEFINE DIALOG oDlg RESOURCE "Test"

   ACTIVATE DIALOG oDlg CENTERED ;
      ON RIGHT CLICK WritePrg( oDlg )

return nil

function WritePrg( oDlg )

   local cPrg := "", n, cVars := ""

   EnumChildWindows( oDlg:hWnd, { | hCtrl | cPrg += GenCode( hCtrl ) } )
   
   if nButtons > 0
      cVars += "local "
      for n = 1 to nButtons
        cVars += If( n > 1, ", ", "" ) + "oBtn" + AllTrim( Str( n ) )
      next    
      cVars += CRLF    
   endif
   if nLbxs > 0
      cVars += "local "
      for n = 1 to nLbxs
         cVars += If( n > 1, ", ", "" ) + "oLbx" + AllTrim( Str( n ) )
      next
      cVars += CRLF    
    endif          
    if nGets > 0
       cVars += "local "
       for n = 1 to nGets
          cVars += If( n > 1, ", ", "" ) + "oGet" + AllTrim( Str( n ) )
       next
       cVars += CRLF    
    endif          
    if nTrackBars > 0
       cVars += "local "
       for n = 1 to nTrackBars
          cVars += If( n > 1, ", ", "" ) + "oTrb" + AllTrim( Str( n ) )
       next
       cVars += CRLF    
    endif          
 
   FW_memoEdit( cVars + CRLF + 'DEFINE DIALOG oDlg RESOURCE "' + oDlg:cResName + '"' + ;
                CRLF + CRLF + cPrg + "ACTIVATE DIALOG oDlg CENTERED" )

return nil  

function GenCode( hCtrl )

   local cCode := "REDEFINE "
   local cClass := GetClassName( hCtrl )
   
   do case
      case cClass == "Button"
        cCode += "BUTTON oBtn" + AllTrim( Str( ++nButtons ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                 " OF oDlg ACTION ''"

      case cClass == "Edit"
        cCode += "GET oGet" + AllTrim( Str( ++nGets ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                 " OF oDlg" + If( lAnd( GetWindowLong( hCtrl, GWL_STYLE ), ES_MULTILINE ), " MULTILINE", "" )
   
      case cClass == "ListBox"
         cCode += "LISTBOX oLbx" + AllTrim( Str( ++nLbxs ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                  " OF oDlg ON CHANGE ''"

      case cClass == "msctls_trackbar32"  
        cCode += "TRACKBAR oTrb" + AllTrim( Str( ++nTrackBars ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
            " OF oDlg ON CHANGE ''"

      otherwise
         MsgInfo( cClass )  
    endcase
   
return cCode + CRLF + CRLF
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RC to PRG generator

Postby Otto » Mon Feb 12, 2024 9:45 am

Dear Antonio,

I tried a few days ago to create html files from RC files using the rc.prgr. However, I couldn't find a quick solution for how to solve the positioning.
In html, I have a row/column-based positioning and with the RC files, it's absolute.

It then requires a bit of logic to implement this, and I eventually gave up on the attempt. It's interesting that I can't find any RC2HTML converters on the web.
I tried with JavaScript. First, I made a JSON but now I have the elements but not the positioning.

Best regards,
Otto

Code: Select all  Expand view  RUN


<!DOCTYPE html>
<html lang="de">
<head>
  <meta charset="UTF-8">
  <title>Formular aus JSON</title>
  <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</head>
<body>
  <h1>Formular</h1>
  <form action="#">
   

    <div class="input-fields">
    </div>

    <div class="static-fields">
      </div>

    <div class="edit-fields">
      </div>

    <div class="buttons">
      </div>
  </form>

 
  <script>
    const data =  {
       
  "Steuerelemente": [
    {
      "Typ": "Static",
      "Beschriftung": "Name",
      "ID": 200,
      "Position": [44, 8, 20, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Name2",
      "ID": 201,
      "Position": [32, 24, 34, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Straße",
      "ID": 202,
      "Position": [40, 40, 27, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Ort",
      "ID": 203,
      "Position": [48, 56, 16, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "KontoNR/Bank",
      "ID": 205,
      "Position": [8, 72, 59, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Währung",
      "ID": 204,
      "Position": [288, 52, 33, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Kurtaxe €",
      "ID": 211,
      "Position": [288, 80, 33, 8]
    },
 
    {
      "Typ": "Button",
      "Beschriftung": "Terminvormerk",
      "ID": 250,
      "Position": [300, 20, 83, 12]
    },
    {
      "Typ": "Button",
      "Beschriftung": "Kellnercodes",
      "ID": 5999,
      "Position": [368, 44, 120, 11]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Anzahl der Betten",
      "ID": -1,
      "Position": [308, 180, 116, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Betriebsstammdaten",
      "ID": 231,
      "Position": [308, 152, 116, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "ATU-NR",
      "ID": -1,
      "Position": [36, 88, 28, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Anzahl der Zimmer",
      "ID": -1,
      "Position": [308, 164, 116, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Betriebsname für Reports",
      "ID": -1,
      "Position": [8, 176, 96, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Konto Kurtaxe",
      "ID": -1,
      "Position": [268, 96, 52, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Email",
      "ID": 4001,
      "Position": [24, 136, 40, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Telefon",
      "ID": 4002,
      "Position": [24, 104, 40, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Homepage",
      "ID": 4003,
      "Position": [8, 152, 56, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "Fax",
      "ID": 4004,
      "Position": [24, 120, 40, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "ArtikelNr Kurtaxe",
      "ID": 4005,
      "Position": [260, 112, 60, 8]
    },
    {
      "Typ": "Static",
      "Beschriftung": "GPS-Koordinaten",
      "IDs": ["Breitengrad", "Längengrad"],
      "Position": ["Breitengrad: 116, 244, 40, 8", "Längengrad: 264, 244, 40, 8"]
    },
    {
      "ID": 101,
      "Koordinaten": [72, 8, 152, 12]
    },
    {
      "ID": 102,
      "Koordinaten": [72, 24, 152, 12]
    },
    {
      "ID": 103,
      "Koordinaten": [72, 40, 152, 12]
    },
    {
      "ID": 104,
      "Koordinaten": [72, 56, 152, 12]
    },
    {
      "ID": 107,
      "Koordinaten": [72, 72, 152, 12]
    },
    {
      "ID": 105,
      "Koordinaten": [328, 48, 17, 12]
    },
    {
      "ID": 5001,
      "Koordinaten": [328, 76, 26, 12]
    },
    {
      "ID": 555,
      "Koordinaten": [72, 88, 110, 12]
    },
    {
      "ID": 1300,
      "Koordinaten": [444, 160, 21, 12]
    },
    {
      "ID": 1400,
      "Koordinaten": [444, 176, 21, 12]
    },
    {
      "ID": 1019,
      "Koordinaten": [108, 176, 150, 12]
    },
    {
      "ID": 5002,
      "Koordinaten": [328, 92, 34, 12]
    },
    {
      "ID": 5003,
      "Koordinaten": [328, 108, 40, 12]
    },
    {
      "ID": 4007,
      "Koordinaten": [72, 104, 108, 12]
    },
    {
      "ID": 4008,
      "Koordinaten": [72, 120, 108, 12]
    },
    {
      "ID": 4009,
      "Koordinaten": [72, 136, 108, 12]
    },
    {
      "ID": 4010,
      "Koordinaten": [72, 152, 108, 12]
    },
    {
      "ID": 4006,
      "Koordinaten": [196, 136, 80, 12]
    },
    {
      "ID": 4013,
      "Koordinaten": [72, 192, 412, 12]
    },
    {
      "ID": 4016,
      "Koordinaten": [96, 208, 192, 12]
    },
    {
      "ID": 4017,
      "Koordinaten": [96, 224, 284, 12]
    },
    {
      "ID": 4021,
      "Koordinaten": [176, 240, 64, 12]
    },
    {
      "ID": 4022,
      "Koordinaten": [328, 240, 64, 12]
    },
 

    {
      "Beschriftung": "Breitengrad",
      "ID": 4019,
      "Koordinaten": [116, 244, 40, 8]
    },
    {
      "Beschriftung": "Längengrad",
      "ID": 4020,
      "Koordinaten": [264, 244, 40, 8]
    }
  ]
}
;

console.log(data);




const inputFields = document.querySelector('.input-fields');
// Angenommen, `data.Steuerelemente` enthält Ihr Beispielobjekt
for (const element of data.Steuerelemente) {
  // Prüfen, ob `element.Typ` `undefined` oder `null` ist
  if (element.Typ === undefined || element.Typ === null) {
    inputFields.innerHTML += `
      <p>
        <label for="element-${element.ID}">ID: ${element.ID}</label>
        <input type="text" id="element-${element.ID}" name="element-${element.ID}" value="${element.Wert || ''}">
      </p>
    `;
  }
}
 



    // Einfügen der statischen Felder
    const staticFields = document.querySelector('.static-fields');
    for (const element of data.Steuerelemente) {
      if (element.Typ === 'Static') {
        staticFields.innerHTML += `
          <p>
            <label for="${element.ID}">${element.Beschriftung}</label>
            <span id="${element.ID}">${element.ID}</span>
          </p>
        `;
      }
    }
 


    // Einfügen der Eingabefelder
    const editFields = document.querySelector('.edit-fields');
    for (const element of data.Steuerelemente) {
      if (element.Typ === 'Edit') {
        editFields.innerHTML += `
          <p>
            <label for="${element.ID}">${element.Beschriftung}</label>
            <input type="text" id="${element.ID}" name="${element.ID}" value="${element.Wert}">
          </p>
        `;
      }
    }

    // Einfügen der Buttons
    const buttons = document.querySelector('.buttons');
    for (const element of data.Steuerelemente) {
      if (element.Typ === 'Button') {
        buttons.innerHTML += `
          <button type="button" id="${element.ID}">${element.Beschriftung}</button>
        `;
      }
    }

    // JavaScript-Code zum Bearbeiten des Formulars

    const form = document.querySelector('form');

    form.addEventListener('submit', (event) => {
      // ...
    });
  </script>
</body>
</html>



 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: RC to PRG generator

Postby Enrico Maria Giordano » Mon Feb 12, 2024 10:06 am

Can't you just use style clause?

Code: Select all  Expand view  RUN
style = "position: absolute;  top: ...px; left: ...px;"
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: RC to PRG generator

Postby Otto » Mon Feb 12, 2024 10:32 am

Enrico, I would like a flexible system in HTML like Bootstrap's GRID, otherwise it becomes difficult if you want it to be responsive.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: RC to PRG generator

Postby Enrico Maria Giordano » Mon Feb 12, 2024 10:35 am

Can you show a sample of what you want to achieve exactly?
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: RC to PRG generator

Postby Otto » Mon Feb 12, 2024 10:50 am

Enrico, I want to generate a kind of HTML code from an RC file similar to the example code I posted.
Best regards,
Otto

Code: Select all  Expand view  RUN


 <div class="container">
        <h2>Adresskartei Eingabe</h2>
        <form>
            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="inputName">Name</label>
                    <input type="text" class="form-control" id="inputName" placeholder="Name">
                </div>
                <div class="form-group col-md-6">
                    <label for="inputSurname">Nachname</label>
                    <input type="text" class="form-control" id="inputSurname" placeholder="Nachname">
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="inputEmail">E-Mail</label>
                    <input type="email" class="form-control" id="inputEmail" placeholder="E-Mail">
                </div>
                <div class="form-group col-md-6">
                    <label for="inputPhone">Telefon</label>
                    <input type="text" class="form-control" id="inputPhone" placeholder="Telefon">
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-12">
                    <label for="inputAddress">Adresse</label>
                    <input type="text" class="form-control" id="inputAddress" placeholder="1234 Hauptstraße">
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-4">
                    <label for="inputCity">Stadt</label>
                    <input type="text" class="form-control" id="inputCity">
                </div>
                <div class="form-group col-md-4">
                    <label for="inputState">Bundesland</label>
                    <select id="inputState" class="form-control">
                        <option selected>Wählen...</option>
                        <option>...</option>
                    </select>
                </div>
                <div class="form-group col-md-4">
                    <label for="inputZip">Postleitzahl</label>
                    <input type="text" class="form-control" id="inputZip">
                </div>
            </div>
            <button type="submit" class="btn btn-primary">Speichern</button>
        </form>
    </div>




 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: RC to PRG generator

Postby Enrico Maria Giordano » Mon Feb 12, 2024 10:54 am

With your sample I get a very ugly result. Is it that you really want? If yes, you don't need to position the items at all.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: RC to PRG generator

Postby Otto » Mon Feb 12, 2024 11:11 am

Enrico, You need to integrate bootstrap. However, the layout must result from the RC file. After the conversion,
it should look similar to the initial screen. I only added the code to demonstrate how it's done with bootstrap.

Best regards,
Otto


Code: Select all  Expand view  RUN


<!DOCTYPE html>
<html>
<head>
    <title>Adresskartei Eingabebildschirm</title>
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
</head>
<body>
    <div class="container">
        <h2>Adresskartei Eingabe</h2>
        <form>
            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="inputName">Name</label>
                    <input type="text" class="form-control" id="inputName" placeholder="Name">
                </div>
                <div class="form-group col-md-6">
                    <label for="inputSurname">Nachname</label>
                    <input type="text" class="form-control" id="inputSurname" placeholder="Nachname">
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-6">
                    <label for="inputEmail">E-Mail</label>
                    <input type="email" class="form-control" id="inputEmail" placeholder="E-Mail">
                </div>
                <div class="form-group col-md-6">
                    <label for="inputPhone">Telefon</label>
                    <input type="text" class="form-control" id="inputPhone" placeholder="Telefon">
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-12">
                    <label for="inputAddress">Adresse</label>
                    <input type="text" class="form-control" id="inputAddress" placeholder="1234 Hauptstraße">
                </div>
            </div>
            <div class="form-row">
                <div class="form-group col-md-4">
                    <label for="inputCity">Stadt</label>
                    <input type="text" class="form-control" id="inputCity">
                </div>
                <div class="form-group col-md-4">
                    <label for="inputState">Bundesland</label>
                    <select id="inputState" class="form-control">
                        <option selected>Wählen...</option>
                        <option>...</option>
                    </select>
                </div>
                <div class="form-group col-md-4">
                    <label for="inputZip">Postleitzahl</label>
                    <input type="text" class="form-control" id="inputZip">
                </div>
            </div>
            <button type="submit" class="btn btn-primary">Speichern</button>
        </form>
    </div>
    <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.5.5/dist/umd/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>



 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6346
Joined: Fri Oct 07, 2005 7:07 pm

Re: RC to PRG generator

Postby Enrico Maria Giordano » Mon Feb 12, 2024 12:59 pm

If I understand correctly, you can't have both automatic and fixed items placing together.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: RC to PRG generator

Postby karinha » Mon Feb 12, 2024 1:16 pm

Master Antônio, donde está este recurso?

Code: Select all  Expand view  RUN

   DEFINE DIALOG oDlg RESOURCE "Test"
 


I don't understand how this example works. I'm slow in the brain today. hahahaha.

No entiendo cómo funciona este ejemplo. Hoy tengo el cerebro lento. jajajaja.

Gracias, thanks.

Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: RC to PRG generator

Postby Antonio Linares » Mon Feb 12, 2024 3:05 pm

Estimado Joao,

Puedes usar cualquier fichero RC, la idea es cargar un diálogo a partir de su recurso y que escriba el código fuente.

Aqui tienes el ejemplo:
Code: Select all  Expand view  RUN
#ifdef __FLAT__
  1 24 "WinXP\WindowsXP.Manifest"
#endif

sound DIALOG 69, 52, 446, 364
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Text To Speech (TTS)"
FONT 8, "MS Sans Serif"
{
    PUSHBUTTON "Play", 2010, 75, 341, 63, 14
    PUSHBUTTON "Pause", 2020, 139, 341, 55, 14
    PUSHBUTTON "Stop", 2030, 195, 341, 63, 14
    PUSHBUTTON "?", 2040, 259, 341, 55, 14
    LTEXT "Texto a Leer:", -1, 5, 14, 48, 10
    EDITTEXT 10, 52, 13, 278, 323, ES_MULTILINE | WS_BORDER | WS_TABSTOP
    LTEXT "Volumen:", -1, 364, 72, 40, 10
    LTEXT "Velocidad:", -1, 402, 72, 37, 10
    PUSHBUTTON "+", 120, 371, 94, 17, 14
    PUSHBUTTON "-", 130, 371, 114, 17, 14
    PUSHBUTTON "+", 140, 409, 94, 17, 14
    PUSHBUTTON "-", 150, 409, 114, 17, 14
    LTEXT "Text", 160, 372, 135, 20, 8
    LTEXT "Text", 170, 410, 135, 20, 8
    LTEXT "Levels:", -1, 335, 135, 35, 10
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RC to PRG generator

Postby karinha » Mon Feb 12, 2024 5:51 pm

Master, intenta con este por favor.

Code: Select all  Expand view  RUN

#ifdef __FLAT__
  1 24 "WinXP\WindowsXP.Manifest"
#endif

BOXBACKUP DIALOG 90, 44, 310, 301
STYLE DS_MODALFRAME | 0x4L | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "PLENOIND - Configurar o Backup:"
FONT 8, "MS Sans Serif"

{
 CONTROL "&Saida", 611, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 230, 280, 70, 14
 CONTROL "", 101, "TXBrowse", 0 | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP, 8, 72, 292, 140
 CONTROL "&Iniciar Backup", 610, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 280, 80, 14
 CONTROL "", 103, "TMETEREX", 0 | WS_CHILD | WS_VISIBLE, 8, 268, 292, 8
 CONTROL "Arquivo(Pasta) de destino da cópia de segurança (*.zip):", 4002, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 217, 258, 10
 CONTROL "", 102, "EDIT", ES_LEFT | ES_MULTILINE | ES_WANTRETURN | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 8, 228, 270, 20
 CONTROL "Arquivo(Pasta) de origem de dados para cópia de segurança:", 4003, "STATIC", SS_LEFT | WS_CHILD | WS_VISIBLE | WS_GROUP, 8, 39, 258, 10
 CONTROL "Atribuir contrasenha.", 104, "BUTTON", BS_AUTOCHECKBOX | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 8, 252, 90, 10
 CONTROL "Anote a Contrasenha:", 4001, "STATIC", SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 100, 252, 136, 11
 CONTROL "105", 105, "STATIC", SS_RIGHT | WS_CHILD | WS_VISIBLE | WS_GROUP, 240, 252, 60, 8
 CONTROL "", 616, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 280, 49, 20, 20
 CONTROL "", 100, "EDIT", ES_LEFT | ES_MULTILINE | ES_WANTRETURN | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_TABSTOP, 8, 49, 270, 20
 CONTROL "", 615, "BUTTON", BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 280, 228, 20, 20
 CONTROL "Text", 401, "STATIC", SS_CENTER | WS_CHILD | WS_VISIBLE, 0, 3, 310, 34
}
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: RC to PRG generator

Postby Antonio Linares » Mon Feb 12, 2024 7:39 pm

Dear Joao,

Please try this updated version:
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

#define GWL_STYLE         -16

static nButtons := 0, nLbxs := 0, nGets := 0, nTrackBars := 0, nXBrowses := 0, nMeterExs := 0

function Main()

   local oDlg

   TMeterEx():Register()
   TXBrowse():Register()

   DEFINE DIALOG oDlg RESOURCE "Test"

   ACTIVATE DIALOG oDlg CENTERED ;
      ON RIGHT CLICK WritePrg( oDlg )

return nil

function WritePrg( oDlg )

   local cPrg := "", n, cVars := ""

   EnumChildWindows( oDlg:hWnd, { | hCtrl | cPrg += GenCode( hCtrl ) } )
   
   if nButtons > 0
      cVars += "local "
      for n = 1 to nButtons
        cVars += If( n > 1, ", ", "" ) + "oBtn" + AllTrim( Str( n ) )
      next    
      cVars += CRLF    
   endif
   if nLbxs > 0
      cVars += "local "
      for n = 1 to nLbxs
         cVars += If( n > 1, ", ", "" ) + "oLbx" + AllTrim( Str( n ) )
      next
      cVars += CRLF    
    endif          
    if nGets > 0
       cVars += "local "
       for n = 1 to nGets
          cVars += If( n > 1, ", ", "" ) + "oGet" + AllTrim( Str( n ) )
       next
       cVars += CRLF    
    endif          
    if nTrackBars > 0
       cVars += "local "
       for n = 1 to nTrackBars
          cVars += If( n > 1, ", ", "" ) + "oTrb" + AllTrim( Str( n ) )
       next
       cVars += CRLF    
    endif          
    if nXBrowses > 0
      cVars += "local "
      for n = 1 to nXBrowses
         cVars += If( n > 1, ", ", "" ) + "oXbrw" + AllTrim( Str( n ) )
      next
      cVars += CRLF    
   endif          
   if nMeterExs > 0
      cVars += "local "
      for n = 1 to nMeterExs
         cVars += If( n > 1, ", ", "" ) + "oMtr" + AllTrim( Str( n ) )
      next
      cVars += CRLF    
   endif          
 
   FW_memoEdit( cVars + CRLF + 'DEFINE DIALOG oDlg RESOURCE "' + oDlg:cResName + '"' + ;
                CRLF + CRLF + cPrg + "ACTIVATE DIALOG oDlg CENTERED" )

return nil  

function GenCode( hCtrl )

   local cCode := "REDEFINE "
   local cClass := Upper( GetClassName( hCtrl ) )
   
   do case
      case cClass == "BUTTON"
         cCode += "BUTTON oBtn" + AllTrim( Str( ++nButtons ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                  " OF oDlg ACTION ''"

      case cClass == "EDIT"
         cCode += "GET oGet" + AllTrim( Str( ++nGets ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                  " OF oDlg" + If( lAnd( GetWindowLong( hCtrl, GWL_STYLE ), ES_MULTILINE ), " MULTILINE", "" )
   
      case cClass == "LISTBOX"
         cCode += "LISTBOX oLbx" + AllTrim( Str( ++nLbxs ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
                  " OF oDlg ON CHANGE ''"

      case cClass == "MSCTLS_TRACKBAR32"  
         cCode += "TRACKBAR oTrb" + AllTrim( Str( ++nTrackBars ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
            " OF oDlg ON CHANGE ''"

      case cClass == "TXBROWSE"
         cCode += "XBROWSE oBrw" + AllTrim( Str( ++nXBrowses ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
            " OF oDlg"

      case cClass == "STATIC"
         cCode = ""  

      case cClass == "TMETEREX"
         cCode += "METEREX oMtr" + AllTrim( Str( ++nMeterExs ) ) + " ID " + AllTrim( Str( GetDlgCtrlId( hCtrl ) ) ) + ;
            " OF oDlg"

      otherwise
         MsgInfo( cClass )  
    endcase
   
return cCode + If( ! Empty( cCode ), CRLF + CRLF, "" )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: RC to PRG generator

Postby karinha » Mon Feb 12, 2024 9:09 pm

Very good master. It's starting to look good.

Muy buen maestro. Está empezando a tener buena pinta.

Code: Select all  Expand view  RUN

local oBtn1, oBtn2, oBtn3, oBtn4, oBtn5
local oGet1, oGet2
local oXbrw1
local oMtr1

DEFINE DIALOG oDlg RESOURCE "BOXBACKUP"

REDEFINE BUTTON oBtn1 ID 611 OF oDlg ACTION ''

REDEFINE XBROWSE oBrw1 ID 101 OF oDlg

REDEFINE BUTTON oBtn2 ID 610 OF oDlg ACTION ''

REDEFINE METEREX oMtr1 ID 103 OF oDlg

REDEFINE GET oGet1 ID 102 OF oDlg MULTILINE

REDEFINE BUTTON oBtn3 ID 104 OF oDlg ACTION ''

REDEFINE BUTTON oBtn4 ID 616 OF oDlg ACTION ''

REDEFINE GET oGet2 ID 100 OF oDlg MULTILINE

REDEFINE BUTTON oBtn5 ID 615 OF oDlg ACTION ''

ACTIVATE DIALOG oDlg CENTERED
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7835
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 28 guests