VB中如何嵌入其他應(yīng)用程序
當(dāng)前位置:點(diǎn)晴教程→知識(shí)管理交流
→『 技術(shù)文檔交流 』
我想要在VB窗口中設(shè)一按鈕,點(diǎn)擊之后,能調(diào)用另一程序,并且該程序不會(huì)出現(xiàn)它自己的程序窗口,而是在VB主窗口中顯示,也就是調(diào)用程序后直接就把程序顯示在VB的窗口中,這該如何才能實(shí)現(xiàn),望高手們幫幫忙啊~~ 謝謝ljl88900的回答,按你的做法可以實(shí)現(xiàn)在窗口里打開程序,但如果要把打開的程序固定在VB主窗口的中間,該怎么做?另外,我如果要用OLE控件的話,我要的程序也可以調(diào)用,但是為什么打開的程序不能象打開EXCEL或則word那樣,可以在OLE窗口里打開,而是又打開另一窗口呢,高手們?cè)俅螏蛶兔Π~~ '在窗體代碼區(qū)復(fù)制下面代碼,然后運(yùn)行程序,即可看到效果。
'=====代碼部分===== 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) '把計(jì)算器作為子窗體 Private Sub Form_Load() Dim lngCalculator As Long Dim lngStyle As Long Dim lngExStyle As Long Shell "calc.exe", vbNormalFocus lngCalculator = FindWindow(vbNullString, "計(jì)算器") 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 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |