AttachImage in v8.5 - how?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/07/2004 at 10:03, xxxxxxxx wrote:

    User Information:
    Cinema 4D Version:   8.5 
    Platform:   Windows  ;   
    Language(s) :     C++  ;

    ---------
    I think the final piece of the puzzle for porting my plugin from v7.3 to v8.5 has to do with diaplaying a bitmap in a userarea of a dialog.  Under 7.3, I did the following...

        
        
        
        
        Bool SaveOptsDialog::CreateLayout(void)  
        {  
         BaseBitmap *logo = NULL;
        
        
        
        
         if( !(GeModalDialog::CreateLayout() && LoadDialogResource(DLG_PBJOPTIONS,NULL,0)))  
          return FALSE;  
          
         logo = BaseBitmap::Alloc();  
         if (!logo || logo->Init(GeGetPluginPath()+String("res")+String("redilogo.tif"))!=IMAGE_OK)  
         {  
          return FALSE;  
         }  
         AttachImage(IDC_LOGO, logo, BMPBUTTON_COPYBITMAP);  
         BaseBitmap::Free(logo);  
          
         return TRUE;  
        }  
        
    

    ...but AttachImage() is no longer available.  I don't need this to be a button or anything, it's just a logo that needs to be displayed.  Can someone tell me the easist way to do this under v8.5 SDK?
    Thanks,
    - Keith



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/07/2004 at 21:46, xxxxxxxx wrote:

    ...Continueing in the tradition of eventually answering my own questions ;)... after some searching in the forums here and more pouring over the SDK docs (which are light on info on this subject) I've come up with something that works and may be useful to others.
    Goal :
    Display a static bitmap/icon image in a modal dialog that has an existing (loaded from resource) User Area control
    Implemenation :
    First, create a simple GeUserArea-derived class...
    ----------------------------- S N I P ---------------------------

        
        
          
        #include "c4d.h"
        
        
        
        
        class LogoBmp : public GeUserArea  
        {  
         private:  
          AutoAlloc<BaseBitmap> m_pBmp;
        
        
        
        
         public:  
          // we only need to overload a few functions...  
          virtual Bool Init(void);  
          virtual void Draw(LONG x1, LONG y1, LONG x2, LONG y2);  
        };  
        
        
        
        
        
        Bool LogoBmp::Init(void)  
        {  
        // initialize the bitmap by loading your bitmap/icon image  
         if( !m_pBmp || m_pBmp->Init(GeGetPluginPath()+String("res")+String("redilogo.tif"))!=IMAGE_OK )  
          return false;
        
        
        
        
         return true;  
        }
        
        
        
        
        void LogoBmp::Draw(LONG x1, LONG y1, LONG x2, LONG y2)  
        {  
         // if we have a valid bitmap, render it into the specified region  
         if( m_pBmp )  
          DrawBitmap(m_pBmp, x1, y1, x2-x1, y2-y1, 0, 0, m_pBmp->GetBw(), m_pBmp->GetBh(), BMP_NORMALSCALED | BMP_ALLOWALPHA);  
        }  
        
    

    ----------------------------- S N I P ---------------------------
    ...next, insert one of these classes as a member of your (derived) GeDialog or GeModalDialog class and then simply AttachUserArea() inside your CreateLayout() code...
    ----------------------------- S N I P ---------------------------

        
        
          
        class LoadOptsDialog : public GeModalDialog  
        {  
         private:  
          LogoBmp m_bmplogo;  // <---- here's our new bitmap/logo class  
          ObjLoader *ppbj;
        
        
        
        
         public:  
          LoadOptsDialog(ObjLoader *pbj);
        
        
        
        
          virtual Bool CreateLayout(void);  
          virtual Bool InitValues(void);  
          virtual Bool Command(LONG id, const BaseContainer &msg);  
          virtual Bool AskClose(void);  
        };  
        
        
        
        
        
        Bool LoadOptsDialog::CreateLayout(void)  
        {  
         if( !(GeModalDialog::CreateLayout() && LoadDialogResource(DLG_IMPFILE,NULL,0)))  
          return FALSE;
        
        
        
        
         AttachUserArea(m_bmplogo, IDC_LOGO);  // <---- attach it and we're done!  
         return TRUE;  
        }  
        
    

    ----------------------------- S N I P ---------------------------
    ...I tried to keep this example as simple as possible, so I hope it makes sense!
    Cheers,
    - Keith



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 01/05/2009 at 23:56, xxxxxxxx wrote:

    I'm pushing this thread up, because I want to do something similar...

    I want to show several bitmaps in the descriptions of my plugin object. So there's no GeDialog, just the Attribute Manager. Also, it would be about 8 or 10 images, explaining some attributes with simple icon-like graphics.

    Do I have to write a separate GeUserArea-derived class for each of those bitmaps? That would be pretty much work, just for some icons to appear. Or is there an easier method? Working with the 10.1 SDK here.

    Thanks in advance ;-)

    Cheers,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/05/2009 at 00:34, xxxxxxxx wrote:

    I dunno the answer, but here is my updated header file...
    logo.h
    ----------------------------- S N I P ---------------------------

        
        
          
        //------------------------------------------------------------------------------------------------------  
        // LogoBmp Class  
        //   
        // Class derived from GeUserArea to render bitmaps in dialogs.  
        //------------------------------------------------------------------------------------------------------
        
        
        
        
        #include "c4d.h"
        
        
        
        
        class LogoBmp : public GeUserArea  
        {  
        private:  
            BaseBitmap *m_pBmp;  
            LONG m_areaW;  
            LONG m_areaH;  
            LONG m_bmW;  
            LONG m_bmH;
        
        
        
        
        public:  
            // Constructor  
            LogoBmp(void)  
            {  
                m_areaW = 0;  
                m_areaH = 0;  
                m_bmW = 64;  
                m_bmH = 64;  
                m_pBmp = BaseBitmap::Alloc();  
            }
        
        
        
        
            // Destructor  
            ~LogoBmp(void) { if( m_pBmp ) BaseBitmap::Free(m_pBmp); }
        
        
        
        
            // Initialize bitmap with filename (looks in plugin's res folder, as implemented)  
            Bool LogoBmp::Logoname(String szName)  
            {  
                if( !m_pBmp || m_pBmp->Init(GeGetPluginPath()+String("res")+szName)!=IMAGE_OK )  
                    return false;
        
        
        
        
                m_bmW = m_pBmp->GetBw();  
                m_bmH = m_pBmp->GetBh();  
                return true;  
            }
        
        
        
        
            // Overloaded GetMinSize()  
            virtual Bool LogoBmp::GetMinSize(LONG& w, LONG& h)  
            {  
                w = m_bmW;  
                h = m_bmH;  
                return true;  
            }
        
        
        
        
            // Overloaded Sized()  
            virtual void LogoBmp::Sized(LONG w, LONG h)  
            {  
                m_areaW = w;  
                m_areaH = h;  
            }
        
        
        
        
            // Overloaded draw routine  
        #ifdef _R10p1_SDK_ // R10 or later...  
            virtual void LogoBmp::DrawMsg(LONG x1, LONG y1, LONG x2, LONG y2,const BaseContainer &msg)  
        #else // ...earlier versions called Draw() instead  
            virtual void LogoBmp::Draw(LONG x1, LONG y1, LONG x2, LONG y2  
        #endif  
            {  
                OffScreenOn();  
                if( m_pBmp )  
                {  
                    LONG bx, by;
        
        
        
        
                    bx = (m_areaW - m_bmW) / 2;  
                    by = (m_areaH - m_bmH) / 2;
        
        
        
        
                    DrawSetPen(COLOR_BG);  
                    DrawRectangle(x1, y1, x2, y2);
        
        
        
        
                    DrawBitmap(m_pBmp, bx, by, m_bmW, m_bmH, 0, 0, m_bmW, m_bmH, BMP_NORMALSCALED | BMP_ALLOWALPHA);  
                }  
            }  
        };  
        
    

    ----------------------------- S N I P ---------------------------
    ...the "Logoname()" routine is probably poorly named... should maybe be called LoadBitmap() or SetBitmap() or something.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/05/2009 at 00:44, xxxxxxxx wrote:

    Better than nothing :D I guess I will use this class and derive the actual icon bitmaps from it.

    Thanks, Giblet, you're always very generous with your code!

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/05/2009 at 05:14, xxxxxxxx wrote:

    Have considered using a BitmapButton? There is a thread discussing BitmapButtons:

    Bitmap Button Madness

    cheers,
    Matthias



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 02/05/2009 at 13:13, xxxxxxxx wrote:

    Thanks, Matthias. Can I make a bitmap button that cannot be clicked? I just want to display icons, the user shouldn't click on it.

    Greetings,
    Jack



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/05/2009 at 07:18, xxxxxxxx wrote:

    Yes. This example is for a GeDialog not Description:

    BaseContainer bc;
    bc.SetLong(DESC_CUSTOMGUI,          CUSTOMGUI_BITMAPBUTTON);
    bc.SetLong(BITMAPBUTTON_BORDER,     BORDER_IN);
    bc.SetBool(BITMAPBUTTON_BUTTON,     FALSE);
    // BitMap Button
    BitmapButtonCustomGui*     bmbutton =     static_cast<BitmapButtonCustomGui*>(AddCustomGui(4000L,CUSTOMGUI_BITMAPBUTTON,String(),BFH_CENTER|BFV_CENTER,SizePix(256L),SizePix(200L),bc));
    if (bmbutton)
    {
         Filename bg = GeGetPluginPath()+Filename("res")+Filename("about.tif");
         if (GeFExist(bg)) bmbutton->SetImage(bg, FALSE);
    }


Log in to reply