积极答复者
怎样让窗体嵌入桌面?

问题
-
我想让窗体在桌面上能显示,但处于最底层,包括桌面图标也处在它上面,其它一些窗口都在它上面。而且鼠标、键盘对它不起作用。只通过NotifyIcon的托盘来让它恢复成普通窗口后进行各种操作。请各位指点,如何实现?
网上找了好多,都有一个同样的问题,就是其中me.hwnd有弯曲的下划线,不知道还要设置些什么?
Public Class Form1 Private Declare Function GetWindowInteger Lib "user32" Alias _ "GetWindowIntegerA" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Integer Private Declare Function SetWindowInteger Lib "user32" Alias _ "SetWindowIntegerA" (ByVal hWnd As Integer, ByVal nIndex As Integer, _ ByVal dwNewInteger As Integer) As Integer Private Declare Function SetLayeredWindowAttributes Lib "user32" _ (ByVal hWnd As Integer, ByVal crKey As Integer, ByVal bAlpha As Byte, _ ByVal dwFlags As Integer) As Integer Private Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = &H80000 Private Const WS_EX_TRANSPARENT = &H20& Private Const LWA_ALPHA = &H2& Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim Style As Integer hwnd = CType(Me.Handle, Integer) Style = GetWindowInteger(Me.hWnd, GWL_EXSTYLE) Style = Style Or WS_EX_LAYERED Or WS_EX_TRANSPARENT SetWindowInteger(Me.hWnd, GWL_EXSTYLE, Style) SetLayeredWindowAttributes(Me.hWnd, 0, 255, LWA_ALPHA) End Sub End Class
答案
-
me.handle?
http://feiyun0112.cnblogs.com/- 已建议为答案 Mike FengModerator 2011年4月8日 10:54
- 已标记为答案 Mike FengModerator 2011年4月14日 8:05
-
再设置一次style?
Style = Style xOr WS_EX_LAYERED xOr WS_EX_TRANSPARENT
SetWindowInteger(Me.hWnd, GWL_EXSTYLE, Style)
http://feiyun0112.cnblogs.com/- 已标记为答案 Mike FengModerator 2011年4月14日 8:06
-
Hi Qdaijchf,
你的程序里好像没有定义变量hwnd 啊。定义先。
Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Mike FengModerator 2011年4月8日 11:01
- 已标记为答案 Mike FengModerator 2011年4月14日 8:05
全部回复
-
me.handle?
http://feiyun0112.cnblogs.com/- 已建议为答案 Mike FengModerator 2011年4月8日 10:54
- 已标记为答案 Mike FengModerator 2011年4月14日 8:05
-
-
再设置一次style?
Style = Style xOr WS_EX_LAYERED xOr WS_EX_TRANSPARENT
SetWindowInteger(Me.hWnd, GWL_EXSTYLE, Style)
http://feiyun0112.cnblogs.com/- 已标记为答案 Mike FengModerator 2011年4月14日 8:06
-
Hi Qdaijchf,
你的程序里好像没有定义变量hwnd 啊。定义先。
Best regards,
Mike Feng [MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- 已建议为答案 Mike FengModerator 2011年4月8日 11:01
- 已标记为答案 Mike FengModerator 2011年4月14日 8:05