943,660 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 10659
  • C++ RSS
Apr 28th, 2007
0

how to set the window position of my console applicaton ?

Expand Post »
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.
Similar Threads
kgz
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kgz is offline Offline
12 posts
since Feb 2007
Apr 28th, 2007
0

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

anyone?
kgz
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kgz is offline Offline
12 posts
since Feb 2007
Apr 28th, 2007
0

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.
Last edited by Ancient Dragon; Apr 28th, 2007 at 10:11 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,949 posts
since Aug 2005
Apr 28th, 2007
0

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
kgz
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kgz is offline Offline
12 posts
since Feb 2007
Apr 28th, 2007
0

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.

  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. }
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,949 posts
since Aug 2005
Apr 29th, 2007
0

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


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.
kgz
Reputation Points: 10
Solved Threads: 0
Newbie Poster
kgz is offline Offline
12 posts
since Feb 2007
Apr 29th, 2007
0

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
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,949 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: 1%2 ? what is the answer ???
Next Thread in C++ Forum Timeline: Issue creating a vector of a struct in C++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC