2012-07-06 101 views
0

我想透明的任何应用程序窗口,而不是使用c#或vC++的内容。例如,如果我打开了我的电脑,那么它使得该窗口对于我的应用程序而言不是透明的。使透明背景的应用程序窗口

+0

你需要更具体一点。您是否问过如何在C#中将自己的应用程序编程为透明? – zeencat 2012-07-06 13:26:38

+0

您是否正在谈论使您自己的应用程序中的窗口透明,还是属于其他应用程序的窗口? – 2012-07-06 13:27:19

+0

我想透明任何打开的窗口从我的应用程序中选择。例如。我的电脑打开,然后我可以使它从我的应用程序不透明(仅仅是它的背景...)而不是它的文件夹。只有窗口背景透明。 – 2012-07-07 07:20:12

回答

1

设置表单属性

this.BackColor = System.Drawing.Color.Lime; 
this.TransparencyKey = System.Drawing.Color.Lime; 
+0

这将在其代码中设置表单的属性,但不设置操作系统上任何应用程序的属性。 – GrayFox374 2012-07-06 13:41:47

+0

谢谢..它会工作,但正如我所说..我想从我的应用程序,它会列出打开的窗口..就像我的电脑,任何文件夹等..我会选择它,并使该窗口透明我的应用程序。 – 2012-07-09 05:17:49

0

到谷歌:

http://www.intowindows.com/make-windows-7-transparent-with-system-transparency-tool/

您可以在Windows 7轻松地做到这一点,不需要任何代码。对于运200/XP,到谷歌机一次:

http://www.codeproject.com/Articles/4473/Making-any-application-transparent-in-Windows-2000

布尔m_bTracking; //当鼠标为 //时将为true //正在跟踪HWND m_hCurrWnd; //处理鼠标上次出现的窗口 HCURSOR m_hCursor; //魔杖光标

//全局定义的typedef BOOL(WINAPI * lpfn)(HWND的HWND,COLORREF CR, BYTE bAlpha,DWORD dwFlags中); lpfn g_pSetLayeredWindowAttributes;

BOOL CWinTransDlg :: OnInitDialog中(){ .... //获得SetLayeredWindowAttributes //在User32.dll中 HMODULE hUser32 =的GetModuleHandle(_T( “USER32.DLL”))的函数指针; g_pSetLayeredWindowAttributes =(lpfn)GetProcAddress(hUser32, “SetLayeredWindowAttributes”); if(g_pSetLayeredWindowAttributes == NULL) AfxMessageBox( “分层不支持此版本的Windows”, MB_ICONEXCLAMATION);

// Load the wand cursor 
HINSTANCE hInstResource = AfxFindResourceHandle(
    MAKEINTRESOURCE(IDC_WAND), RT_GROUP_CURSOR); 
m_hCursor = ::LoadCursor(hInstResource, MAKEINTRESOURCE(IDC_WAND)); 
... } 

空隙CWinTransDlg :: OnLButtonDown中(UINT NFLAGS,口岸系统点){ ... SetCapture(); //使鼠标移动事件为 //定向到此窗口 m_hCurrWnd = NULL; //目前没有窗口要透明 m_bTracking = true; //设置跟踪标志 :: SetCursor(m_hCursor); //转动鼠标指针到棒光标 ...}

空隙CWinTransDlg ::的OnMouseMove(UINT NFLAGS,口岸系统点){ ... 如果(m_bTracking) { ... //将鼠标坐标转换为屏幕 ClientToScreen(& point); ... //获得鼠标协调窗口 m_hCurrWnd = :: WindowFromPoint(point); ... 像类,字幕等 窗口//显示详细信息... } ...}

无效CWinTransDlg :: OnLButtonUp(UINT NFLAGS,口岸系统点){ .. 。 //停止跟踪鼠标 ReleaseCapture(); m_bTracking = false;

// If the window under the mouse is not of this 
// application we toggle its 
// layer style flag and apply the alpha as set by the slider control 
if (g_pSetLayeredWindowAttributes && m_hCurrWnd != m_hWnd) 
{ 
    ::SetWindowLong(m_hCurrWnd, GWL_EXSTYLE, 
        GetWindowLong(m_hCurrWnd, 
        GWL_EXSTYLE)^WS_EX_LAYERED); 
    g_pSetLayeredWindowAttributes(m_hCurrWnd, 0, 
        (BYTE)m_slider.GetPos(), LWA_ALPHA); 

    ::RedrawWindow(m_hCurrWnd, NULL, NULL, 
        RDW_ERASE | RDW_INVALIDATE | 
        RDW_FRAME | RDW_ALLCHILDREN); 
} 
... } 
+0

你应该在这里发布片段以防万一URL死掉。 – Snuffleupagus 2012-07-06 13:33:16

+0

好主意,将编辑。 – GrayFox374 2012-07-06 13:40:31