vb:将窗体嵌入桌面的一段代码

前端之家收集整理的这篇文章主要介绍了vb:将窗体嵌入桌面的一段代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String,ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long,ByVal hWnd2 As Long,ByVal lpsz1 As String,ByVal lpsz2 As String) As Long
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long,ByVal hWndNewParent As Long) As Long

Public Sub PinToDesktop(FormToPin As Form)

Dim progman As Long
progman = FindWindow("progman",vbNullString)
SetParent FormToPin.hWnd,progman

End Sub

Public Sub UnPinFromDesktop(FormToUnPin As Form)

Dim lngExplorer As Long

lngExplorer = FindWindow("ExploreWClass",vbNullString)
SetParent FormToUnPin.hWnd,lngExplorer

End Sub

这里改了下

Option Explicit Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String,ByVal lpWindowName As String) As Long Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long,ByVal lpsz2 As String) As Long Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long,ByVal hWndNewParent As Long) As Long Public Sub PinToDesktop(FormToPin As Form) Dim progman As Long progman = FindWindow("progman",vbNullString) SetParent FormToPin.hWnd,progman End Sub Private Sub Command1_Click() Call PinToDesktop(Form1) End Sub

原文链接:https://www.f2er.com/vb/261119.html

猜你在找的VB相关文章