Table of Contents

initwindow

Syntax of initwindow

#include "graphics.h"
int initwindow(int width, int height, const char* title="Windows BGI",
int left=0, int top=0, bool dbflag=false, closeflag=true);
 

Description of initwindow

The initwindow function is available in the winbgim implementation of BGI
graphics. You do not need to include conio.h; just include graphics.h.
The function initializes the graphics system by opening a graphics window
of the specified size. The first two parameters (width and height) are
required, but all other parameters have default values.
The title parameter is the title that will be printed at the top of the
window (with a default of "Windows BGI".) If this is set to the empty
string (no characters), then the window will be opened without a title
bar or border (typically used for a popup message that the user can then
close by clicking), and the user will not be able to move this window. If
you want a title bar with no visible title, then set the title to a
string containing one space.
The left and top parameters determine the screen coordinates of the left
and top sides of the window.
The dbflag parameter determines whether double-buffering for the window
is automatically turned on as described in the swapbuffers function (true
means that double-buffering will be turned on).
If the closeflag parameter is true, then the user can click on the
window's close button to shut down the entire program.

Example of initwindow

/* initwindow example */
#include "graphics.h"
 
int main(void)
{
   /* initialize graphics window at 400 x 300 */
   initwindow(400, 300);
 
   /* draw a line */
   line(0, 0, getmaxx(), getmaxy());
 
   /* clean up */
   getch();
   closegraph();
   return 0;
}
/* initwindow example with two windows */
#include "graphics.h"
 
int main(void)
{
   int wid1, wid2;
 
   /* initialize graphics windows */
   wid1 = initwindow(400, 300);
   wid2 = initwindow(300, 400, 200, 100);
 
   /* draw lines */
   setcurrentwindow(wid1);
   line(0, 0, getmaxx(), getmaxy());
   setcurrentwindow(wid2);
   line(0, 0, getmaxx(), getmaxy());
 
   /* clean up */
   getch();
   closegraph();
   return 0;
}

See also

closegraph getcurrentwindow getmaxheight getmaxwidth initgraph setcurrentwindow swapbuffers

output of initwindow example

  no output of example at the moment
  do not hesitate and add it...