Help with .RC files / resources etc.

Help with .RC files / resources etc.

Postby Ollie » Sat Dec 30, 2006 9:08 pm

I have no clue how to work with .RC files and resource editors etc. Please can someone tell me where I can learn how this all works.
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Antonio Linares » Sun Dec 31, 2006 3:55 am

Ollie,

Welcome to the forums. Here you have some quick tutorial videos:
http://www.uploading.com/files/VIRDQ41X ... 1.zip.html
http://www.uploading.com/files/EKWXSWE1 ... 2.zip.html

From the FWH docs:
Code: Select all  Expand view  RUN
What are resources:

Resources are one of the most important parts of Windows programming.To understand them you should consider that your program can be divided in two parts:

·   What the program does -behaviors-
·   The different pieces used to build the program -Data-

Once again we are talking about Object Oriented Programming. Obviously, both parts are highly dependant upon each other.

Some of the pieces used to build your program may be stored in a separate .DLL file or even inside the EXE file. Those pieces, let's call them resources, can be managed and changed externally from the program. This is probably the most important reason for the birth of what is called "Visual Programming".

"Visual Programming" is mainly about resources. The programmer may draw resources using the mouse and certain design programs. In the next stage, those resources get related to some behaviors. From that moment you are building, and using, Objects!

FiveWin has been designed to obtain high performance from Windows resources. FiveWin proposes a way of programming based on resource usage. We are convinced that drawing screens and other resources is the easiest and quickest way to develop a program. Thanks to this technology you can easily build 'Data-driven' programs. This means that your user interface is based on external and modifiable data.  You can   easily modify a screen and use it without having to recompile or relink.

The most important part of this process is to understand how to build an Object from a resource, and how to define -redefine- its  behaviors. There are three main ways to build an Object in xBase:

1. @ nRow, nCol ...

This kind of construction builds an Object and displays it. When you do, @ ... GET ... you are building a GET Object with Clipper, and you also display it. This way of building Objects is not based on resources.

2. DEFINE <ObjectClass> <ObjectName>

This is the main way of building an Object in xBase. The Object is created, but it is not shown. To display it and activate it, you do:

   ACTIVATE <ObjectClass> <ObjectName>

This system was proposed and used by dBase IV, and it is going to be the most important way to build Objects in xBase.This system it is also not based on resources.

3. REDEFINE <ObjectClass> <ObjectName> ID <Identifier>

In this case you are using resources. The Object is already created in the resource, but you need a way to modify and define its behaviors. This is why the REDEFINE command is going to be the most important command to modify behaviors in xBase.

Once you have redefined its behaviors, the Object will be activated using the command:

ACTIVATE <ObjectClass> <ObjectName>

In many cases the Objects are contained by a 'container' Object.This would be the case of a Window or a Dialog Box which contains certain controls. To activate those controls it is not necessary to use the command ACTIVATE ... for each of them.  It is enough to ACTIVATE the container Object.

Lets review now, step by step, the process you should follow to use resources in your programs:

1.   You need a resource designer. We like to use Borland's Resource WorkShop. This designer comes with Borland's products for Windows, such as C++ and Turbo Pascal. You should contact Borland or a software distributor and get one!  You'll thank us!

2.   Using that designer you may start drawing the different screens of your program. This is a standard system for Windows programming. The screens you design must be stored inside a DLL. In the \FiveWin\DLL directory there is an 'empty' DLL you may use to store your screens in. (make a copy for every new project). You should tell the resource editor to 'open' and use that DLL. Select open file  and type the name of that DLL.

3.  When you design your screens you should give a name to each of them.   This name will let you select them from inside your program. You should specify a unique identifier, a number, for each element of a screen. This number will be used by the REDEFINE command to tell FiveWin which Object you are using.

Practice with your resource editor to understand it and to become familiar with its usage.

After that, from inside your program you should tell FiveWin that your program is going to use resources. To do this,  use the following command at the beginning of your program:

#include 'FiveWin.ch'

SET RESOURCES TO <DLLFileName>

And when you are about to end the execution of your program, you should tell FiveWin that you have finished using them:

SET RESOURCE TO  // Release the resource

To use any of the Dialog Boxes you have defined in your DLL all you   have to do is the following:

function TestDialogBox()

   local oDlg
   local cName := "FiveWin"

   DEFINE DIALOG oDlg NAME "MyDialog"

   REDEFINE GET ID 110 VAR cName OF oDlg

   REDEFINE BUTTON ID 120 OF oDlg ACTION nMsgBox( "Hello" )

   REDEFINE BUTTON ID 130 OF oDlg ACTION oDlg:End()

   ACTIVATE DIALOG oDlg

Return nil

In this example we are building a Dialog Box from the screen "MyDialog" stored inside the DLL we have specified in a SET RESOURCES TO "MyDLL.dll" earlier in the program.

