Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - ImageManager.Icons.AddIcon don't work correctly
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ImageManager.Icons.AddIcon don't work correctly

 Post Reply Post Reply
Author
Message
dimdar View Drop Down
Groupie
Groupie
Avatar

Joined: 11 July 2007
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote dimdar Quote  Post ReplyReply Direct Link To This Post Topic: ImageManager.Icons.AddIcon don't work correctly
    Posted: 11 July 2007 at 12:38pm

Hi,

I'd like create an ImageManager collection with defferent icon state so i have writed this code

With ImageManager1.Icons
    .AddIcon PicNormal.Picture.handle, ID_FILE_NEW, xtpImageNormal
    .AddIcon PicHot.Picture.handle, ID_FILE_NEW, xtpImageHot
    .AddIcon PicPressed.Picture.handle, ID_FILE_NEW, xtpImagePressed
    .AddIcon PicChecked.Picture.handle, ID_FILE_NEW, xtpImageChecked
    .AddIcon PicDisable.Picture.handle, ID_FILE_NEW, xtpImageDisabled
End With

the problem is that the image for xtpImageNormal is empty, the other work fine. The problem was only with .AddIcon, if I use .LoadIcon all work file ex:

With ImageManager1.Icons
    .LoadIcon "C:\Icons\File_New.ico", ID_FILE_NEW, xtpImageNormal
    .AddIcon PicHot.Picture.handle, ID_FILE_NEW, xtpImageHot
    .AddIcon PicPressed.Picture.handle, ID_FILE_NEW, xtpImagePressed
    .AddIcon PicChecked.Picture.handle, ID_FILE_NEW, xtpImageChecked
    .AddIcon PicDisable.Picture.handle, ID_FILE_NEW, xtpImageDisabled
End With

Thank's
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2007 at 1:35am
Hello,
 
May be PicNormal contains bitmaps - not icons ?
 
I recommend add all icons of ImageManager in design time - in properties of imagemanager.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
dimdar View Drop Down
Groupie
Groupie
Avatar

Joined: 11 July 2007
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote dimdar Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2007 at 3:50am
Hi,
 
Sorry but I don't understand. I don’t want load icon at design-time but at run-time .
 
PicNormal contain an icon because if I write:

 

With ImageManager1.Icons
    .AddIcon PicHot.Picture.handle, ID_FILE_NEW, xtpImageNormal
    .AddIcon PicNormal.Picture.handle, ID_FILE_NEW, xtpImageHot

End With

 

Otherwise:

 

With ImageManager1.Icons
    .AddIcon PicNormal.Picture.handle, ID_FILE_NEW, xtpImageNormal
    .AddIcon PicHot.Picture.handle, ID_FILE_NEW, xtpImageHot

End With

 

The xtpImageNormal is always empty but the xtpImageHot is displayed correctly when I move mouse on it. I thing this is a bug .

Back to Top
dimdar View Drop Down
Groupie
Groupie
Avatar

Joined: 11 July 2007
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote dimdar Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2007 at 4:33am
Originally posted by dimdar dimdar wrote:

Hi,
 
Sorry but I don't understand. I don’t want load icon at design-time but at run-time .
 
PicNormal contain an icon because if I write:

 

With ImageManager1.Icons
    .AddIcon PicHot.Picture.handle, ID_FILE_NEW, xtpImageNormal
    .AddIcon PicNormal.Picture.handle, ID_FILE_NEW, xtpImageHot

End With

 

Otherwise:

 

With ImageManager1.Icons
    .AddIcon PicNormal.Picture.handle, ID_FILE_NEW, xtpImageNormal
    .AddIcon PicHot.Picture.handle, ID_FILE_NEW, xtpImageHot

End With

 

The xtpImageNormal is always empty but the xtpImageHot is displayed correctly when I move mouse on it. I thing this is a bug .

 

Hi,

 

While waiting for correction bug I have found a work around: I draw my icon on ImageManagerIcon Handle  (ImageManager1.Icons.GetImage(ID_FILE_NEW, 32).Handle). But now  I have a question: If I would like draw on xtpImageHot handle?  I think that Handle property need a state arguments for retrieve image handle for each state, someone have a workaround for it?

 

Thanks’

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2007 at 8:17am
Hello,
Please attach form with PicNormal and PicHot.  Need to test it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
dimdar View Drop Down
Groupie
Groupie
Avatar

Joined: 11 July 2007
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote dimdar Quote  Post ReplyReply Direct Link To This Post Posted: 12 July 2007 at 11:09am
 
Hi,
 

This is my test application. ddIcon and ddIcons are GDI+ support class for draw icons with alpha support. I don't understand why it work with xtpImageHot (and other) but not with xtpImageNormal.

 
Thanks' you
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 13 July 2007 at 5:46am
Hi,
 
Add CommandBars.Options.UseFadedIcons = False
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
dimdar View Drop Down
Groupie
Groupie
Avatar

Joined: 11 July 2007
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote dimdar Quote  Post ReplyReply Direct Link To This Post Posted: 13 July 2007 at 6:27am

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,

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 13 July 2007 at 7:01am
Thanks for suggestion.
 
Actually if you are going use Alpha icons, I suggest you create alpha bitmaps instead - We support drawing alpha bitmaps for all OS.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
dimdar View Drop Down
Groupie
Groupie
Avatar

Joined: 11 July 2007
Status: Offline
Points: 34
Post Options Post Options   Thanks (0) Thanks(0)   Quote dimdar Quote  Post ReplyReply Direct Link To This Post Posted: 13 July 2007 at 7:10am
Originally posted by oleg oleg wrote:

Thanks for suggestion.
 
Actually if you are going use Alpha icons, I suggest you create alpha bitmaps instead - We support drawing alpha bitmaps for all OS.
 
Sorry, but alpha bitmaps are .png files?
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 16 July 2007 at 1:47am
bmp files also can have alpha layer. Photoshop 8/9/10 supports it.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.172 seconds.