Contents Up Previous Next 原文へのリンク

アプリケーションの初期化と終了 Application initialization and termination

ここで述べられる関数は,アプリケーションの開始/終了,および GUIプログラムにおけるメインイベントループの挙動制御に用いられる.
The functions in this section are used on application startup/shutdown and also to control the behaviour of the main event loop of the GUI programs.

::wxEntry
::wxHandleFatalExceptions
::wxInitAllImageHandlers
::wxInitialize
::wxSafeYield
::wxUninitialize
::wxYield
::wxWakeUpIdle


::wxEntry

これは,プラットフォーム依存の方法でwxWidgetsを初期化する. デフォルトのwxWidgetsエントリコード(例えば,mainやWinMain)を用いていな い場合には,これを使う.例えば,この関数を用いてMFCアプリケーションか らwxWidgetsを初期化することができる.
This initializes wxWidgets in a platform-dependent way. Use this if you are not using the default wxWidgets entry code (e.g. main or WinMain). For example, you can initialize wxWidgets from an Microsoft Foundation Classes application using this function.

void wxEntry(HANDLE hInstance, HANDLE hPrevInstance, const wxString& commandLine, int cmdShow, bool enterLoop = TRUE)

Windows上でのwxWidgetsの初期化(DLLでは無い場合).enterLoopが偽ならば, この関数はwxApp::OnInitを呼び出して即座に返る.そうでなければ, wxWidgetsメッセージループに入る.
wxWidgets initialization under Windows (non-DLL). If enterLoop is FALSE, the function will return immediately after calling wxApp::OnInit. Otherwise, the wxWidgets message loop will be entered.

void wxEntry(HANDLE hInstance, HANDLE hPrevInstance, WORD wDataSegment, WORD wHeapSize, const wxString& commandLine)

Windows上でのwxWidgetsの初期化(DLLの場合).
wxWidgets initialization under Windows (for applications constructed as a DLL).

int wxEntry(int argc, const wxString& *argv)

Unix上でのwxWidgetsの初期化.
wxWidgets initialization under Unix.

Remarks

wxWidgetsの後始末をするために,wxApp::OnExitに続けて静的関数 wxApp::CleanUpを呼ぶ.例えば,wxWidgetsを使用しているMFCアプリケーショ ンから終了させる場合:
To clean up wxWidgets, call wxApp::OnExit followed by the static function wxApp::CleanUp. For example, if exiting from an MFC application that also uses wxWidgets:

int CTheApp::ExitInstance()
{
  // CleanUpがOnExitを呼ばないので,明示的に呼ばなければならない
  // OnExit isn't called by CleanUp so must be called explicitly.
  wxTheApp->OnExit();
  wxApp::CleanUp();

  return CWinApp::ExitInstance();
}
Include files

<wx/app.h>


::wxHandleFatalExceptions

bool wxHandleFatalExceptions(bool doIt = TRUE)

doItが真の場合,致命的な例外(Windowsの一般保護違反)が発生し,wxApp::OnFatalExceptionに渡 される. デフォルトでは,つまり,この関数が呼ばれなければ,アプリケーションを終 了させるという通常の方法がとられる. doItをFALSEにしてwxHandleFatalExceptions()を呼び出すと,このデ フォルトの動作が行われる.
If doIt is TRUE, the fatal exceptions (also known as general protection faults under Windows or segmentation violations in the Unix world) will be caught and passed to wxApp::OnFatalException. By default, i.e. before this function is called, they will be handled in the normal way which usually just means that the application will be terminated. Calling wxHandleFatalExceptions() with doIt equal to FALSE will restore this default behaviour.


::wxInitAllImageHandlers

void wxInitAllImageHandlers()

利用可能なイメージハンドラを全て初期化する. 利用可能なハンドラのリストについては,wxImageを参照のこと.
Initializes all available image handlers. For a list of available handlers, see wxImage.

See also

wxImage, wxImageHandler

Include files

<wx/image.h>


::wxInitialize

bool wxInitialize()

この関数は,wxAppオブジェクトを 全く作成しない場合に限り,wxBaseにおいてのみ用いられる. この場合,他のwxWidgets関数を呼ぶより前に,main()関数から呼び 出さなければならない.

関数がFALSEを返した場合,初期化は行われていない.この場合,ラ イブラリを使用することはできずwxUninitializeも呼ばれるべきではな い.

この関数が何度か呼ばれる場合でも,成功したひとつひとつ呼び出しに対して, wxUninitializeが呼ばれなければ ならない.

This function is used in wxBase only and only if you don't create wxApp object at all. In this case you must call it from your main() function before calling any other wxWidgets functions.

If the function returns FALSE the initialization could not be performed, in this case the library cannot be used and wxUninitialize shouldn't be called neither.

This function may be called several times but wxUninitialize must be called for each successful call to this function.

Include files

<wx/app.h>


::wxSafeYield

bool wxSafeYield(wxWindow* win = NULL, bool onlyIfNeeded = FALSE)

この関数は,wxYieldと似ている.ただし,wxYield呼び出し以前の全プログラ ムウィンドウに対するユーザの入力を無効にして,呼び出し後に再び有効にす る,と言う点が異なる.もし,winがNULLならば,このウィンドウは有 効なままであり,限定的なユーザインタラクションを実装できる.

戻り値は,::wxYieldを呼び出した結果で ある.

This function is similar to wxYield, except that it disables the user input to all program windows before calling wxYield and re-enables it again afterwards. If win is not NULL, this window will remain enabled, allowing the implementation of some limited user interaction.

Returns the result of the call to ::wxYield.

Include files

<wx/utils.h>


::wxUninitialize

void wxUninitialize()

この関数は,コンソール(wxBase)プログラムでのみ用いられる. 成功したwxInitialize呼び出しそれ ぞれに対して,一回呼び出す必要がある.
This function is for use in console (wxBase) programs only. It must be called once for each previous successful call to wxInitialize.

Include files

<wx/app.h>


::wxYield

bool wxYield()

wxApp::Yieldを呼ぶ.

この関数は,古いバージョンに対する互換性の為だけに存在する.新しいコー ドでは,これの代わりにwxApp::Yieldメ ソッドを用いることが望ましい.

Calls wxApp::Yield.

This function is kept only for backwards compatibility. Please use the wxApp::Yield method instead in any new code.

Include files

<wx/app.h> or <wx/utils.h>


::wxWakeUpIdle

void wxWakeUpIdle()

この関数は,(プラットフォーム依存の内部)アイドル状態のシステムを呼 び覚ます. つまり,システムが現在アイドル状態で,他のイベントが来るまでア イドルイベントを送らないとしても,強制的にシステムにアイドルイベント を送らせる.これは,二つのスレッド間でのイベント送信でも役立ち, それに対応する::wxPostEvent関数およびwxEvtHandler::AddPendingEvent関数で使用される.
This functions wakes up the (internal and platform dependent) idle system, i.e. it will force the system to send an idle event even if the system currently is idle and thus would not send any idle event until after some other event would get sent. This is also useful for sending events between two threads and is used by the corresponding functions ::wxPostEvent and wxEvtHandler::AddPendingEvent.

Include files

<wx/app.h>