In that screen there is a GET Object and two PushButtons (Command Buttons). From the resource editor we have assigned a value of 110 to the GET control and 120 to the first button and 130 to the second.

Remember that the syntax for redefining is:
   REDEFINE <ObjectClass> <ObjectName> ;
   ID <Identifier> ;
   OF <ContainerObjectName> ;
   ...

Every kind of control will have certain extensions typical to this command. As an example, BUTTON has the clause ACTION to let us specify what the Object will do when the button is pressed.
regards, saludos

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

Postby Ollie » Sun Dec 31, 2006 8:14 am

Fantastic Antonio !!! Very helpful.
I'm on my way!

Just out of interest, why do you use numbers (10,20,30 etc) as Identifiers, wouldn't using descriptive names like (OK_button etc) be easier? (or am I missing something?)

And how do you keep track of all the numbers while programming, do you constantly switch between the source and resource editor? Hints and Tips appreciated.

Ollie
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Enrico Maria Giordano » Sun Dec 31, 2006 9:54 am

Ollie wrote:Just out of interest, why do you use numbers (10,20,30 etc) as Identifiers, wouldn't using descriptive names like (OK_button etc) be easier? (or am I missing something?)


You can use identifiers but keep in mind that they don't exist on runtime. But this is not a real problem in most cases.

Ollie wrote:And how do you keep track of all the numbers while programming, do you constantly switch between the source and resource editor?


Once you REDEFINEd all the controls you don't have to use identifier anymore, generally.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Sun Dec 31, 2006 10:52 am

Ollie,

You can create a CH file to be shared from the RC and from the PRG:

test.ch

#define ID_NAME 10
#define ID_ADDRESS 20
#define ID_OK 30
#define ID_CANCEL 40

so in the RC file you do (change 10 into ID_NAME, and so on):

#include "test.ch"

and also in the PRG (change 10 into ID_NAME, and so on):

#include "test.ch"

so when you change test.ch both the RC and the PRG will be affected.
regards, saludos

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

Postby Ollie » Sun Dec 31, 2006 6:52 pm

Hi again. Thanks for the help so far.

Ok, I have the Dialog thing working, I seem to understand it.

Does this also apply to 'WINDOWS' (as opposed to Dialogs) and MDI CHILDs etc.

I have a Main (MDI) Window with buttons to open a CUSTOMERS (MDI)child window or a SUPPLIERS (MDI)child window. (Separate tables that the user can switch between). So these are not DIALOGs. Can I still use the power of resources to design these screens and keep the source code separate?
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Antonio Linares » Sun Dec 31, 2006 7:49 pm

Ollie,

Please review fwh\samples\TestMdi4.prg
regards, saludos

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

Postby Ollie » Sun Dec 31, 2006 8:06 pm

Thanks for the quick response. That looks like what I need.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Ollie » Tue Jan 02, 2007 3:37 pm

Antonio,

These resources are great - I am able to get everything working except TABS.

Borland Resource editor doesn't seem to have it, so I tried Pelles C - something I read about on this forum.

It lets me put a TABCONTROL in my dialog, but I can't see how to change TAB names, specify number of TABS or put anything on the TABS.

Please can you help me, or refer me to someone who can.

Thanks in advance.
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Gale FORd » Tue Jan 02, 2007 5:10 pm

When you do the REDEFINE you add the information like tab names.

Check out insptest.prg in the samples directory.

Actually I like using folders most of the time rather than tabs.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Ollie » Tue Jan 02, 2007 5:26 pm

Thanks Gale,
I am looking at it now.

Actually I like using folders most of the time rather than tabs.


Folders? What are folders? Can they do what I want the TABS to do? Can you show me an example.

Ollie
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Gale FORd » Tue Jan 02, 2007 5:33 pm

Look at all of the testfld*.prg files.

Basically you create a dialog with no border for each folder.

Then on your main folder/window you create a folder control.

Then in the source code you redefine the folder control and tell it the folder tab names and which dialog to place on each folder tab.
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Postby Ollie » Tue Jan 02, 2007 5:42 pm

Thanks Gale, I now realise it is FOLDERS that I want. And I think thats what EMG was trying to let me know)

Thanks for the help.

I am working through the BIGFOLD.PRG sample
Many thanks
Ollie.

Using:
xHarbour Compiler build 1.2.1 (SimpLex) (Rev. 6406)
Borland C++ 5.5.1
FWH 9.04 (2009 Apr)
Ollie
 
Posts: 233
Joined: Sat Dec 30, 2006 6:10 am

Postby Enrico Maria Giordano » Tue Jan 02, 2007 5:44 pm

Ollie wrote:Thanks Gale, I now realise it is FOLDERS that I want. And I think thats what EMG was trying to let me know)


Exactly. :D

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia


Return to FiveWin for Harbour/xHarbour

Who is online

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