 |
|
 |
I've tried to make this work using VS2010, but it's useless...
Can't find atlapp.h, CUpdateUI, CMessageFilter, CIdleHandler.
-----
Chris
|
|
|
|
 |
|
 |
You obviously did not realize that
1. The article is written in 2005 using VS2005 and I never claimed that it works in VS2010. So to rate it 1 because the code does not work in VS2010 is kind of silly.
2. It requires WTL which you do not have.
|
|
|
|
 |
|
|
 |
|
 |
i am using visual studio c++ version 6.0
:\transparent\how to make a transparent and click-through window\doppler\doppler\layered.h(10) : error C2065: 'WS_EX_LAYERED' : undeclared identifier
c:\transparent\how to make a transparent and click-through window\doppler\doppler\maindlg.h(14) : see reference to class template instantiation 'CLayered' being compiled
c:\transparent\how to make a transparent and click-through window\doppler\doppler\layered.h(10) : error C2057: expected constant expression
c:\transparent\how to make a transparent and click-through window\doppler\doppler\maindlg.h(14) : see reference to class template instantiation 'CLayered' being compiled
c:\transparent\how to make a transparent and click-through window\doppler\doppler\layered.h(12) : error C2057: expected constant expression
first/second error location
class CLayered
{
enum Styles
{
-----> WIN_TRANSPARENT = WS_EX_LAYERED,
WIN_CLICK_THRU = WS_EX_LAYERED | WS_EX_TRANSPARENT
};
third error location
class CLayered
{
enum Styles
{
WIN_TRANSPARENT = WS_EX_LAYERED,
WIN_CLICK_THRU = WS_EX_LAYERED | WS_EX_TRANSPARENT
-----> };
alan
|
|
|
|
 |
|
 |
Compiler can not find WS_EX_LAYERED.
In winuser.h it's defined like this:
#if(_WIN32_WINNT >= 0x0500)
#define WS_EX_LAYERED 0x00080000
#endif
So make sure in stdafx.h you have the following line:
#define _WIN32_WINNT 0x0500
|
|
|
|
 |
|
 |
Good evening again
I have checked the include files winuser.h at both
C:\Program Files\Microsoft Platform SDK\Include
and
C:\Program Files\Microsoft Visual Studio\VC98\Include
and
#if(_WIN32_WINNT >= 0x0500)
#define WS_EX_LAYERED 0x00080000
#endif /* _WIN32_WINNT >= 0x0500 */
or any other reference to WS_EX_LAYERED is not in ether file
I have the following versions of Microsoft software installed
Microsoft Visual Studio
Microsoft Visual Studio 8
Microsoft Visual Studio .NET 2003
Microsoft.NET
I found fix at
http://upnl.org/project/Berryz/browser/toolbox/mIRCNotifier/Notifier/Layered.h?rev=590
----------------------------------------------------------------------------------
// Layered.h : interface of the CLayered class
//
/////////////////////////////////////////////////////////////////////////////
#define WS_EX_LAYERED 0x00080000
#define LWA_COLORKEY 1
#define LWA_ALPHA 2
template
class CLayered
{
enum Styles
{
WIN_TRANSPARENT = WS_EX_LAYERED,
WIN_CLICK_THRU = WS_EX_LAYERED | WS_EX_TRANSPARENT
};
bool m_bSupported;
// SetLayeredWindowAttributes() function pointer
typedef BOOL (__stdcall *PFUNCSETLAYEREDWINDOWATTR)(HWND, COLORREF, BYTE, DWORD);
PFUNCSETLAYEREDWINDOWATTR m_pfSetLayeredWindowAttributes;
BOOL SetLayered(Styles Style)
{
if (!m_bSupported)
{
ATLTRACE(_T("Your OS does not support the transparency\n"));
return FALSE;
}
T* pT = static_cast(this);
return pT->ModifyStyleEx(0, Style);
}
BOOL RemoveLayered(Styles Style)
{
T* pT = static_cast(this);
return pT->ModifyStyleEx(Style, 0);
}
public:
CLayered()
{
// To support a transparency try to get a SetLayeredWindowAttributes function address
HMODULE hUser32 = GetModuleHandle(_T("User32.dll"));
if (hUser32)
{
// Get the address of the SetLayeredWindowAttributes() function
m_pfSetLayeredWindowAttributes =
(PFUNCSETLAYEREDWINDOWATTR)::GetProcAddress(hUser32, "SetLayeredWindowAttributes");
// Set the supported indicator
if (m_pfSetLayeredWindowAttributes)
m_bSupported = true;
else
m_bSupported = false;
}
}
BOOL SetLayered()
{
// Need an extended style WS_EX_LAYERED to make it layered
return SetLayered(WIN_TRANSPARENT);
}
BOOL RemoveLayered()
{
return RemoveLayered(WIN_TRANSPARENT);
}
BOOL SetClickThru()
{
// Need an extended style WS_EX_LAYERED and WS_EX_TRANSPARENT to pass mouse clicks through the window
if (SetLayered(WIN_CLICK_THRU))
{
// Without this call the window will not be visible
return MakeTransparent(255);
}
else
return FALSE;
}
BOOL RemoveClickThru()
{
return RemoveLayered(WIN_CLICK_THRU);
}
// Sets the transparency of the window
BOOL MakeTransparent(int nOpacity)
{
if (m_bSupported)
{
ATLASSERT(m_pfSetLayeredWindowAttributes);
T* pT = static_cast(this);
return m_pfSetLayeredWindowAttributes(pT->m_hWnd, 0, (BYTE)nOpacity, LWA_ALPHA);
}
return FALSE;
}
// Sets the transparency of the window
BOOL MakeTransparent(COLORREF transparentKey)
{
if (m_bSupported)
{
ATLASSERT(m_pfSetLayeredWindowAttributes);
T* pT = static_cast(this);
return m_pfSetLayeredWindowAttributes(pT->m_hWnd, transparentKey, 0, LWA_COLORKEY);
}
return FALSE;
}
};
|
|
|
|
 |
|
 |
I can't download the demo project!
_________________________
If Microsoft is the solution, I want my problem back.
|
|
|
|
 |
|
|
 |
|
 |
now it works for me, too
_________________________
If Microsoft is the solution, I want my problem back.
|
|
|
|
 |
|
 |
I would be usefull if the article gave some information on why you want to use a transparent and click-through window?
Neville Franks, Author of Surfulater www.surfulater.com "Save what you Surf" and ED for Windows www.getsoft.com
|
|
|
|
 |
|
 |
IMO it’s a very nice and useful UI features to have. Some utilities have them, i.e. rainmeter[^]
And since somebody asked a question in the MSDN magazine I guess the answer will be interesting to a lot of people.
-- modified at 0:20 Saturday 26th November, 2005
|
|
|
|
 |
|
 |
It may be nice and useful to have it in top-level semi-transparent indicator (better not just semi-transparent, but with real alpha channel), but this feature being implemented by itself with no other features is truly useless. Maybe you'd better expand CLayered to implement additional functionality and make a normal article with something useful?
This article is an interesting tip, but nothing more.
|
|
|
|
 |
|
 |
Averk wrote: expand CLayered to implement additional functionality
It was not my intention. The intended use of this class is to add transparent functionality to the window that already has other features.
Averk wrote: This article is an interesting tip
It's not. This class allows anyone to add the transparent and/or click-through functionality real quick with just few lines of code.
|
|
|
|
 |
|
 |
First and foremost, thank you for your article. I really enjoyed it. You've got my 5.
Second, I've seen a semi-transparent window used for the search and replace (s/r) dialog, which is modeless. When the focus is on the editor's window, the s/r becomes transparent: when it is on the s/r, it becomes opaque. It's very practical when used that way.
A click-through window, totally transparent can be used on top of a regular window, to hide it from programs like Spy++. Personally, I haven't found use for this feature yet. Another use of transparency is watermarks.
Thanks again,
Pablo Aliskevicius.
|
|
|
|
 |
|
 |
Pablo Aliskevicius wrote: You've got my 5.
Thanks.
|
|
|
|
 |
|
 |
Why, you ask?
Answer: ClocX[^]
It is a very handy program that displays a clock, optionally transparent, optionally always-on-top, and optionally click-through. I love it to death!
Credit For My Personal Discovery: PCWorld Magazine
|
|
|
|
 |