如果使用SetLayeredWindowAttributes设置为透明,则对话框不会保持最顶部 [英] Dialog not remaing topmost if set transparent using SetLayeredWindowAttributes
本文介绍了如果使用SetLayeredWindowAttributes设置为透明,则对话框不会保持最顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使我的window(dlg)透明且最顶部,但不起作用.这是我的代码:-
I am trying to make my window(dlg) transparent and top most but doesn''t work. Here is my code:-
SetWindowLong(m_hWnd, GWL_EXSTYLE,
GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED | WS_EX_TOPMOST );
// Make this window 70% alpha
SetLayeredWindowAttributes(m_hWnd, 0, (255 * 50) / 100, LWA_ALPHA);
SetWindowPos( &wndTopMost, TRANSP_X_POS, TRANSP_Y_POS, TRANSP_WDTH, TRANSP_HGHT, SWP_NOCOPYBITS | SWP_NOREPOSITION );
有任何建议吗?
Any suggestions?
推荐答案
您可以尝试致电SetForegroundWindow(GetSafeHwnd())
:)
其实我的问题是由于使用OpenGL.
我同时使用Open GL和MFC.
在OpenGl上加载时(应用程序之间的代码.....)
g_hDC = GetDC(g_hWnd);
PixelFormat = ChoosePixelFormat(g_hDC,& pfd);
SetPixelFormat(g_hDC,PixelFormat,& pfd);
g_hRC = wglCreateContext(g_hDC);
wglMakeCurrent(g_hDC,g_hRC);
此时wglMakeCurrent(g_hDC,g_hRC);系统光标的长度被剪裁.(我认为是这样)
在此之后,如果我尝试在mfc中加载具有大尺寸字符串(8至10个字符)的systemcursor .....游标未完整显示.
actually my problem was due to the ussage of OpenGL .
I am using Both Open GL and MFC .
when on OpenGl Application is loaded( code ..... in between )
g_hDC = GetDC( g_hWnd );
PixelFormat = ChoosePixelFormat( g_hDC, &pfd );
SetPixelFormat( g_hDC, PixelFormat, &pfd);
g_hRC = wglCreateContext( g_hDC );
wglMakeCurrent( g_hDC, g_hRC );
at this point wglMakeCurrent( g_hDC, g_hRC ); system cursor length is clipped.(i think interanlly)
After this if i try to load systemcursor with a string of large size( 8 to 10 char) in mfc ..... cursor is not shown to full length.
这篇关于如果使用SetLayeredWindowAttributes设置为透明,则对话框不会保持最顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文