Hi,
Many thanks’ for you patient, it works correctly now .
I have just I suggest to you : how you could know I can load icon with alpha support on .res directly but I can load it how custom resource. This sub loads a custom resource and returns a byte array.
Public Function LoadDllData(ByVal Index As Long, Optional ByVal ResFormat As String = "CUSTOM") As Byte()
'*************************************************************************
'* Loads raw data from a dll
'* Parameter:
'* Index (required) : Integer specifying the Identifier (Id) of
'* the data in the resource file.
'* resformat (optional): Constant that specifies the type of
'* the data:
'* AVI, WAVE, RTF ,RCDATA ......
'* default value: CUSTOM
'* Return value : Byte-Array
'*************************************************************************
Dim hResInfo As Long
Dim hResData As Long
Dim pBuffer As Long
Dim nCount As Long
Dim bBuffer() As Byte
On Error Resume Next
Debug.Assert (m_hInstance <> 0)
' If you get this debug assertion, you forgot to load a dll
' Set the DllName property to a valId file before calling
' this method
hResInfo = FindResource(m_hInstance, Index, ResFormat)
' If you get this debug assertion, the resource you
' specified, was not found in the resource dll you are using
' Check the Id and the resource type
Debug.Assert (hResInfo <> 0)
If hResInfo > 0 Then
nCount = SizeofResource(m_hInstance, hResInfo)
' We do not want to load empty data
If nCount = 0 Then
Exit Function
End If
' Load the resource into memory
hResData = LoadResource(m_hInstance, hResInfo)
If hResData > 0 Then
' and lock it
pBuffer = LockResource(hResData)
' Fill byte array with memory block
ReDim bBuffer(nCount - 1)
CopyMemory bBuffer(0), ByVal pBuffer, nCount
Else
Err.Raise 31037, , "Error loading from file"
Exit Function
End If
Else
Err.Raise 326, , "Custom resource with Identifier " & Format$(Index) & " not found."
End If
LoadDllData = bBuffer
End Function
Public Property Let DllName(ByVal vData As String)
'*************************************************************************
'* Setting this property loads the specified dll. A previous loaded dll
'* will be unloaded.
'*************************************************************************
On Error Resume Next
If m_hInstance <> 0 Then FreeLibrary (m_hInstance)
m_hInstance = LoadLibrary(vData)
' If you get this debug assertion, your program cannot load
' the dll. Check the Path and the filename. The dll itself
' may be corrupt.
Debug.Assert (m_hInstance <> 0)
' Generate an runtime-error Identical to VB LoadResString
If m_hInstance = 0 Then
Err.Raise 48, , "Error in loading DLL: " & vData
m_sDllName = vbNullString
Else
m_sDllName = vData
End If
End Property
….
I think may be a good improvement create a new function like this:
ImageManager.Icons.LoadIconData(IconData() As Byte, Command as Long, imageState as XTPImageState)
Or load a custom resource directly from a module like the function ImageManager.Icons.LoadBitmapFromResource, so every user can import alpha icons in a resource file as custom resources and use them.
Best regards,
|