initgraph

This function is used to initialize the graphics window.

HWND initgraph(
	int width,
	int height,
	int flag = NULL
);

Parameters

width

The width of the graphics window.

height

The height of the graphics window.

flag

The style of the graphics window, which defaults to NULL, can be the following values.

Value Description
NOCLOSE Disable the close button of the graphics window.
NOMINIMIZE Disable the minimize button of the graphics window.
SHOWCONSOLE Keep the original console window.

Return Value

Returns the handle to the graphics window created.

Examples

The following code snippet creates a graphics window with a size 640 * 480.

initgraph(640, 480);

The following code snippet creates a graphics window with a size 640 * 480, displays the console window.

initgraph(640, 480, SHOWCONSOLE);

The following code snippet creates a graphics window with a size 640 * 480, displays the console window, and disables the close button.

initgraph(640, 480, SHOWCONSOLE | NOCLOSE);