Technique described at gamedev or codeguru I think. Dunno. Very very ugly and hackish.
Code:
#include <windows.h>
#include <iostream>
int main(int argc, char* argv[])
{
char szOld[200];
char szNew[200] = "hello";
int iRet;
::GetConsoleTitle(szOld, 200);
::SetConsoleTitle(szNew);
::Sleep(100);
HWND hwnd = ::FindWindow(NULL, szNew);
if(!hwnd)
{
::MessageBox(0, "Window handle not obtained", "wtf", MB_OK);
return 0;
}
::SetConsoleTitle(szOld);
::ShowWindow(hwnd, SW_HIDE);
if((iRet = ::MessageBox(0, "I'm asking you a question ..........", "rwawrwarr", MB_YESNO)) == IDYES)
{
::ShowWindow(hwnd, SW_SHOWNORMAL);
}
return 0;
}
I eluded to this without providing the code in my post above saying:
Originally Posted by
Me
...further hacking stuff up with a FindWindow to obtain the console window handle...