Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » can´t find the resource from my resource_only_dll Collapse All
Subject Author Date
Bertil Morefält Nov 20, 2009 - 9:24 AM

Hi!


I have an MDI application with 28 dll:s (MFC Extenstion DLL:s) and I am trying to bild a new MFC Extenstin DLL where I want to use yours ProfUIS 2.85.  One of my Dll:s are a resource_only_dll where all my resources resides. When I try to use radio button yours CExtImageList can´t find the resource and objBitmap.Attach allways fails . When I checked your source code I found i very odd that you in the CExtImageList constrructor have ’ HINSTANCE hInstResource = AfxGetInstanceHandle()’ shouldn’t it be ’ HINSTANCE hInstResource = AfxGetResourceHandle()’. How do I solve this problem?


Best Regards,


Bertil Morefält

Technical Support Nov 20, 2009 - 2:44 PM

Thank you for reporting us this issue. Here is the updated source code:

class __PROF_UIS_API CExtImageList : public CImageList
{
public:
            CExtImageList()
            {
            }
            CExtImageList(
                        UINT nResourceID,
                        COLORREF clrTransparencyMask = RGB(255,0,255),
                        int nButtonWidth = 16,
                        HINSTANCE hInstResource = AfxGetInstanceHandle(),
                        UINT nColorFlag = ILC_COLOR24,
                        UINT nColorAddionalFlag = ILC_MASK
                        )
            {
                        VERIFY(
                                    Load(
                                                nResourceID,
                                                clrTransparencyMask,
                                                nButtonWidth,
                                                hInstResource,
                                                nColorFlag,
                                                nColorAddionalFlag
                                                )
                                    );
            }
            BOOL Load(
                        UINT nResourceID,
                        COLORREF clrTransparencyMask = RGB(255,0,255),
                        int nButtonWidth = 16,
                        HINSTANCE hInstResource = AfxGetInstanceHandle(),
                        UINT nColorFlag = ILC_COLOR24,
                        UINT nColorAddionalFlag = ILC_MASK
                        )
            {
                        ASSERT(
                                                nColorFlag == ILC_COLOR4
                                    ||           nColorFlag == ILC_COLOR8
                                    ||           nColorFlag == ILC_COLOR16
                                    ||           nColorFlag == ILC_COLOR24
                                    ||           nColorFlag == ILC_COLOR32
                                    );
                        if( hInstResource == NULL )
                        {
                                    hInstResource = ::AfxGetResourceHandle();
                                    if( hInstResource == NULL )
                                    {
                                                hInstResource = ::AfxGetInstanceHandle();
                                                if( hInstResource == NULL )
                                                {
                                                            ASSERT( FALSE );
                                                            return FALSE;
                                                }
                                    }
                        }
                        CBitmap objBitmap;
                        if( ! objBitmap.Attach( LoadImage( hInstResource, MAKEINTRESOURCE( nResourceID ), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE|LR_CREATEDIBSECTION ) ) )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        BITMAP infoBitmap;
                        ::memset( &infoBitmap, 0, sizeof(BITMAP) );
                        if( ! objBitmap.GetBitmap( &infoBitmap ) )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        CSize sizeBitmap( infoBitmap.bmWidth, infoBitmap.bmHeight ); 
                        int nCountOfButtons = sizeBitmap.cx / nButtonWidth;
                        if( ! Create( nButtonWidth, sizeBitmap.cy, nColorFlag|nColorAddionalFlag, nCountOfButtons, 0 ) )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        if( Add( &objBitmap, clrTransparencyMask ) == -1 )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        return TRUE;
            }
}; // class CExtImageList



Bertil Morefält Nov 21, 2009 - 6:39 AM

This code segment will not work in my case


BOOL Load(
                        UINT nResourceID,
                        COLORREF clrTransparencyMask = RGB(255,0,255),
                        int nButtonWidth = 16,
                        HINSTANCE hInstResource = AfxGetInstanceHandle(),

This will always give a correct pointer
                        UINT nColorFlag = ILC_COLOR24,
                        UINT nColorAddionalFlag = ILC_MASK
                        )
            {
                        ASSERT(
                                                nColorFlag == ILC_COLOR4
                                    ||           nColorFlag == ILC_COLOR8
                                    ||           nColorFlag == ILC_COLOR16
                                    ||           nColorFlag == ILC_COLOR24
                                    ||           nColorFlag == ILC_COLOR32
                                    );
                        if( hInstResource == NULL )

this if-statement will newer return true, and leave me with no pointer to my resourse. When you use AfxGetResourceHandle() you will allways get the
correct resource wether it is a resource_only_dll or not.

{
                                    hInstResource = ::AfxGetResourceHandle();
                                    if( hInstResource == NULL )
                                    {
                                                hInstResource = ::AfxGetInstanceHandle();
                                                if( hInstResource == NULL )
                                                {
                                                            ASSERT( FALSE );
                                                            return FALSE;
                                                }
                                    }
                        }
                        CBitmap objBitmap;
                        if( ! objBitmap.Attach( LoadImage( hInstResource, MAKEINTRESOURCE( nResourceID ), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE|LR_CREATEDIBSECTION ) ) )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }

