我想將shell執行出來的程式鑲在vb程式上,就是類似變成vb的一部份那種,可以隨vb程式改變大小。
請各位大大幫一下^^\"
2006-05-05 19:41:06 · 4 個解答 · 發問者 Pastoryan 1 in 電腦與網際網路 ➔ 程式設計
W.J.S.大所用的方式確實可以將物件鑲在vb內,但似乎沒辦法隨時改跟著vb的程式改變大小。我希望的目標是當vb的視窗被改變時,內鑲的程式也能以同比例改變。謝謝幫忙^^"
2006-05-06 13:27:48 · update #1
'以啟動記事本為例Private Type PT X As Long Y As LongEnd TypePrivate Type RECT L As Long T As Long R As Long B As LongEnd TypePrivate Type Wn L As Long F As Long C As Long M As PT X As PT N As RECTEnd TypePrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal C&, ByVal W&) As LongPrivate Declare Function GetParent Lib "user32" (ByVal H&) As LongPrivate Declare Function GetWindow Lib "user32" (ByVal H&, ByVal C&) As LongPrivate Declare Sub DestroyWindow Lib "user32" (ByVal H&)Private Declare Sub Putfocus Lib "user32" Alias "SetFocus" (ByVal H&)Private Declare Sub GetWindowThreadProcessId Lib "user32" (ByVal H&, P&)Private Declare Sub SetWindowPlacement Lib "user32" (ByVal H&, L As Wn)Private Declare Sub SetParent Lib "user32" (ByVal H&, ByVal P&)Dim V&Function PTH(ByVal P&) As LongDim A&, B& A = FindWindow(0, 0)Do While A If GetParent(A) = 0 Then GetWindowThreadProcessId A, B If B = P Then PTH = A Exit Do End If End If A = GetWindow(A, 2)LoopEnd FunctionPrivate Sub Form_Load()Dim P&, R As RECT, W As Wn'啟動記事本P = Shell("C:\Winnt\Notepad.exe")If P Then '找記事本hWnd V = PTH(P) '將記事本加入form SetParent V, hwnd '使記事本獲得駐點 Putfocus V '設定記事本的方位大小 ScaleMode = 3 W.L = Len(W) R.R = ScaleWidth R.B = ScaleHeight W.C = 1 W.N = R SetWindowPlacement V, WEnd IfEnd SubPrivate Sub Form_Unload(Cancel As Integer)'關掉記事本DestroyWindow VEnd Sub
2006-05-07 01:30:11 補充:
Pia大大已回答,我就不用再補充了
2006-05-06 13:04:28 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋
我有辦法
在程式碼加上這段:
Private Sub Form_Resize()
If P Then
ScaleMode = 3
W.L = Len(W)
R.R = ScaleWidth
R.B = ScaleHeight
W.C = 1
W.N = R
SetWindowPlacement V, W
End If
End Sub
然後再把Form_Load()程序中的第一行 Dim P&, R As RECT, W As Wn
移動至Dim V&下面
就可以啦!^^
2007-01-01 12:08:14 · answer #2 · answered by 阿不拉 2 · 0⤊ 0⤋
怪了!
很有價值的程式,怎會没人評價呢?
我來推一下
2006-07-27 23:07:42 · answer #3 · answered by ㄚ旺 5 · 0⤊ 0⤋
'當vb的視窗被改變時,內鑲的程式以同比例改變
Private Sub Form_Resize()
Dim P&, R As RECT, W As Wn
W.L = Len(W)
R.R = ScaleWidth
R.B = ScaleHeight
W.C = 1
W.N = R
SetWindowPlacement V, W
End Sub
2006-05-06 20:42:16 · answer #4 · answered by Pia 3 · 0⤊ 0⤋