Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm working with a basic console application. I'm trying to use the Console.SetWindowPosition method to put the console window at the top left of the screen, but for some reason its not working (and no error either).

 

(I also set the console to the largest size possible, as you can see in my code)

 

Here's my code:

 

using System;

namespace ConsoleApplication1
{
   class Program
   {
       static void Main(string[] args)
       {
           Console.ForegroundColor = ConsoleColor.Red;
           Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight);
           Console.SetWindowPosition(Console.WindowLeft, Console.WindowTop);

...etc etc...

 

I also tried

Console.SetWindowPosition(0, 0);

but with no cigar.

 

Any help would be greatly appreciated.

  • Leaders
Posted

SetWindowPosition, along with WindowLeft and WindowTop, specify the location of the "view window" within the console's buffer. In other words, this seems to deal with scrolling within the console, and not the actual window on the desktop.

 

As far as I can see, the console class does not provide what you are looking for. This code project article appears to address this need, among many others.

[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...