-
SetConsoleWindowInfo
I wrote a really annoying program that goes something like this:
Code:
#include <time.h>
#include <windows.h>
#include <stdlib.h>
int main()
{
time_t now;
time(&now);
srand(now);
while(true)
{
Sleep(100);
SMALL_RECT WinRect = {0, 0, rand() % 100 + 1, rand() % 70 + 1};
SMALL_RECT* WinSize = &WinRect;
SetConsoleWindowInfo(GetStdHandle(STD_OUTPUT_HANDLE), true, WinSize);
}
return 0;
}
I was wondering, is there a way to move the console window? All this does is resize.
-
There is not a specific console routine to do this, however, you can of course cheat.
Code:
#include <windows.h>
int main()
{
HWND hWnd;
RECT WinRect;
SetConsoleTitle("Home");
hWnd = FindWindow(NULL,
"Home");
GetWindowRect(hWnd,
&WinRect);
MoveWindow(hWnd,
0,
0,
WinRect.right - WinRect.left,
WinRect.bottom - WinRect.top,
TRUE);
return 0;
}
-
You can have console applications that uses MFC, which allows you to control the current window and do a lot of other things.