Click here to Skip to main content
13,044,766 members (43,887 online)
Rate this:
Please Sign up or sign in to vote.
So, how does one code these methods/functions in Linux ?

void drawengine::gotoxy(int x, int y)
	COORD pos;
	pos.X = x;
	pos.Y = y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
void drawengine::setcursor(bool visible)
	ccinfo.dwSize = 1;
	ccinfo.bVisible = visible;
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &ccinfo);
void drawengine::consolesize(int x, int y)
	SMALL_RECT windowSize = {0, 0, x, y};
	SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), TRUE, &windowSize);
void drawengine::fullscreen()

I'm sorry, I didn't explain well. I am aware that these functions only work on a windows environment. I am asking for an alternative and not how to make these Win32 API calls work on Linux. Matthew Faithfull mentioned NCurses, can someone give a simple implementation? or provide a link to a clear tutorial?

Thank you.
Posted 17-Mar-13 15:37pm
Updated 18-Mar-13 5:25am
Richard MacCutchan 18-Mar-13 12:16pm
Google will find you lots of tutorials on programming for Linux, using curses or GTK.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

The simple answer is that you can't but that's not quite the whole story.

If you want to continue to use Win32 API calls like SetConsoleDisplayMode then you're going to need a Linux implementation of Win32. The best known of these is 'Wine Is Not an Emulator'[^]. This will give you what you need.

Another alternative is to change your code ( assuming it's all console based ) to use the NCurses library. This does all the Console realted stuff you could want and is part of the Linux Standard Base ( i.e. available in every distro ). It's also available on Windows as PDCurses ( Public Domain Curses ). Using this approach would give you extremely portable code that could be built for almost anything from Android to Windows to OSX.
_Shepherd 18-Mar-13 11:27am
Thank you for your answer. Please read my question again, I have edited it.
Matthew Faithfull 18-Mar-13 11:57am
No problem. There seem to be lots of NCurses tutorials on the web. looks very basic.
There's even a You Tube Video series.

You aren't however going to find one-to-one matches for functions like SetConsoleWindowInfo NCurses has it's own way of doing things. You could however 'borrow' the whole implementation of SetConsoleWindowInfo from the WINE sources if you wanted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 18 Mar 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100