#include <cstdlib>
#include <iostream>
#include <windows.h>
#include <winuser.h>
HWND taskbar = FindWindow("Shell_traywnd", NULL);
RECT rect;
int what = GetWindowRect(taskbar, &rect);
const long MonitorWidth = ::GetSystemMetrics(SM_CXSCREEN);
const long MonitorHeight = ::GetSystemMetrics(SM_CYSCREEN) - (rect.bottom - rect.top);
using namespace std;
void ChooseWindow()
{
while(1)
if (GetAsyncKeyState(121)==-32767)
{
HWND TheWindow = GetForegroundWindow();
break;
}
else {
Sleep(10);
}
}
int main()
{
unsigned short int WindowsAmount;
cout << "Hoeveel vensters wilt u verdelen? (2 - 8)" << "\n";
cin >> WindowsAmount;
switch(WindowsAmount)
{
case 4:
{
HWND TheWindow;
ChooseWindow();
SetWindowPos(TheWindow,
HWND_TOP,
0,
0,
MonitorWidth / 2,
MonitorHeight / 2,
SWP_SHOWWINDOW |
SWP_NOOWNERZORDER |
SWP_NOREDRAW
);
HWND TheWindow4 = FindWindow(NULL, "Naamloos - Paint");
SetWindowPos(TheWindow4,
HWND_TOP,
MonitorWidth / 2,
0,
MonitorWidth / 2,
MonitorHeight / 2,
SWP_SHOWWINDOW |
SWP_NOOWNERZORDER |
SWP_NOREDRAW
);
HWND TheWindow5 = FindWindow(NULL, "Naamloos - Kladblok");
SetWindowPos(TheWindow5,
HWND_TOP,
0,
MonitorHeight / 2,
MonitorWidth / 2,
MonitorHeight / 2,
SWP_SHOWWINDOW |
SWP_NOOWNERZORDER |
SWP_NOREDRAW
);
HWND TheWindow6 = FindWindow(NULL, "Document - WordPad");
SetWindowPos(TheWindow6,
HWND_TOP,
MonitorWidth / 2,
MonitorHeight / 2,
MonitorWidth / 2,
MonitorHeight / 2,
SWP_SHOWWINDOW |
SWP_NOOWNERZORDER |
SWP_NOREDRAW
);
}
break;
default:
{
cout << "Invoer is onjuist";
}
}
Sleep(1000);
}