Ive posted this on another forum, and haven't gotten very far. I had a few skillful coders give it a go, and no luck.
We got errors...

I'm trying to make a console app... Transparent, or translucent. (See-through)
Ive tried:

#include <iostream>
#define _WIN32_WINNT 0x0500
#include <windows.h>
using namespace std;
int main()
{
    HWND hWnd = GetConsoleWindow();
    SetConsoleTitle("Test");
    SetWindowLong(hWnd, GWL_EXSTYLE,
    GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
    SetLayeredWindowAttributes(hWnd, 0, 50, LWA_ALPHA);
    system("PAUSE");
    return 0;
}

And got:

K:\Computers\C++ stuff\C++ Projects\Untitled1.cpp:21: Error 5
K:\Computers\C++ stuff\C++ Projects\Untitled1.cpp:23: Error 87

Any idea's as to if it's possible?
Thanks guys. :)

~BRADSZY~

#include <stdio.h>
#define _WIN32_WINNT 0x0500
#include <windows.h>

#define CHECK_ERROR(x) if (!x) error(__FILE__, __LINE__, GetLastError())


void error(const char *file, int line, int err)
{
  printf("%s:%d: Error %d\n", file, line, err);
}

int main()
{
    LONG lRet;
    HWND hWnd = GetConsoleWindow();
    CHECK_ERROR(hWnd);
    SetConsoleTitle("Test");
    lRet = SetWindowLong(hWnd, GWL_EXSTYLE,
        GetWindowLong(hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
    CHECK_ERROR(lRet);
    lRet = SetLayeredWindowAttributes(hWnd, 0, 50, LWA_ALPHA);
    CHECK_ERROR(lRet);

    system("PAUSE");
    return 0;
}

That was the error checking code...

Edited 3 Years Ago by mike_2000_17: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.