⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texcept.tex

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 TEX
字号:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Name:        texcept.tex%% Purpose:     C++ exceptions and wxWidgets overview%% Author:      Vadim Zeitlin%% Modified by:%% Created:     17.09.03%% RCS-ID:      $Id: texcept.tex,v 1.6 2005/02/22 15:09:54 ABX Exp $%% Copyright:   (c) 2003 Vadim Zeitlin%% License:     wxWindows license%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\section{C++ exceptions overview}\label{exceptionsoverview}\subsection{Introduction}\label{exceptionintroduction}wxWidgets had been started long before the exceptions were introduced in C++ soit is not very surprising that it is not built around using them as some moremodern C++ libraries are. For instance, the library doesn't throw exceptions tosignal about the errors. Moreover, up to (and including) the version 2.4 ofwxWidgets, even using the exceptions in the user code was dangerous because thelibrary code wasn't exception-safe and so an exception propagating through itcould result in memory and/or resource leaks, and also not very convenient.Starting from the version 2.5.1 wxWidgets becomes more exception-friendly. Itstill doesn't use the exceptions by itself but it should be now safe to use theexceptions in the user code and the library tries to help you with this. Pleasenote that making the library exception-safe is still work in progress.\subsection{Strategies for exceptions handling}\label{exceptionstrategies}There are several choice for using the exceptions in wxWidgets programs. Firstof all, you may not use them at all. As stated above, the library doesn't throwany exceptions by itself and so you don't have to worry about exceptions at allunless your own code throws them. This is, of course, the simplest solution butmay be not the best one to deal with all possible errors.Another strategy is to use exceptions only to signal truly fatal errors. Inthis case you probably don't expect to recover from them and the defaultbehaviour -- to simply terminate the program -- may be appropriate. If it isnot, you may override \helpref{OnUnhandledException()}{wxapponunhandledexception} in your wxApp-derived class to perform any clean up tasks. Note, however, thatany information about the exact exception type is lost when this function iscalled, so if you need you should override \helpref{OnRun()}{wxapponrun} andadd a try/catch clause around the call of the base class version. This wouldallow you to catch any exceptions generated during the execution of the mainevent loop. To deal with the exceptions which may arise during the programstartup and/or shutdown you should insert try/catch clauses in \helpref{OnInit()}{wxapponinit} and/or \helpref{OnExit()}{wxapponexit} as well.Finally, you may also want to continue running even when certain exceptionsoccur. If all of your exceptions may happen only in the event handlers of asingle class (or only in the classes derived from it), you may centralize yourexception handling code in \helpref{ProcessEvent}{wxevthandlerprocessevent} method of this class. If this is impractical, you may also consider overridingthe \helpref{wxApp::HandleEvent()}{wxapphandleevent} which allows you to handleall the exceptions thrown by any event handler.\subsection{Technicalities}\label{exceptionstechnicalities}To use any kind of exception support in the library you need to build it with \texttt{wxUSE\_EXCEPTIONS} set to $1$. This should be the case by default butif it isn't, you should edit the \texttt{include/wx/msw/setup.h} file underWindows or run \texttt{configure} with \texttt{--enable-exceptions} argumentunder Unix.On the other hand, if you do \emph{not} plan to use exceptions, setting thisflag to $0$ or using \texttt{--disable-exceptions} could result in a leaner andslightly faster library.As for any other library feature, there is a \helpref{sample}{sampleexcept} showing how to use it. Please look at its sources for further information.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -