久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

如何將Excel嵌入到VB中

 昵稱(chēng)6703750 2011-04-02
將Excel數(shù)據(jù)嵌入到VB中,,使他在VB的MDI窗體中,,看起來(lái)就像VB的一部分,同時(shí)我也可以用代碼對(duì)其進(jìn)行讀寫(xiě)
我用OLE把它嵌入到里面,,不過(guò)每次雙擊以后,,出來(lái)的Excel大小我無(wú)法控制
(我不想用對(duì)象的方式來(lái)操作Excel,因?yàn)槲乙丫庉嫳砀竦慕缑嫣峁┙o用戶(hù))
bas中:

Public XL As Excel.Application, xlHwnd As Long
Public Declare Sub Sleep Lib "kernel32 " (ByVal dwMilliseconds As Long)

Public Const WS_CAPTION As Long = &HC00000
Public Const SW_SHOW As Long = 5
Public Const WS_EX_APPWINDOW = &H40000
Public Const SW_SHOWMAXIMIZED = 3
Public Const GWL_STYLE As Long = -16

Public Const GW_HWNDNEXT = 2

Public Declare Function GetWindowThreadProcessId Lib "user32 " (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Public Declare Function GetParent Lib "user32 " (ByVal hwnd As Long) As Long
Public Declare Function FindWindow Lib "user32 " Alias "FindWindowA " (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetWindow Lib "user32 " (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetWindowText Lib "user32 " Alias "GetWindowTextA " (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function SetParent Lib "user32 " (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long

Public Declare Function SetWindowLong Lib "user32 " Alias "SetWindowLongA " (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function GetWindowLong Lib "user32 " Alias "GetWindowLongA " (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Public Declare Function ShowWindow Lib "user32 " (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function DrawMenuBar Lib "user32 " (ByVal hwnd As Long) As Long

Public Const WS_SYSMENU = &H80000

Public Sub RemoveSysButton(ByVal hHwnd As Long)
Dim lWnd As Long
lWnd = GetWindowLong(hHwnd, GWL_STYLE)
lWnd = lWnd And Not (WS_SYSMENU)
lWnd = SetWindowLong(hHwnd, GWL_STYLE, lWnd)
DrawMenuBar hHwnd
End Sub

Function InstanceToWnd(ByVal target_pid As Long) As Long
Dim test_hwnd As Long
Dim test_pid As Long
Dim test_thread_id As Long

test_hwnd = FindWindow(ByVal 0&, ByVal 0&)

Do While test_hwnd <> 0
If GetParent(test_hwnd) = 0 Then
test_thread_id = GetWindowThreadProcessId(test_hwnd, test_pid)
If test_pid = target_pid Then
InstanceToWnd = test_hwnd
Exit Do
End If
End If
test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)
Loop
End Function

Public Sub SetFormStyle(hwnd)
Dim IStyle As Long
IStyle = GetWindowLong(hwnd, GWL_STYLE)
IStyle = IStyle And Not WS_CAPTION And Not WS_EX_APPWINDOW
SetWindowLong hwnd, GWL_STYLE, IStyle
ShowWindow hwnd, SW_SHOW
DrawMenuBar hwnd
End Sub
form中:

Set XL = CreateObject( "excel.application ")
xlHwnd = FindWindow( "XLMAIN ", XL.Caption)
oldHwnd = GetParent(xlHwnd)

Call SetFormStyle(xlHwnd)

l = SetParent(xlHwnd, Me.hwnd)

XL.Workbooks.Open FileName:= "要打開(kāi)的文檔 "

RemoveSysButton xlHwnd

XL.WindowState = xlNormal
XL.Height = Me.Height / 20
XL.Width = Me.Width / 20
XL.Top = 0
XL.Left = 0


大體就是這樣的,,在此基礎(chǔ)上再完善一下就達(dá)到要求了,。

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶(hù)發(fā)布,,不代表本站觀點(diǎn),。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,,謹(jǐn)防詐騙,。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶(hù) 評(píng)論公約