Best Regards,
Bertil Morefält

 

Technical Support Nov 23, 2009 - 7:20 AM

We changed all the default values for all the hInstResource parameters:

class __PROF_UIS_API CExtImageList : public CImageList
{
public:
            CExtImageList()
            {
            }
            CExtImageList(
                        UINT nResourceID,
                        COLORREF clrTransparencyMask = RGB(255,0,255),
                        int nButtonWidth = 16,
                        HINSTANCE hInstResource = NULL,
                        UINT nColorFlag = ILC_COLOR24,
                        UINT nColorAddionalFlag = ILC_MASK
                        )
            {
                        VERIFY( Load( nResourceID, clrTransparencyMask, nButtonWidth, hInstResource, nColorFlag, nColorAddionalFlag ) );
            }
            BOOL Load(
                        UINT nResourceID,
                        COLORREF clrTransparencyMask = RGB(255,0,255),
                        int nButtonWidth = 16,
                        HINSTANCE hInstResource = NULL,
                        UINT nColorFlag = ILC_COLOR24,
                        UINT nColorAddionalFlag = ILC_MASK
                        )
            {
                        ASSERT(
                                                nColorFlag == ILC_COLOR4
                                    ||           nColorFlag == ILC_COLOR8
                                    ||           nColorFlag == ILC_COLOR16
                                    ||           nColorFlag == ILC_COLOR24
                                    ||           nColorFlag == ILC_COLOR32
                                    );
                        if( hInstResource == NULL )
                        {
                                    hInstResource = ::AfxGetResourceHandle();
                                    if( hInstResource == NULL )
                                    {
                                                hInstResource = ::AfxGetInstanceHandle();
                                                if( hInstResource == NULL )
                                                {
                                                            ASSERT( FALSE );
                                                            return FALSE;
                                                }
                                    }
                        }
                        CBitmap objBitmap;
                        if( ! objBitmap.Attach( LoadImage( hInstResource, MAKEINTRESOURCE( nResourceID ), IMAGE_BITMAP, 0, 0, LR_DEFAULTSIZE|LR_CREATEDIBSECTION ) ) )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        BITMAP infoBitmap;
                        ::memset( &infoBitmap, 0, sizeof(BITMAP) );
                        if( ! objBitmap.GetBitmap( &infoBitmap ) )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        CSize sizeBitmap( infoBitmap.bmWidth, infoBitmap.bmHeight ); 
                        int nCountOfButtons = sizeBitmap.cx / nButtonWidth;
                        if( ! Create( nButtonWidth, sizeBitmap.cy, nColorFlag|nColorAddionalFlag, nCountOfButtons, 0 ) )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        if( Add( &objBitmap, clrTransparencyMask ) == -1 )
                        {
                                    ASSERT( FALSE );
                                    return FALSE;
                        }
                        return TRUE;
            }
}; // class CExtImageList



Bertil Morefält Nov 24, 2009 - 4:01 AM

Hi!


It just dosn’t work. So I went back to basics.


I declared two Buttons one wihe CExtRadioButton and the other as CButton in my class declaration.


    CExtRadioButton m_ctlSysOff;

    CButton m_ctlKvittaOff;


and in


 


  void CAnvView::DoDataExchange(CDataExchange* pDX)

{

   DDX_Control(pDX, IDC_ANV_USER_RADIO1,        m_ctlUserOff);

   DDX_Control(pDX, IDC_ANV_SYS_RADIO1,        m_ctlSysOff);


......


}


 


and in my resource_only_dll file I set up two radiobutton-controls.


The control m_ctlSysOff  disapear and  m_ctlKvittaOff is visible and works correctly. Why?


Best Regards,


Bertil Morefält

Technical Support Nov 24, 2009 - 2:09 PM

We guess this question is not related to image lists and bitmap resources. The information in your message is not enough to come to any conclusions about disappeared radio button. The only thing we can suppose is that the disappeared radio button has no WS_VISIBLE style. Could you create two simple possible test projects reproducing this magic and sent them to us to the support mail box at this web site? We mean one is EXE app and second is resource DLL.