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
    • Register
    • Login

    BitmapButton in Resource file

    Cinema 4D SDK
    2024 c++
    2
    8
    1.2k
    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.
    • J
      JohnThomas
      last edited by

      Hello.

      I'm currently trying to create a FieldLayer plugin that is using a resource file for the creation of its description. Everything is working properly with the exception of a BitmapButton that does not seem to be sending any kind of message that it has been pressed.

      Here is the line from the resource file that I am creating the BitmapButton.

      BITMAPBUTTON ID_EXECUTERUN {BUTTON;}
      

      Inside of Message I Have the MSG_DESCRIPTION_GETBITMAP to set the image for the bitmap.

      if (type == MSG_DESCRIPTION_GETBITMAP)
      	{
      		DescriptionGetBitmap* dgb = static_cast<DescriptionGetBitmap*>(t_data);
      		Int32 ID = dgb->_descId[0].id;
      		AutoAlloc<BaseBitmap> bm;
      		Filename bg;
      
      		
      		if (ID == ID_EXECUTERUN )
      		{
      			bg = GeGetPluginPath() + Filename("res") + Filename("Icons") + Filename("Execute.png");
      
      			bm->Init(bg);
      			AutoAlloc<BaseBitmap> bm2;
      			bm2->Init(bm->GetBw() / 2, bm->GetBh() / 2);
      
      			bm->ScaleIt(bm2, 256, TRUE, TRUE);
      			dgb->_bmp = bm2.Release();
      		}
      		
      	}
      

      There was a forum post that was dealing with the same issue, but the solution offered in the post does not seem to be working. I put prints in both the SetDParameter function as well as the MSG_DESCRIPTION_COMMAND message and neither one is ever being printed, all of the other controls I have are working properly.

      Is there something fundamental that I'm missing that is preventing it from catching that the button is being pressed?

      Any help would be greatly appreciated.

      John Thomas

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @JohnThomas
        last edited by

        Hi John Thomas,

        There's nothing fundamental you're missing here. The solution from this old thread should work just fine. Please have a look at the NodeData::SetDParameter() Manual namely the DESCFLAGS_SET::USERINTERACTION flag you need to check against.

        The code snippet you've attached shows the unrelated part of your code. The important function where the problem is likely to happen is the SetDParameter() function.

        By the way, you can register icons using the RegisterIcon() function and use it directly in your code instead of populating the file path by multiple string concatenations. Just make sure you've registered the image before the plugin registration happens.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • J
          JohnThomas
          last edited by

          Thanks for the response.

          My SetDParamter function is defined with this code.

          Bool ExampleFieldLayer::SetDParameter(GeListNode* node, const DescID& id, const GeData& t_data, DESCFLAGS_SET& flags)
          {
          	switch (id[0].id)
          	{
          		case 1006: // ID_EXECUTERUN 
          		{
          			if (flags & DESCFLAGS_SET::USERINTERACTION)
          			{
          				ApplicationOutput("Running SetDParameter");
          			}
          			break;
          		}
          	}
          	
          	return SUPER::SetDParameter(node, id, t_data, flags);
          }
          

          And at no point am I getting a print from the BitmapButton being pressed.

          John Thomas

          1 Reply Last reply Reply Quote 0
          • J
            JohnThomas
            last edited by

            Any ideas, my GetDParameter is defined with this code.

            Bool ExampleFieldLayer::GetDParameter(const GeListNode* node, const DescID& id, GeData& t_data, DESCFLAGS_GET& flags) const 
            {
            	Int32 ID = id[0].id;
            	if (ID == 1006)
            	{
            		Int32 dirty = 0;
            		maxon::WeakRawPtr<const GeListNode> weakPtr(node);
            		if (weakPtr.Get())
            		{
            			GeListNode* convert = MAXON_REMOVE_CONST(weakPtr.Get());
            			BaseList2D* convertObject = static_cast<BaseList2D*>(convert);
            			BitmapButtonStruct bbs(convertObject, id, dirty);
            			t_data = GeData(bbs, CUSTOMDATATYPE_BITMAPBUTTON);
            			flags |= DESCFLAGS_GET::PARAM_GET;
            		}
            	}
            	return SUPER::GetDParameter(node, id, t_data, flags);
            }
            
            1 Reply Last reply Reply Quote 0
            • i_mazlovI
              i_mazlov
              last edited by

              Hi John,

              Your thread has slipped from my table, I'm sorry for that. This thread is next in my list.

              Cheers,
              Ilia

              MAXON SDK Specialist
              developers.maxon.net

              i_mazlovI 1 Reply Last reply Reply Quote 0
              • i_mazlovI
                i_mazlov @i_mazlov
                last edited by

                Hi John,

                Please again excuse the delayed answer!

                I've checked the Bitmap button specifically and it looks like if one creates it dynamically, they are normally using SetCallback() function for registering the "clicked" callback. However, if you're loading your bitmap from the resource file, you can react on the "clicked" event by checking for the MSG_DESCRIPTION_COMMAND message in the Message() function. Could you please try using the code snippet below out, if it works for you?

                Cheers,
                Ilia

                Bool YourFieldLayerDataClass::Message(GeListNode *node, Int32 type, void *t_data)
                {
                	iferr_scope_handler { return false; };
                 
                	if (type == MSG_DESCRIPTION_GETBITMAP)
                	{
                		DescriptionGetBitmap *dgp = (DescriptionGetBitmap*)t_data;
                		if (!dgp) return false;
                 
                		if (dgp->_descId[0].id == /* YOUR_BITMAPBUTTON_ID */)
                		{
                			if (!dgp->_bmp)
                			{
                				// ...
                				// Your icon loading routine
                				// ...
                				if (!dgp->_bmp) return false;
                			}
                		}
                	}
                	else if (type == MSG_DESCRIPTION_COMMAND)
                	{
                		DescriptionCommand *dc = (DescriptionCommand*)t_data;
                		if (!dc) return false;
                 
                		if (dc->_descId[0].id == /* YOUR_BITMAPBUTTON_ID */)
                		{
                			// Bitmap button has been clicked
                		}
                	}
                 
                	return SUPER::Message(node, type, t_data);
                }
                

                MAXON SDK Specialist
                developers.maxon.net

                J 1 Reply Last reply Reply Quote 0
                • J
                  JohnThomas @i_mazlov
                  last edited by

                  @i_mazlov Thanks for the response.

                  I tried utilizing the code and I am not getting any response when I try running it.

                  John Thomas

                  i_mazlovI 1 Reply Last reply Reply Quote 0
                  • i_mazlovI
                    i_mazlov @JohnThomas
                    last edited by

                    Hi @JohnThomas,

                    sorry again for a long delay in the answer.

                    Now I see that in this specific setup when the bitmap button is used inside the field layer plugin, the message MSG_DESCRIPTION_COMMAND is not propagated to the field layer plugin, which sounds like a bug to me. I've checked the code and it's likely due to the field layer data object being somewhat special comparing to others. I will double check this with a corresponding developer, once he's back from parental leave, and create a bug report for this to be fixed.

                    Unfortunately, I cannot offer you any workaround for this before it's fixed.

                    Cheers,
                    Ilia

                    MAXON SDK Specialist
                    developers.maxon.net

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