How to make a wxFrame behave like a modal wxDialog object

后端 未结 4 1873
萌比男神i
萌比男神i 2021-01-12 04:51

Is is possible to make a wxFrame object behave like a modal dialog box in that the window creating the wxFrame object stops execution until the wxFrame object exits?

4条回答
  •  一向
    一向 (楼主)
    2021-01-12 05:06

    It does not really make sense to "stop execution" of a window, as the window only handles events that are sent to it, like for example mouse, keyboard or paint events, and ignoring them would make the program appear hung. What you should do is disable all controls in your frame, this will gray them out and make the user aware of the fact that they can not be interacted with at this moment.

    You can also disable the parent frame completely, instead of disabling all controls on it. Look into the wxWindowDisabler class, the constructor has a parameter to indicate a window that can be interacted with, and all other windows of the application will be disabled.

    If you later on want to execute a secondary program, then you could use the wxExecute() function to do it.

提交回复
热议问题