fclt Logo
Using wxWindows with BCC5.5
Utiliser wxWindows avec BCC5.5

1. What is wxWindows? Qu'est-ce que wxWindows?
wxWindows is a open source GUI framework allowing you to build cross-platform applications. wxWindows is also used as the graphical framework in C++BuilderX. For details and downloading the last stable release, see the wxWindows web site. At the time I wrote this article, the latest stable version was 2.4.2.
wxWindows est un framework graphique open source et multi-plateformes. C'est aussi le framework utilisé par C++BuilderX. Pour les détails et le téléchargement de la dernière version stable, je vous renvoie au site de wxWindows. Au moment où je rédige cet article, la dernière version stable est la 2.4.2.

2. Installing wxWindows.
Installer wxWindows.
- Go to the wxWindows web site to download the latest stable version.

- Unzip the file in a folder of your choice. Beware, the path where you unzip the files can't have any space or '-' in it. That's important.

- Set an environment variable called WXWIN to the path where you installed the wxWindows files. Do this either in your autoexec.bat file or using Control Panel/System/Advanced tab.

- Rendez-vous sur le site de wxWindows pour télécharger la dernière version stable.

- Dézipper le fichier dans le répertoire de votre choix mais faites attention que le chemin du répertoire ne peut pas contenir d'espace ou de '-'. Important!

- Créer une variable d'environnement appelée WXWIN dans laquelle vous spécifiez le chemin du répertoire où vous avez placé les fichiers. Vous ajoutez cette variable soit dans votre autoexec.bat soit via le Panneau de configuration/Système/Avancés.

3. Compiling the library. Compilation de la librairie.
Now that you have the source code, you have to compile the library in order to get a lib file usable with the free commandline tool. It's not that hard at all. How to do this is explained in the file $(WXWIN)\docs\msw\install.txt, with &(WXWIN) being the path where you installes wxWindows.
The lib file you have to add to every project that uses wxWindows is called wx24ds_bcc.lib.
To create the lib file, go to $(WXWIN)\src\msw and type from the command line:
Maintenant que les fichiers source sont installés, vous devez compiler la librairie pour obtenir un fichier .lib utilisable avec BCC5.5. La procédure est expliquée dans le fichier $(WXWIN)\docs\msw\install.txt. $(WXWIN) est le chemin du répertoire racine où lwxWindows est installé. Ce fichier .lib appelé wx24ds_bcc.lib est à inclure dans chacun de vos projets qui utilisent wxWindows.
Pour créer le .lib, allez dans le répertoire $(WXWIN)\src\msw et tapez depuis une ligne de commande:

make -f makefile.b32


4. Using wxWindows Utiliser wxWindows
Change the files Bcc32.cfg and Ilink32.cfg which are in the $(BCB)\bin directory to include the path to the wxWindows header files and lib files.
here is what mines look like:
Modifiez les fichiers Bcc32.cfg et Ilink32.cfg qui se trovent dans le répertoire bin de BCC5.5 de façon à y inclure le chemin vers les fichiers entêtes et lib de wxWindows.
Les miens ressemblent à ceci:

Bcc32.cfg 
-DWINVER=0x0400
-D_WIN32_WINNT=0x0400
-I"c:\Borland\Bcc55\include";"c:\Borland\wxWindows\include"
-L"c:\Borland\Bcc55\lib";"c:\Borland\wxWindows\lib"

Ilink32.cfg
-L"c:\Borland\Bcc55\lib";"c:\Borland\wxWindows\lib"


You are now able to compile wxWindows applications. Below, I give you an example of makefile usable with BCC5.5 to compile your projects. You can customize it to suit your needs. Basically, you just have to change, in the body of the makefile, the name of your source files and the name of your resulting application. The are comments in the code to show you where to make those changes. Vous êtes maintenant capable de compiler vos applications pour wxWindows. Ci-dessous, je vous donne un exemple de makefile utilisable avec BCC5.5 et qui permet de compiler une application wxWindows. Vous devez juste changer dans le corps du fichier makefile le nom de votre application et le nom des fichiers source. Il y a des commentaires dans le code qui vous indiquent où effectuer ces changements.

# WXWIN = Environment variable set when compiling the wxWindows libraries.
WXPATH=$(WXWIN)
BPATH=$(MAKEDIR)
INCLUDEPATH=$(BPATH)\..\include
LIBPATH=$(BPATH)\..\lib
WXLIBPATH=$(LIBPATH);$(WXPATH)\lib
WXINCLUDEPATH=$(INCLUDEPATH);$(WXPATH)\lib\msw;$(WXPATH)
  \include;$(WXPATH)\contrib\include;$(WXPATH)\src\iodbc;$(WXPATH)
  \src\regex;$(WXPATH)\src\generic;$(WXPATH)\src\png;$(WXPATH)
  \src\jpeg;$(WXPATH)\src\zlib;$(WXPATH)\src\tiff;

# Defines needed for wxWindows
WXDEFINE=-D__WXWIN__ -D__WXMSW__ -D__WINDOWS__ -DWIN32 -DWXDEBUG=1
  -D__WXDEBUG__ -DUSE_DEFINE -D__WIN95__ -D__WINDOWS__

ARCHINCDIR=$(WXPATH)\lib\msw
ARCHSETUPH=$(ARCHINCDIR)\wx\setup.h

CC=$(BPATH)\bcc32
RC=$(BPATH)\brcc32
LINK=$(BPATH)\ilink32

SYSOBJS=c0w32.obj
SYSLIBS=cw32mt.lib import32.lib ole2w32.lib
WXLIBS=wx24ds_bcc.lib

# -a1 means align on 1 byte (default = 4 bytes) needed to compile
# wxWindows prog.

CFLAGS=-tWM -Od -v -vi- -y -tWM -H- -a1 $(WXDEFINE) -I$(WXINCLUDEPATH)
LFLAGS=-Tpe -aa -x -Gn -L$(WXLIBPATH)
RFLAGS=-32 -i$(WXINCLUDEPATH)

# Here, change the name according to your needs.
# Project is the executable name.
# Unit1 is the name of the unit containing your source code (.cpp).
# You can add multiple files on the same line (if you have several
# source files).
# project is the name of your resource file (.rc)
# Don't put .cpp extension or .rc extension, instead, replace .cpp
# with .obj to tell make to compile the file as an object file.
# The same applies to .rc files.
PROJECT=Project.exe
OBJS=Unit1.obj
RES=project.res
LIBS=

.autodepend

all: $(PROJECT)

$(PROJECT): $(OBJS) $(RES)
  $(LINK) $(LFLAGS) $(OBJS) $(SYSOBJS), $(PROJECT),, $(SYSLIBS)
    $(WXLIBS) $(LIBS), ,$(RES)

.cpp.obj:
  $(CC) -c $(CFLAGS) $<

.cc.obj:
  $(CC) -c $(CFLAGS) $<

.c.obj:
  $(CC) -c $(CFLAGS) $<

.rc.res:
  $(RC) $(RFLAGS) $<


Note that the samples provided with wxWindows already have their own makefiles. Each sample has a file called makefile.b32. You can use those files to compile the samples. The makefile above is only needed when you compile your own applications.
Don't forget to look at the wxWindows web site for documentation, tutorials and samples.
Les examples fournis avec wxWindows possèdent déjà leur propre makefile. Le makefile donné plus haut n'est nécessaire que lorsque vous compilez vos propres applications.
N'oubliez pas non plus de visiter le site de wxWindows. Vous y trouverez la documentation, des tutoriels et des examples.