how to set the window position of my console applicaton ?

Reply

Join Date: Feb 2007
Posts: 12
Reputation: kgz is an unknown quantity at this point 
Solved Threads: 0
kgz kgz is offline Offline
Newbie Poster

how to set the window position of my console applicaton ?

 
0
  #1
Apr 28th, 2007
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
Last edited by kgz; Apr 28th, 2007 at 8:29 am.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 12
Reputation: kgz is an unknown quantity at this point 
Solved Threads: 0
kgz kgz is offline Offline
Newbie Poster

Re: how to set the window position of my console applicaton ?

 
0
  #2
Apr 28th, 2007
anyone?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,171
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1439
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: how to set the window position of my console applicaton ?

 
0
  #3
Apr 28th, 2007
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.
Last edited by Ancient Dragon; Apr 28th, 2007 at 10:11 am.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 12
Reputation: kgz is an unknown quantity at this point 
Solved Threads: 0
kgz kgz is offline Offline
Newbie Poster

Re: how to set the window position of my console applicaton ?

 
0
  #4
Apr 28th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,171
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1439
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: how to set the window position of my console applicaton ?

 
0
  #5
Apr 28th, 2007
this works with VC++ 2005 Express and the Windows Platform SDK installed You have to add User32.lib to the list of link libraries.

  1. #include <windows.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int _tmain(int argc, _TCHAR* argv[])
  6. {
  7. HWND hWnd = GetConsoleWindow();
  8. MoveWindow(hWnd,100,100,300,400,TRUE);
  9. cin.ignore();
  10. return 0;
  11. }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 12
Reputation: kgz is an unknown quantity at this point 
Solved Threads: 0
kgz kgz is offline Offline
Newbie Poster

Re: how to set the window position of my console applicaton ?

 
0
  #6
Apr 29th, 2007
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


Originally Posted by Ancient Dragon View Post
this works with VC++ 2005 Express and the Windows Platform SDK installed You have to add User32.lib to the list of link libraries.

  1. #include <windows.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int _tmain(int argc, _TCHAR* argv[])
  6. {
  7. HWND hWnd = GetConsoleWindow();
  8. MoveWindow(hWnd,100,100,300,400,TRUE);
  9. cin.ignore();
  10. return 0;
  11. }
Last edited by kgz; Apr 29th, 2007 at 12:26 pm.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,171
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1439
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Most Valuable Poster

Re: how to set the window position of my console applicaton ?

 
0
  #7
Apr 29th, 2007
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
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC