Moving (centering) the console window

Hi everyone. So I've been working on a small personal project, and I'm currently trying to have the console window open up where I want (in this case, centered on the user's screen). I've looked online for answers on how to this and I've tried a few things but to no success.

The thing everything I found seemed to be different from one another, so I'm kind of confused now. If I get it correctly, I must start by getting the "handle" and also finding the SystemMetrics, but I get lost on how to actually use the corresponding functions. Could anyone point me in the right direction please ?

Pretty much yes. The only other tiny of code that comes after is the main function which is currently empty. I put a temporarily _getch() just so it doesn't close automatically. No errors related to that part whatsoever.

Hi, it's me again. Today I was messing around with the previously shown code that basically lets me choose the size and the positioning of the window when running the program.

I tried making it bigger, so I changed the following lines:int WindowWidth = 680;int Windowheight = 350;
(Lines 8 and 9 in the original code)

To this:int WindowWidth = 800;int WindowHeight = 500;

What happened kind of surprised me. The width of the console window didn't change (it remained at 680, I tested it by outputting a long string), but the height didn't change to 500. I am now wondering: Is there size limitations ? Is it because of the functions I am using ? If so, is there a way to get around it or other functions to use to achieve my goal ?

As I said earlier, I haven't changed my code at all except for those two lines. I am not getting any error messages and the program compiles just fine. Any help would be greatly appreciated. Thank you !

You are wasting your time. See, the console window doesn't belong to your program. It belongs to the user -- the human sitting in front of the PC. He wants his console window to appear where he wants it. That's why the console window gives him options to set the geometry for every console window that appears.

If your program requires the use of a text window that has specific size and position requirements, consider using a window with a windows Edit control or a Rich Edit control, and manipulating that.

To answer your other questions -- yes, there are limitations, but they are constrained by the text buffer, which you must modify to allow for bigger windows.

Sorry this isn't the kind of answer you are looking for, but it is the correct way to handle the UI.

I understand what you mean, thank you for the reply. In this particular case I'm basically just making a tiny program that will output sentences and maybe a drawing made of ASCII characters. The program is destined to one person only, and is basically just a joke.

Are you saying that whatever changes I make to the console window will not apply when that person runs it on their computer ? If that's not the case, do you still consider it bad practice, even if the program is meant to be opened by only one friend and has no particular use other than having a quick laugh ?