Solved Grayed out or disabled X button

Hi,
I'm a bit lost, maybe someone can help me out.
Here a simple modal example:

import c4d
from c4d import gui

class TestDialog(gui.GeDialog):
    def CreateLayout(self):
        self.AddButton(1014, c4d.BFH_SCALEFIT, 100, 17, 'Close')
        return True
    def Command(self, id, msg):
        if id == 1014:
            #CLOSE BUTTON
            self.Close()
            
        return c4d.gui.GeDialog.Command(self, id, msg) 
    def AskClose(self):
        return False
    
if __name__=='__main__':
    dialog = TestDialog()
    dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC,)
    c4d.EventAdd()

I want a dialog box with a grayed out or disable X button.
I can change it to a different dlgtype, but those are not really what I need.

Can I overwrite the “DLG_TYPE_MODAL” ?

alt text

Hi Myosis, thanks for reaching out us.

With regard to your question, we recommend to follow-up @mp5gosu's recommendations cause there's actually nothing in our API that could override OS window management mechanism. An example on how to use the `c4d.DIALOG_NOMENUBAR' is available on the PluginCafé GitHub repo.

Best,

I don't think that you can modifiy this. Alternatively, catch the close message, if you just don't want the user to be able to close the dialog.
or
You can completely hide the title bar with AddGadget()

@mp5gosu said in Grayed out or disabled X button:

AddGadget()

Thanks for your reply!
I still struggle to hide it, do I use it like this:

import c4d
from c4d import gui

class TestDialog(gui.GeDialog):
    
    def __init__(self):
        self.AddGadget(c4d.DIALOG_NOMENUBAR, 0) 
    
    def CreateLayout(self):
        self.AddButton(1014, c4d.BFH_SCALEFIT, 100, 17, 'Close')
        return True
    def Command(self, id, msg):
        if id == 1014:
            #CLOSE BUTTON
            self.Close()
            
        return c4d.gui.GeDialog.Command(self, id, msg) 
    def AskClose(self):
        return False
    
if __name__=='__main__':
    dialog = TestDialog()
    dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC,)
    c4d.EventAdd()

Ah sorry, forgot to mention, that you have to call the Dialog via DLG_TYPE_ASYNC_POPUPEDIT or DLG_TYPE_ASYNC_POPUP_RESIZEABLE, not DLG_TYPE_ASYNC.

Hi Myosis, thanks for reaching out us.

With regard to your question, we recommend to follow-up @mp5gosu's recommendations cause there's actually nothing in our API that could override OS window management mechanism. An example on how to use the `c4d.DIALOG_NOMENUBAR' is available on the PluginCafé GitHub repo.

Best,

Ah too bad. I need it to be a separate window, so the user can relocate it's position.
I want to preform some actions upon closing (removing certain objects).
But I can't seem to link that to the OS window X button, can I ?

@mp5gosu Thanks for clarifying.
@r_gigante And thanks for the link there is a lot of useful stuff on there.

You can. Override AskClose() and do your stuff. :) Remember to return True to let it stay open - not False as in your current code.
Finally Close the Dialog via return False.

@mp5gosu
This sounds like the solution I was looking for :sweat_smile:
Thanks a lot!

Ps, yes im a noob...