Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how do you get the graphics functions to work?(look at name)

how do you get the graphics functions to work?(look at name)

how do you get the graphics functions to work?(look at name)

when i try to include graphics.h it says "BGI graphics not supported under windows".
the book says to check Options| Linker| Libraries| Graphics Library, but the is no choice "liker" in options.

P.S. i couldnt get any of the example programs to work exept the hello world.

RE: how do you get the graphics functions to work?(look at name)

I might be wrong but the BGI runs with DOS applications only. SO when you create
a project under the IDE you need to select DOS (Standard) and the BGI check box.

Hope this helps.

RE: how do you get the graphics functions to work?(look at name)

The Options| Linker| Libraries| Graphics Library is correct
but this works for the BORLAND 3.0 compiler in DOS.
If you try the same thing in the BORLAND 5.0 (windows) then indeed, you won't find this in the menus. I searched for this to last week for 2hours and I'm glad I am not the only one with this problem.
If anyone knows how I can go and use the 'line(...)' and the other functions again in the BORLAND 5.0, please let me know.

RE: how do you get the graphics functions to work?(look at name)


I'm not sure to understand your problem. Why not trying a DC?

What I know and tell you in case of, is that when I need to use graphics for Windows under BC++ 5.0 I just create an instance of a TDC class, which has all the graphics capabilities:

dot; line; polygon; filling routine; handling regions; etc...

This works well and is very fast. You need to include  <owl\dc.h>.

A TDC object must be created as soon as needed and destroyed as soon as drawing is finished, because Windows has only a limited amount of DC contexts available.

Hope that helps,


RE: how do you get the graphics functions to work?(look at name)

To use the graphics routine for borland C++ 5.02 you need to create a project with a Target Type of Application, Platform of DOS, and include the BGI libraries. You can then run a sample application like this:


#include <iostream.h> //console i/o needed if graphics fails
#include <graphics.h>
#include <conio.h>

int main(){
    int gDriver = DETECT, gMode = NULL, errorCode;
   int right, left;
   int top, bottom;
   int count;

   //initialize graphics mode set driver to autodetect
   //3rd param will search current dir for *.bgi files
   initgraph(&gDriver, &gMode, "");

   //check result of graphics initialization
   errorCode = graphresult();

   //if anything other than succesful show error code and end program
   if(errorCode != grOk){
       cout<<"Graphics error : "<<grapherrormsg(errorCode)<<endl;
      cout<<"Press any key to exit..."<<endl;

      return 1;

   //set line style solid and with a thickness of 3 pixels
   setlinestyle(SOLID_LINE, NULL, 3);

   //initialize the rectangle values
   left = getx() + 10;
   top = gety() + 10;
   right = getmaxx() - 10;
   bottom = getmaxy() - 10;

   //initialize loop control variable
   count = 1;
   while(count <= getmaxcolor()){

      //change color of rectangle
      rectangle(left, top, right, bottom);

      //change rectangle values to embed smaller rectangles in larger
      left = left + 10;
      top = top + 10;
      right = right - 10;
      bottom = bottom - 10;

      //update loop control variable

   //pause output press any key to exit program

   //close graphics mode

   return 0;

For the initgraph() function to initialize correctly make sure you copy *.bgi files from c:\bc5\bgi to whatever your current directory is.

hope this helps.

happy programming!

RE: how do you get the graphics functions to work?(look at name)

Well...i've got the same old graphics problems which do not run under windows....as someone told, they will run only under DOS...Can anyone tell me how to run borland under dos..or the file under DOS???

RE: how do you get the graphics functions to work?(look at name)

How do you run Borland graphics under dos? I've had this same problem but have
found out some things. I am using Borland 4.5 compiler so bear that in mind.
To begin with open a new project in the IDE and select the type to run as either dos[standard] or dos[overlay]. Tick the box marked BGI, go to advanced and
choose .c node then click okay (after you have named your directory and program {.ide} of course). You will now be able to compile and run under windows and use
the Borland IDE if that is what you use. If you use an editing program in dos (e.g. edit) then save your source code as .c and compile as you normally would but also add 'graphics.lib' after the source_name. This will allow you to compile graphics in dos.

In your source code you need to initialise the graphics. To find out how to do this just
do a quick search on the web using a keyword(s) such as bgi graphics initgraph and there will be tons of stuff to guide you.

One other problem I came across was portability i.e. it ran on my computer and no one else's. What it seemed to need was this.
Step 1.
Used BGIOBJ.EXE to convert graphics driver files (specifically) EGAVGA.BGI to .OBJ files. On the dos command line type: <bgiobj egavga.bgi>
Creates a file EGAVGA.OBJ in the bgi directory which is where BGIOBJ.EXE resides and from where it should be run.

Step 2.
The new object file(s) have to be added to GRAPHICS.LIB usually located in the LIB directory of the Borland compiler directory. This is also done at the dos command line and whilst within the LIB directory. For example, on my system the command line would appear exactly as this.

C:\zzz\BC45\LIB\tlib graphics.lib +c:\zzz\bc45\bgi\egavga.obj

-tlib is the program that adds to the library (LIB)
-the symbol + (plus) performs the action to add
-the extensions .lib and .obj can be omitted as these are assumed

* The egavga.bgi graphics driver has now been converted to egavga.obj
* The egavga.obj file has now been linked to GRAPHICS.LIB

Step 3.
The file now has to be 'registered' in the source code it is being used in so
that the executable will be portable to other computers.*Note, registering
should be done before initiating the graphics.

if (registerbgidriver(EGAVGA_driver))<0 exit(1)

I think I've written this correctly but there are other ways to do it, just check a site or a book that includes graphics stuff. e.g ...C/C++ Complete Reference...

anyway that is what I have found out.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close