Page 1 of 1

re.prg

Posted: Wed Mar 16, 2011 7:59 am
by Silvio
How converte output prg into fivewin code (@ x,y) from re.prg

it now save the prg but only with redefine commands.

I need to save with sources because on W7 the resources leak memory of pc

and I try to converte each mine rc dialogs into source code

Any help ?

Re: re.prg

Posted: Wed Mar 16, 2011 9:01 am
by Silvio
For a sample Look it please


If we run RE.prg


We have a resources rc and we can show it


Image


If we use Rc2prg.prg and thenwe compile the test.prg ( I save on test.prg test.rc)

we have this

Image



BUT IT IS TOO BIG MORE THAN THE ORIGINAL DIALOG

WHY ?

Re: re.prg

Posted: Wed Mar 16, 2011 9:12 am
by Bayron
BUT IT IS TOO BIG MORE THAN THE ORIGINAL DIALOG

WHY ?
Silvio, I have noticed this too...

It seems to be that in resources, the Font size is 8 pixels, but from code, you can not specify this Font Size directly to the Dialog, but only to the text on It...

Re: re.prg

Posted: Wed Mar 16, 2011 12:26 pm
by Silvio
try it please
Resource code

Code: Select all

LIBROS_EDIT DIALOG DISCARDABLE 24, 45, 330, 230
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU|WS_VISIBLE
CAPTION "LIBROS_EDIT"
FONT 8, "MS Sans Serif"
{
  CONTROL "Título", 200, "Static", WS_GROUP, 15, 14, 26, 9
  CONTROL "", 100, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 50, 12, 175, 12
  CONTROL "Código", 201, "Static", WS_GROUP, 230, 14, 24, 8
  CONTROL "", 101, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 255, 12, 60, 12
  CONTROL "Tít. Orig.", 202, "Static", WS_GROUP, 15, 27, 28, 9
  CONTROL "", 102, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 50, 26, 175, 12
  CONTROL "Autor", 203, "Static", WS_GROUP, 15, 42, 30, 8
  CONTROL "", 103, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 50, 40, 150, 12
  CONTROL "Materia", 204, "Static", WS_GROUP, 15, 56, 27, 8
  CONTROL "", 104, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 50, 54, 150, 12
  CONTROL "Idioma", 205, "Static", WS_GROUP, 15, 70, 24, 8
  CONTROL "", 105, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 50, 68, 150, 12
  CONTROL "Propietario", 206, "Static", SS_RIGHT|WS_GROUP, 15, 84, 33, 8
  CONTROL "", 106, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 50, 82, 150, 12
  CONTROL "Ubicación", 207, "Static", WS_GROUP, 15, 98, 33, 8
  CONTROL "", 107, "Edit", ES_AUTOHSCROLL|ES_WANTRETURN|WS_BORDER|WS_TABSTOP, 50, 96, 150, 12
  CONTROL "", 108, "SysTabControl32", 0x00000000, 15, 114, 300, 86
  CONTROL "", 109, "TBtnBmp", WS_TABSTOP, 16, 203, 56, 8
  CONTROL "", 110, "TBtnBmp", WS_TABSTOP, 16, 212, 56, 8
  CONTROL "&Aceptar", IDOK, "Button", WS_TABSTOP, 208, 203, 50, 16
  CONTROL "&Cancelar", IDCANCEL, "Button", WS_TABSTOP, 264, 203, 50, 16
}
source code

Code: Select all

#include "FiveWin.Ch"

FUNCTION LIBROS_EDIT()
LOCAL oDlgLIBROS_EDIT
LOCAL oFnt
LOCAL oGet100, nGet100
LOCAL oGet101, nGet101
LOCAL oGet102, nGet102
LOCAL oGet103, nGet103
LOCAL oGet104, nGet104
LOCAL oGet105, nGet105
LOCAL oGet106, nGet106
LOCAL oGet107, nGet107
LOCAL oFold32108
LOCAL oTBMP109
LOCAL oTBMP110
LOCAL oBtIDOK
LOCAL oBtIDCANCEL
 
DEFINE FONT oFnt  NAME "MS Sans Serif"        SIZE 0, -8

DEFINE DIALOG oDlgLIBROS_EDIT ;
        FROM  45,24 TO 79,113 ;
        TITLE "LIBROS_EDIT"  ;
        FONT oFnt

@  14, 15 SAY "Título" ;
        SIZE 26,  9 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  12,  50 GET oGet100 VAR nGet100 ;
        SIZE  175,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  14, 230 SAY "Código" ;
        SIZE 24,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  12,  255 GET oGet101 VAR nGet101 ;
        SIZE  60,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  27, 15 SAY "Tít. Orig." ;
        SIZE 28,  9 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  26,  50 GET oGet102 VAR nGet102 ;
        SIZE  175,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  42, 15 SAY "Autor" ;
        SIZE 30,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  40,  50 GET oGet103 VAR nGet103 ;
        SIZE  150,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  56, 15 SAY "Materia" ;
        SIZE 27,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  54,  50 GET oGet104 VAR nGet104 ;
        SIZE  150,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  70, 15 SAY "Idioma" ;
        SIZE 24,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  68,  50 GET oGet105 VAR nGet105 ;
        SIZE  150,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  84, 15 SAY "Propietario" ;
        SIZE 33,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  82,  50 GET oGet106 VAR nGet106 ;
        SIZE  150,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  98, 15 SAY "Ubicación" ;
        SIZE 33,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt

