Esempio n. 1
0
void SetLayeredTaskbar(HWND hwndClock)
{
	LONG exstyle;
	HWND hwnd;
	int alpha;
	
	alpha = GetMyRegLongEx("Taskbar", "AlphaTaskbar", 0);
	bClearTaskbar = GetMyRegLongEx("Taskbar", "ClearTaskbar", FALSE);
	alpha = 255 - (alpha * 255 / 100);
	if(alpha < 8) alpha = 8; else if(alpha > 255) alpha = 255;
	
	if(!pSetLayeredWindowAttributes && (alpha < 255 || bClearTaskbar)) InitLayeredWindow();
	if(!pSetLayeredWindowAttributes) return;
	
	hwnd = GetParent(GetParent(hwndClock));
	
	exstyle = GetWindowLong(hwnd, GWL_EXSTYLE);
	if(alpha < 255 || bClearTaskbar) exstyle |= WS_EX_LAYERED;
	else exstyle &= ~WS_EX_LAYERED;
	SetWindowLong(hwnd, GWL_EXSTYLE, exstyle);
	if(bRefreshClearTaskbar)
	{
		bRefreshClearTaskbar = FALSE;
		RefreshUs();
	}
	RefreshRebar(hwnd);
	
	if(alpha < 255 && !bClearTaskbar)
		pSetLayeredWindowAttributes(hwnd, 0, (BYTE)alpha, LWA_ALPHA);
	else if(bClearTaskbar)
		pSetLayeredWindowAttributes(hwnd, GetSysColor(COLOR_3DFACE), (BYTE)alpha, LWA_COLORKEY|LWA_ALPHA);

}
Esempio n. 2
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//style_set_transparency
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void style_set_transparency(HWND hwnd, BYTE transvalue, bool transback)
{
	if (pSetLayeredWindowAttributes)
	{
		LONG s = GetWindowLong(hwnd, GWL_EXSTYLE);
		UINT flags = 0;
		if (transback) flags |= LWA_COLORKEY;
		if (transvalue < 255) flags |= LWA_ALPHA;
		if (flags)
		{
			if (0 == (s & WS_EX_LAYERED))
				SetWindowLong(hwnd, GWL_EXSTYLE, s | WS_EX_LAYERED);
			pSetLayeredWindowAttributes(hwnd, transback ? TRANSCOLOUR : 0, transvalue, flags);
		}
		else
		{
			if (0 != (s & WS_EX_LAYERED))
				SetWindowLong(hwnd, GWL_EXSTYLE, s & ~WS_EX_LAYERED);
		}
	}
}
Esempio n. 3
0
bool
create_window(void)
{
	WNDCLASSEX wndClass;
	ZeroMemory (&wndClass, sizeof (wndClass));
    wndClass.cbSize        = sizeof (wndClass);
    wndClass.style         = CS_HREDRAW | CS_VREDRAW;
    wndClass.lpfnWndProc   = WndProc;
    wndClass.cbClsExtra    = 0;
    wndClass.cbWndExtra    = 0;
    wndClass.hInstance     = hInst;
    wndClass.hIcon         = LoadIcon (NULL, IDI_APPLICATION);
    wndClass.hIconSm       = NULL;
    wndClass.hCursor       = LoadCursor (NULL, IDC_ARROW);
    wndClass.hbrBackground = (HBRUSH) GetStockObject(GRAY_BRUSH);
    wndClass.lpszMenuName  = NULL;
    wndClass.lpszClassName = "blackscreen";

        if (!RegisterClassEx(&wndClass)) {
 //               return false;
        }

        RECT clientRect;
        clientRect.left = 0;
        clientRect.top = 0;
        clientRect.right = GetSystemMetrics(SM_CXSCREEN);
        clientRect.bottom = GetSystemMetrics(SM_CYSCREEN);

        UINT x(GetSystemMetrics(SM_XVIRTUALSCREEN));
        UINT y(GetSystemMetrics(SM_YVIRTUALSCREEN));
        UINT cx(GetSystemMetrics(SM_CXVIRTUALSCREEN));
        UINT cy(GetSystemMetrics(SM_CYVIRTUALSCREEN));

        clientRect.left = x;
        clientRect.top = y;
        clientRect.right = x + cx;
        clientRect.bottom = y + cy;

        AdjustWindowRect (&clientRect, WS_CAPTION, FALSE);
        hwnd = CreateWindowEx (0,
                               "blackscreen",
                               "blackscreen",
                               WS_POPUP  | WS_CLIPSIBLINGS | WS_CLIPCHILDREN|WS_BORDER,
                               CW_USEDEFAULT,
                               CW_USEDEFAULT,
                               cx,
                               cy,
                               NULL,
                               NULL,
                               hInst,
                               NULL);
		typedef DWORD (WINAPI *PSLWA)(HWND, DWORD, BYTE, DWORD);

	PSLWA pSetLayeredWindowAttributes=NULL;
	/*
	* Code that follows allows the program to run in 
	* environment other than windows 2000
	* without crashing only difference being that 
	* there will be no transparency as 
	* the SetLayeredAttributes function is available only in
	* windows 2000
	*/
	HMODULE hDLL = LoadLibrary ("user32");
	if (hDLL) pSetLayeredWindowAttributes = (PSLWA) GetProcAddress(hDLL,"SetLayeredWindowAttributes");
	/*
	* Make the windows a layered window
	*/

#ifndef _X64
	LONG style = GetWindowLong(hwnd, GWL_STYLE);
	style = GetWindowLong(hwnd, GWL_STYLE);
	style &= ~(WS_DLGFRAME | WS_THICKFRAME);
	SetWindowLong(hwnd, GWL_STYLE, style);
#else
	LONG_PTR style = GetWindowLongPtr(hwnd, GWL_STYLE);
	style = GetWindowLongPtr(hwnd, GWL_STYLE);
	style &= ~(WS_DLGFRAME | WS_THICKFRAME);
	SetWindowLongPtr(hwnd, GWL_STYLE, style);
#endif

	if (pSetLayeredWindowAttributes != NULL) {
#ifndef _X64
		SetWindowLong (hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) |WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST);
#else
		SetWindowLongPtr (hwnd, GWL_EXSTYLE, GetWindowLongPtr(hwnd, GWL_EXSTYLE) |WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOPMOST);
#endif
	    ShowWindow (hwnd, SW_SHOWNORMAL);
	}
	if (pSetLayeredWindowAttributes != NULL) {
	/**
	* Second parameter RGB(255,255,255) sets the colorkey to white
	* LWA_COLORKEY flag indicates that color key is valid
	* LWA_ALPHA indicates that ALphablend parameter (factor)
	* is valid
	*/
	pSetLayeredWindowAttributes (hwnd, RGB(255,255,255), 255, LWA_ALPHA);
	}
	SetWindowPos(hwnd,HWND_TOPMOST,x,y,cx,cy, SWP_FRAMECHANGED|SWP_NOACTIVATE);
//SM_CXVIRTUALSCREEN
	return true;
}