From: P4R4N01D on
I am using Dev-C++ and I have got the following in WM_INITDIALOG, and I
don't get any warnings or errors about it. The problem is that it doesn't
seem to do anything. slwa_function succeeds in getting the address of the
function and returns a non-zero value when it is called (I debugged this to
confirm). Note that SEEMsgBox simply brings up a message box (I use it for
debugging, easier to pass one param rather than 5).
Code:
HMODULE hUser32;
hUser32 = GetModuleHandle(TEXT("USER32.DLL"));
typedef int (WINAPI *lpfnSetLayeredWindowAttributes) (HWND , COLORREF , BYTE
, DWORD );
lpfnSetLayeredWindowAttributes slwa_function;

if(!(slwa_function=(lpfnSetLayeredWindowAttributes)GetProcAddress(hUser32,"SetLayeredWindowAttributes")))
SEEMsgBox("ERROR CALLING SETLAYEREDWINDOW");

// Set WS_EX_LAYERED on this window
SetWindowLong(hwndDlg, GWL_EXSTYLE, GetWindowLong(hwndDlg, GWL_EXSTYLE) |
WS_EX_LAYERED);
// Change opacity of window
slwa_function(hwndDlg, 0,(255 * 50) / 100, LWA_ALPHA);
I had to use the above approach as the function was not referenced in
libuser32. I have asked about this on cboard already:
http://cboard.cprogramming.com/showthread.php?t=104120


From: Stephen on
P4R4N01D wrote:
> I am using Dev-C++ and I have got the following in WM_INITDIALOG, and I
> don't get any warnings or errors about it. The problem is that it doesn't
> seem to do anything. slwa_function succeeds in getting the address of the
> function and returns a non-zero value when it is called (I debugged this to
> confirm).

I've tested your code with VS.NET on XP, ant it works fine...