Home > Language Reference > Classes > StreamMemory

Map Method

Maps the StreamMemory object to a specific memory address.

Syntax

Public Sub Map(ByVal lStartAddr As Long, Optional ByVal lSize As Long = -1)

ParameterDescription
lStartAddrStarting address.
lSizeOptional size.

Remarks

The Map method maps the StreamMemory object to the memory block whose address and size are specified by the lStartAddr and lSize parameters. If the object previously allocated a memory block, it is freed. This method does not perform parameter validation. It is up to the programmer to ensure the memory lStartAddr points to correspond to a valid chunk.

After this method is called, the Kind property returns hbStreamMapped.

This method is typically used to manage pointers, whether they are returned by an external C function or by a predefined HB++ function. The following example uses a memory mapped StreamMemory object to access bitmap bits:

Private Sub Button1_Click()
  Dim bm As New Bitmap
  Dim s As New StreamMemory
  Dim x As Integer, y As Integer
  
  bm.Create 80,50,8,hbDensityLow
  s.Map bm.Bits, 80*50
  For y=0 To 49
    For x=0 To 79
      s.Write CByte(x)
    Next x
  Next y
  CopyArea 0,20,80,50,bm,0,0
End Sub

For further information on shared libraries and communication between HB++ and the C language, refer to the Shared library chapter in the Programmer's Guide and the description of the Declare statement.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A