Code::Blocks Forums

User forums => General (but related to Code::Blocks) => Topic started by: spflanze on September 16, 2017, 01:42:28 am

Title: Closing Windows using Close() and Destroy()
Post by: spflanze on September 16, 2017, 01:42:28 am
I did wxWidgets Tutorial 8 at:
http://wiki.codeblocks.org/index.php/WxSmith_tutorial:_Drawing_on_the_Screen_and_Saving_Drawings

In tutorial 1-6 in this series I found that the Close() function did not work to close the program. What did work is the Destroy() function which caused the program's window to close smoothly. But when I use it in Tutorial 8  I find it does not work so smoothly when closing the stretchable window. What I get is the error:

Quote
Tutorial_8_Screen_Drawing.exe has stopped working
A problem caused the program to stop working correctly.
Windows will close the program and notify you if a solution is available

Interestingly this tutorial does not recommend the Close() function for this stretchable window it opens in response to a button click in the program's top level window. It recommends instead to use Destroy(), which is what I used. Apparently Destroy() is the wrong function. Which is the right one?

The other windows in this tutorial, the main one, and the one opened by the Show button,  do close smoothly and without error as expected using the Destroy() function.

Title: Re: Closing Windows using Close() and Destroy()
Post by: BlueHazzard on September 16, 2017, 03:39:29 pm
You probably hit a memory access bug. You can solve this by running trough the debugger...
Without backtrace it is impossible to tell what is going wrong...
Title: Re: Closing Windows using Close() and Destroy()
Post by: spflanze on September 16, 2017, 08:21:16 pm
I attached the project to the reply I did on Sept 16 on this other thread of mine:
http://forums.codeblocks.org/index.php/topic,22142.new.html#new (http://forums.codeblocks.org/index.php/topic,22142.new.html#new)
Title: Re: Closing Windows using Close() and Destroy()
Post by: BlueHazzard on September 17, 2017, 01:39:05 am
For the crashing see my answer there. For the question about Destroy and Close, read the wxWidgets documentation .
http://docs.wxwidgets.org/3.0/classwx_window.html#a3e44f4a494fc9ef4346c4fba70c8de0c
http://docs.wxwidgets.org/3.0/classwx_window.html#a6bf0c5be864544d9ce0560087667b7fc


 This question is outside the scope of this forum.