阅读:1432回复:2
Visual Basic Example of GlobalHandle
' These declarations need to be placed in a VB Module (like Module1.bas).
' They are WINAPI calls dealing with Global Handles Public Const GMEM_MOVEABLE = &H2 Declare Function GlobalAlloc Lib "kernel32" (ByVal wFlags As Long, _ ByVal dwBytes As Long) As Long Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long Declare Function GlobalUnlock Lib "kernel32" (ByVal hMem As Long) As Long Declare Function lstrcpy Lib "kernel32" Alias "lstrcpyA" _ (ByVal lpString1 As Any, _ ByVal lpString2 As Any) As Long : : : Private Sub Command1_Click() ' The global handle which will contain the actual data. Dim GlobalHandle As Long ' This temporarily points to the location of the locked ' handle's data, so we can copy our data in Dim MemoryBlockAddress As Long Dim tabifiedData As String ' Our source data in the correct tab-deliminated form. ' In practice, this could come from a text file or some other source. ' The Chr() calls are special characters: 9 is a tab, 13 is a carriage ' return, and 10 is a linefeed. tabifiedData = """NY""" & Chr(9) & "105.40" & Chr(13) & Chr(10) & _ """MA""" & Chr(9) & "245.13" & Chr(13) & Chr(10) & _ """AK""" & Chr(9) & "195.30" & Chr(13) & Chr(10) & _ """CA""" & Chr(9) & "56.65" & Chr(13) & Chr(10) & _ """WI""" & Chr(9) & "100.00" & Chr(13) & Chr(10) ' Allocate space for the handle's data and copy the source data into it GlobalHandle = GlobalAlloc(GMEM_MOVEABLE, Len(tabifiedData) + 1) MemoryBlockAddress = GlobalLock(GlobalHandle) lstrcpy MemoryBlockAddress, tabifiedData GlobalUnlock GlobalHandle Dim ds As Dataset ' Now add the dataset to the datasets collection Set ds = Map1.Datasets.Add(miDataSetGlobalHandle, GlobalHandle, "TestDS") ' And create a simple theme from the data ds.Themes.Add End Sub |
|
|
1楼#
发布于:2003-09-19 00:05
嘿嘿,小袁,能在这里碰到你,真是不错
|
|
|
2楼#
发布于:2003-09-19 18:53
河马兄,你真的是 10.1 的生日吗?
我也是,呵呵,真巧,同一天!! 呵呵哈哈哈哈呵呵 |
|
|