应用程序作子窗口
scfan吧
全部回复
仅看楼主
level 5
scfan 楼主
Option ExplicitPrivate Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As LongPrivate Declare Function GetParent Lib "user32" (ByVal hwnd As Long) As LongPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Long, ByVal lpWindowName As Long) As LongPrivate Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As LongPrivate Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As LongPrivate Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As LongPrivate Const GW_HWNDNEXT = 2Private hwndApplicationParent As LongPrivate hwndApplication As LongPrivate Function Getwindowhwnd(ByVal lSourceId As Long) As Long Dim hwndTemp As Long Dim lProcessId As Long Dim lIdTemp As Long hwndTemp = FindWindow(ByVal 0&, ByVal 0&) Do While hwndTemp <> 0 If GetParent(hwndTemp) = 0 Then lIdTemp = GetWindowThreadProcessId(hwndTemp, lProcessId) If lProcessId = lSourceId Then Getwindowhwnd = hwndTemp Exit Do End If End If hwndTemp = GetWindow(hwndTemp, GW_HWNDNEXT) LoopEnd FunctionPrivate Sub Form_Load() dlgOpen.Filter = "应用程序|*.exe" dlgOpen.Flags = cdlOFNFileMustExist Or cdlOFNLongNames '注意参数搭配End SubPrivate Sub mmFileApplication_Click() Dim lId As Long On Error Resume Next dlgOpen.ShowOpen If Trim(dlgOpen.FileName) = "" Then Exit Sub lId = Shell(dlgOpen.FileName, vbMinimizedFocus) If lId = 0 Then MsgBox "应用程序不能正确执行 ", vbOKOnly + vbInformation Exit Sub End If hwndApplication = Getwindowhwnd(lId) hwndApplicationParent = SetParent(hwndApplication, Me.hwnd)End SubPrivate Sub mmFileNotepad_Click() Dim lId As Long lId = Shell("notepad.exe", vbNormalFocus) If lId = 0 Then MsgBox "记事本不能正确执行 ", vbOKOnly + vbInformation Exit Sub End If hwndApplication = Getwindowhwnd(lId) hwndApplicationParent = SetParent(hwndApplication, Me.hwnd)End SubPrivate Sub mmFileQuit_Click() Unload MeEnd Sub
2006年05月01日 13点05分 1
level 2
没有多少注释的程序看着真是头大阿
2006年05月06日 05点05分 2
1