Thread: How to move the command window programatically?

  1. #1
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126

    Question How to move the command window programatically?

    Hi,
    I wonder how can I move the command line window programatically from a Command Line project in visual studio c++?
    is there any function or method like:
    setWindowPosition(x,y);
    ??

    thanks in advance
    Mac OS 10.6 Snow Leopard : Darwin

  2. #2
    'Allo, 'Allo, Allo
    Join Date
    Apr 2008
    Posts
    639
    Almost, the api is SetWindowPos but you can wrap it up to make it look like that.

    Code:
    #include <windows.h>
    
    void setWindowPosition(int x, int y)
    {
        SetWindowPos(GetConsoleWindow(), NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOOWNERZORDER);
    }
    That's Windows only code. You'll have to take a look at something like pdcurses to do it portably, the function of interest there is mvwin().

  3. #3
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Quote Originally Posted by adeyblue View Post
    You'll have to take a look at something like pdcurses to do it portably, the function of interest there is mvwin().
    No, mvwin() only moves a logical internal window -- it can't move the actual command line window. To move the command line window on Linux, you would need to call an appropriate GTK or QT function depending on what window manager you're using.
    bit∙hub [bit-huhb] n. A source and destination for information.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Tic Tac Toe Comp Move help
    By swgh in forum C++ Programming
    Replies: 5
    Last Post: 09-24-2008, 11:05 AM
  2. Forced moves trouble!!
    By Zishaan in forum Game Programming
    Replies: 0
    Last Post: 03-27-2007, 06:57 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. Formatting Output
    By Aakash Datt in forum C++ Programming
    Replies: 2
    Last Post: 05-16-2003, 08:20 PM

Tags for this Thread