Solved Understanding SetCommandDragId

I'm having troubles to understand the SetCommandDragId function for c4d.gui.BitmapButtonCustomGui.
I'm using the following function to add my BitmapButton to my Dialog:

    def AddIconButton(self, buttonid, title, iconid, tooltip):
        bc = c4d.BaseContainer()
        bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)
        bc.SetInt32(c4d.BITMAPBUTTON_ICONID1, iconid)
        bc.SetString(c4d.BITMAPBUTTON_TOOLTIP, tooltip)
        bc.SetInt32(c4d.BITMAPBUTTON_FORCE_SIZE, 32)
        button = self.AddCustomGui(buttonid, c4d.CUSTOMGUI_BITMAPBUTTON, title, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 40, 40, bc)
        #set button.SetCommandDragId() here?!!!
        return button

Even inside the CreateLayout I had no luck with FindCustomGUI() ...
What's the best way to approach this?

Thanks,
Lasse

I must add:

Either they are dragable to the layout or I'm only able to press within the dialog...

Hi yes, the behavior changes a bit once you defined the BitmapCustomGui as a Button that can be dragged.

    def CreateLayout(self):
        bc = c4d.BaseContainer()
        bc.SetBool(c4d.BITMAPBUTTON_BUTTON, True)
        bc.SetInt32(c4d.BITMAPBUTTON_ICONID1, c4d.Ocube)
        bc.SetInt32(c4d.BITMAPBUTTON_FORCE_SIZE, 32)
        button = self.AddCustomGui(10003, c4d.CUSTOMGUI_BITMAPBUTTON, "but", c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 40, 40, bc)
        button.SetCommandDragId(c4d.Ocube)
        return True

    def Message(self, msg, result):
        if msg.GetId() == c4d.BFM_INTERACTEND:
            if self.IsActive(10003):
                print 'Icon clicked in the GeDialog.'

Note that if you click on the icon directly from the Cinema 4D palette it will automatically call the CallCommand with the correct it.

Cheers,
Maxime.

Thanks so much, @m_adam!
Works like a charm!

Cheers,
Lasse

Just to reconcile:

button.SetCommandDragId(THIS_ID) -> THIS_ID needs to be a unique PluginID, correct?

Cheers,
Lasse

Correct, and I would say a CommandData id.