@  96,  50 GET oGet107 VAR nGet107 ;
        SIZE  150,  12 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  114, 15 FOLDER oFold32108 ;
        SIZE 300,  86 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  203, 16 BTNBMP oTBMP109 ;
        SIZE 56,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  212, 16 BTNBMP oTBMP110 ;
        SIZE 56,  8 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  203, 208 BUTTON oBtIDOK ;
        SIZE 50,  16 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

@  203, 264 BUTTON oBtIDCANCEL ;
        SIZE 50,  16 ;
        OF oDlgLIBROS_EDIT ;
        FONT oFnt ;
        PIXEL

ACTIVATE DIALOG oDlgLIBROS_EDIT
RETURN 0

//------------------------------------------------------------------------------

 

Re: re.prg

Posted: Thu Mar 17, 2011 10:14 am
by Carlos Mora
Silvio,

remember that in rc the sizes and positions are shown in DIALOG UNITS, that are not PIXELS. That's the reason when we change the dialog's font everything resizes.

Re: re.prg

Posted: Thu Mar 17, 2011 11:55 am
by MdaSolution
Carlos,
I not believe on 2011 we not have Ide run , I need create forms no resources because it eat the resources of system (w7)
I found an app vrmm of ricardo marques , it seems run ok , it a simply form application , then it save on prg good

Antonio must insert this app on new fwh , it can be usefull for the community

Re: re.prg

Posted: Thu Mar 17, 2011 12:58 pm
by James Bott
To get the same size object in dialog units divide window units by 2.05

Re: re.prg

Posted: Thu Mar 17, 2011 2:53 pm
by Carlos Mora
@James,

not sure about that. It depends on the font used in the DIALOG's declaration (in .rc). The real conversion can be a little bit tricky, remember the 16BIT (or something like that) of the REDEFINE DIALOG command in FWH, even 16 bits rc are different.

Code: Select all

pixelX = (dialogunitX * baseunitX) / 4
pixelY = (dialogunitY * baseunitY) / 8
               
from http://support.microsoft.com/kb/145994

A dialog unit is based on the size of the dialog box font, normally 8-point MS Sans Serif. A horizontal unit is the average width of the dialog box font divided by four. A vertical unit is the average height of the font divided by eight.

Re: re.prg

Posted: Thu Mar 17, 2011 3:04 pm
by James Bott
Carlos,

Thanks for clarifying that. I found that number something like 10 years ago and it was just a rough estimate which worked for what I was doing at the time. Your explanation will be more useful and generic.

Regards,
James

Re: re.prg

Posted: Thu Mar 17, 2011 11:39 pm
by Silvio
Carlos,
do you have an Idea to converte rc form into right prg on Re.prg ?
If I can design ( move) each control and save on prg , this is a dream....

Re: re.prg

Posted: Fri Mar 18, 2011 12:08 am
by James Bott
It seems the problem is in this part of the RC2PRG.PRG code. I have not tried to figure it out yet. I don't know where the 14 and 7 came from. Carlos, any ideas?

Regards,
James


Code: Select all

// Dialog-Coordinates

#define FNTX 14
#define FNTY 7

Function xCo(c,x)
if x == NIL
   return Ltrim(str((Val(c)*FNTX)/8,6,0))
endif
return Ltrim(str(val(c)+(((Val(c)+Val(x))*FNTX)/8),6,0))

Function yCo(c,x)
if x == NIL
   return Ltrim(str((Val(c)*FNTY)/4,6, 0))
endif
return Ltrim(str(val(c)+(((Val(c)+Val(x))*FNTY)/4),6,0))
 

Re: re.prg

Posted: Fri Mar 18, 2011 11:02 am
by Carlos Mora
May be those values are the font sizes in use in 16 bits resources, may be they should be changed to the font sizes in the FONT at DIALOG's definition.

Re: re.prg

Posted: Sat Mar 19, 2011 11:24 am
by Silvio
Dear Friends
Any solution for it ?

Re: re.prg

Posted: Fri Mar 25, 2011 5:39 pm
by Armando Picon
Silvio

Look this links

http://www.mediafire.com/?if123opaq1kdjob

http://www.mediafire.com/?g5q96xz77g378wp

Both are modified code from original rc2prg

Armando

Re: re.prg

Posted: Sat Mar 26, 2011 8:52 am
by Silvio
I tried but it make the same