VB中如何嵌入其他应用程序
当前位置:点晴教程→知识管理交流
→『 技术文档交流 』
我想要在VB窗口中设一按钮,点击之后,能调用另一程序,并且该程序不会出现它自己的程序窗口,而是在VB主窗口中显示,也就是调用程序后直接就把程序显示在VB的窗口中,这该如何才能实现,望高手们帮帮忙啊~~ 谢谢ljl88900的回答,按你的做法可以实现在窗口里打开程序,但如果要把打开的程序固定在VB主窗口的中间,该怎么做?另外,我如果要用OLE控件的话,我要的程序也可以调用,但是为什么打开的程序不能象打开EXCEL或则word那样,可以在OLE窗口里打开,而是又打开另一窗口呢,高手们再次帮帮忙啊~~~ '在窗体代码区复制下面代码,然后运行程序,即可看到效果。
'=====代码部分===== Option Explicit Private Declare Function SetParent Lib "user32.dll" ( _ ByVal hWndChild As Long, _ ByVal hWndNewParent As Long) As Long Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _ ByVal hwnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Const WS_EX_MDICHILD As Long = &H40& Private Const GWL_STYLE = (-16) Private Const GWL_EXSTYLE As Long = (-20) Private Const WS_CHILD = &H40000000 Private Const WS_CHILDWINDOW = (WS_CHILD) '把计算器作为子窗体 Private Sub Form_Load() Dim lngCalculator As Long Dim lngStyle As Long Dim lngExStyle As Long Shell "calc.exe", vbNormalFocus lngCalculator = FindWindow(vbNullString, "计算器") If lngCalculator > 0 Then SetParent lngCalculator, Me.hwnd SetWindowLong lngCalculator, GWL_EXSTYLE, WS_EX_MDICHILD End If End Sub 该文章在 2013/11/18 1:04:30 编辑过 |
关键字查询
相关文章
正在查询... |