DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   how to set the window position of my console applicaton ? (http://www.daniweb.com/forums/thread76780.html)

kgz Apr 28th, 2007 8:29 am
how to set the window position of my console applicaton ?
 
Hi i really want to set the window position of my console applicaton
I've managed to find Console:: SetWindowPosition bu using google but cant find how to use it...
http://msdn2.microsoft.com/en-us/lib...wposition.aspx
This link shows an example.
But it wont compile
I'm guessing its missing header files, what are they?

I dont realy care how i do it, o if there is another way, then that would be great

kgz Apr 28th, 2007 9:34 am
Re: how to set the window position of my console applicaton ?
 
anyone?

Ancient Dragon Apr 28th, 2007 10:10 am
Re: how to set the window position of my console applicaton ?
 
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.

kgz Apr 28th, 2007 11:19 am
Re: how to set the window position of my console applicaton ?
 
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

Ancient Dragon Apr 28th, 2007 12:28 pm
Re: how to set the window position of my console applicaton ?
 
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;
}

kgz Apr 29th, 2007 12:25 pm
Re: how to set the window position of my console applicaton ?
 
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


Quote:

Originally Posted by Ancient Dragon (Post 354307)
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;
}


Ancient Dragon Apr 29th, 2007 12:34 pm
Re: how to set the window position of my console applicaton ?
 
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


All times are GMT -4. The time now is 12:33 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC