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

    Grayed out or disabled X button

    Cinema 4D SDK
    3
    8
    1.4k
    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.
    • M
      myosis
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • M
        mp5gosu
        last edited by mp5gosu

        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()

        1 Reply Last reply Reply Quote 0
        • M
          myosis
          last edited by

          @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()
          
          1 Reply Last reply Reply Quote 0
          • M
            mp5gosu
            last edited by mp5gosu

            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.

            1 Reply Last reply Reply Quote 0
            • r_giganteR
              r_gigante
              last edited by

              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,

              1 Reply Last reply Reply Quote 0
              • M
                myosis
                last edited by myosis

                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.

                1 Reply Last reply Reply Quote 0
                • M
                  mp5gosu
                  last edited by mp5gosu

                  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.

                  1 Reply Last reply Reply Quote 0
                  • M
                    myosis
                    last edited by

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

                    Ps, yes im a noob...

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