RC to PRG generator
Posted: 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)
Here you have an utility that automatically writes the code for you: (work in progress, we do appreciate your feedback)
Code: Select all | Expand
#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