Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Bitmap in GUI

    SDK Help
    0
    7
    540
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

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

      On 18/02/2008 at 20:08, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   10.111 
      Platform:      Mac OSX  ; 
      Language(s) :

      ---------
      Hi,

      I'm using ResEdit to lay out my GUI. I'm having a bit of trouble getting my code right for setting a bitmap image in the GUI.

      From what I understand, I have two options: a BitmapButton and a UserArea. I've tried both, but without much success. I was able to get an image in the GUI with a bitmapbutton, as long as I set it up in CreateLayout, but I'm not sure how to go about setting that up with my predefined BitmapButton from ResEdit.

      I tried UserArea, as well, but by bitmap is not showing up. Here is the code I am trying for that:

      //trying to set up bitmap preview
      AutoAlloc<BaseBitmap> bmp;
      bmp->Init(GeGetPluginPath()+Filename("res")+Filename("icon.tif"));
      ua.DrawBitmap(bmp, 0, 0, 16, 16, 0, 0, 16, 16, BMP_NORMAL); //ua is a GeUserArea - public member of my GeDialog class
      Bool UIAttached = AttachUserArea(ua, IDC_BITMAP_PREVIEW);
      GePrint("UI Attached = " + BoolToString(UIAttached));

      I get confirmation that the UserArea has been attached, but no bitmap shows up.

      Any help here? I'd settle either for getting the bitmap button to work with the res file or getting the UserArea to work. I'm not too picky there 😉

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

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

        On 18/02/2008 at 21:53, xxxxxxxx wrote:

        BitmapButton is the way to go programmatically. As far as I know, a predefined one never works.

        I'd talk to Spanki (Riptide plugin developer) about using predefined UserArea with bitmaps (he seems to be doing this with Riptide). The URL to his site is:

        Spanki s Site

        1 Reply Last reply Reply Quote 0
        • H
          Helper
          last edited by

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

          On 18/02/2008 at 23:20, xxxxxxxx wrote:

          Thanks. I'll send him a quick e-mail and see what he says. If I am not able to find a solution that works with my .res file, that means I'd have to ditch the .res file and code everything in the CreateLayout function, correct? There's no way that I can see to insert stuff in the middle of the layout, only before or after...

          Just asking. A lot of work has already gone into the layout. I'd hate to have to recode it if I don't have to.

          1 Reply Last reply Reply Quote 0
          • H
            Helper
            last edited by

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

            On 26/02/2008 at 08:48, xxxxxxxx wrote:

            I'm not sure if this is the correct/proper way to do it, but this is how I got it to work...
            I have a new class, based on a GeUserArea class... My header file (logo.h) :

                
                
                
                
                #include "c4d.h"
                
                
                
                
                class LogoBmp : public GeUserArea  
                {  
                 private:  
                #ifdef _V7SDK_  
                  BaseBitmap *m_pBmp;  
                #else  
                  AutoAlloc<BaseBitmap> m_pBmp;  
                #endif  
                 public:  
                  Bool Logoname(char *szName);  
                  virtual void Draw(LONG x1, LONG y1, LONG x2, LONG y2);  
                };  
                
            

            ...the cpp file...

                
                
                
                
                #include "logo.h"
                
                
                
                
                Bool LogoBmp::Logoname(char *szName)  
                {  
                #ifdef _V7SDK_  
                 m_pBmp = AllocBaseBitmap();  
                #endif  
                 if( !m_pBmp || m_pBmp->Init(GeGetPluginPath()+String("res")+String(szName))!=IMAGE_OK )  
                  return false;
                
                
                
                
                 return true;  
                }
                
                
                
                
                void LogoBmp::Draw(LONG x1, LONG y1, LONG x2, LONG y2)  
                {  
                 LONG wid, hgt;
                
                
                
                
                 wid = x2-x1;  
                 hgt = y2-y1;
                
                
                
                
                 if( m_pBmp )  
                  DrawBitmap(m_pBmp, x1, y1, wid, hgt, 0, 0, m_pBmp->GetBw(), m_pBmp->GetBh(), BMP_NORMALSCALED | BMP_ALLOWALPHA);  
                }  
                
            

            ...then, in my case, I have 2 USERAREA s **** defined in my dialog's .res file...

                
                
                
                
                // C4D-DialogResource  
                DIALOG DLG_IMPFILE  
                {  
                 NAME CAPTION_TEXT; CENTER_V; CENTER_H;   
                   
                 GROUP   
                 {  
                  ALIGN_TOP; CENTER_H;   
                  BORDERSIZE 10, 0, 10, 0;   
                  COLUMNS 1;  
                  SPACE 4, 4;  
                    
                  GROUP   
                  {  
                   CENTER_V; CENTER_H;   
                   BORDERSIZE 10, 10, 10, 10;   
                   COLUMNS 3;  
                   SPACE 4, 4;  
                     
                    **USERAREA IDC_LOGO { CENTER_V; CENTER_H; SIZE 128, 64; }**  
                    GROUP   
                   {  
                    CENTER_V; CENTER_H;   
                    BORDERSIZE 10, 0, 10, 0;   
                    COLUMNS 1;  
                    SPACE 4, 4;  
                      
                    STATICTEXT  { NAME IDS_HTX1; CENTER_V; CENTER_H; }  
                    STATICTEXT  { NAME IDS_HTX2; CENTER_V; CENTER_H; }  
                    STATICTEXT  { NAME IDS_HTX3; CENTER_V; CENTER_H; }  
                    STATICTEXT  { NAME IDS_HTX4; CENTER_V; CENTER_H; }  
                    STATICTEXT  { NAME IDS_HTX5; CENTER_V; CENTER_H; }  
                   }  
                    **USERAREA IDC_RTLOGO { CENTER_V; CENTER_H; SIZE 128, 64; }**  
                   }  
                  GROUP   
                  {  
                   NAME IDS_DTITLE; FIT_V; SCALE_V; CENTER_H;   
                   BORDERSTYLE BORDER_GROUP_IN; BORDERSIZE 10, 10, 10, 10;   
                   COLUMNS 1;  
                   SPACE 10, 10;  
                --------------------- S N I P ------------------------
                
                
                
            

            ...and finally, my dialog setup code...

                
                
                
                
                class LoadOptsDialog : public GeModalDialog  
                {  
                 private:  
                   **LogoBmp  m_riplogo;  
                  LogoBmp m_tidelogo;  
                **  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);  
                };
                
                
                
                
                LoadOptsDialog::LoadOptsDialog(ObjLoader *pbj)  
                {   
                  **m_riplogo.Logoname("redilogo.tif");  
                  m_tidelogo.Logoname("riptide.tif");**  
                 ppbj = pbj;   
                }
                
                
                
                
                Bool LoadOptsDialog::AskClose(void)  
                {  
                 return FALSE;  
                }
                
                
                
                
                Bool LoadOptsDialog::CreateLayout(void)  
                {  
                 if( !(GeModalDialog::CreateLayout() && LoadDialogResource(DLG_IMPFILE,NULL,0)))  
                  return FALSE;
                
                
                
                
                  **AttachUserArea(m_riplogo, IDC_LOGO);  
                  AttachUserArea(m_tidelogo, IDC_RTLOGO);  
                ** return TRUE;  
                }
                
                
                
                
                ---------------------- S N I P ----------------------
                
                
                
            

            ...frankly, I no longer remember the particulars about how or why this works, but that's the way it's been in my code for years now :).

            1 Reply Last reply Reply Quote 0
            • H
              Helper
              last edited by

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

              On 26/02/2008 at 08:53, xxxxxxxx wrote:

              ..oh, so yes - my bitmaps do not show up inside resedit - it shows placeholder bitmaps instead (it doesn't know the filenames, etc. that are in my code).

              1 Reply Last reply Reply Quote 0
              • H
                Helper
                last edited by

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

                On 26/02/2008 at 11:13, xxxxxxxx wrote:

                ...I also just found my earlier post of this info (back in '04 🙂 )...
                https://developers.maxon.net/forum/topic/1965
                ...a tad simpler code, since it only had one image at the time.

                1 Reply Last reply Reply Quote 0
                • H
                  Helper
                  last edited by

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

                  On 26/02/2008 at 21:01, xxxxxxxx wrote:

                  Thanks!

                  I ended up ditching the .res file and using a bitmap button. I was able to get the user area to work with the res file, but in the end, the code was more complicated than it needed to be with the user area.

                  About how/why the user area works, I figured out that, just like you have it, you have to set it up as its own class, and most importantly, you need to define the draw function in there that calls DrawBitmap().

                  The draw function gets called every time the user area needs to redraw, and it looks like that's the only place you can call DrawBitmap().

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post