3
Contributors
7
Replies
16
Views
9 Years
Discussion Span
Last Post by Faisal_11
0

Here are the win32 api console functions. include windows.h and you will probably have to have the Windows Platform SDK, free for download from Microsoft.com

First call GetConsoleWindow() to get the handle to the console window, they you can call MoveWindow() to move it to wherever you want. I have not done it myself with a console window.

0

Is this how you use it?
It won't work!!!!
thanks

#include <iostream>
#include "Windows.h"
#include "Wincon.h"

//
int main()
{
  HWND a;

//a = GetConsoleWindow();
  //HWND WINAPI GetConsoleWindow(void);
a = GetConsoleWindow();
   MoveWindow(a,1,1,55,55,1);

} // end Mai
0

this works with VC++ 2005 Express and the Windows Platform SDK installed You have to add User32.lib to the list of link libraries.

#include <windows.h>
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    HWND hWnd = GetConsoleWindow();
    MoveWindow(hWnd,100,100,300,400,TRUE);
    cin.ignore();
	return 0;
}
0

I get these errors:
error C3861: 'GetConsoleWindow': identifier not found, even with argument-dependent lookup
error C2061: syntax error : identifier '_TCHAR'

I'm have not got windows sdk installed, checked and its like 800mb, is it possible just to download the specific library?
thanks

this works with VC++ 2005 Express and the Windows Platform SDK installed You have to add User32.lib to the list of link libraries.

#include <windows.h>
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    HWND hWnd = GetConsoleWindow();
    MoveWindow(hWnd,100,100,300,400,TRUE);
    cin.ignore();
    return 0;
}
0

I don't think you can get just part of the SDK. But I think you can get it on CD for just a few $$$.

The _TCHAR allows the compiler to compile for either UNICODE or not. If your compiler doesn't understand that macro you can replace it with char

-1
try this it will work!


#include<iostream>
#include<windows.h>
using namespace std;
void gotoxy(int a, int b);
int main()
{
    cout << "Cursor before:" << endl;
    gotoxy(23, 12);
    cout << "Cursor after:";
}

void gotoxy(int x, int y)
{
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD coord;
    coord.X = x;
    coord.Y = y;
    SetConsoleCursorPosition(hStdOut, coord);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.