## Tcl8.6.17/Tk8.6.17 Documentation > Tk C API > Tk_Main

### Tcl/Tk Applications | Tcl Commands | Tk Commands | [incr Tcl] Package Commands | SQLite3 Package Commands | TDBC Package Commands | tdbc::mysql Package Commands | tdbc::odbc Package Commands | tdbc::postgres Package Commands | tdbc::sqlite3 Package Commands | Thread Package Commands | Tcl C API | Tk C API | [incr Tcl] Package C API | TDBC Package C API

  NAME
    Tk_Main — Tk-基準の応用譜のための主算譜　 main program for Tk-based applications
  SYNOPSIS
    #include <tk.h>
    Tk_Main(argc, argv, appInitProc)
  引数 ARGUMENTS
    int argc (入力in)
    char *argv[] (入力in)
    Tcl_AppInitProc *appInitProc (入力in)
  説明 DESCRIPTION
  SEE ALSO
  KEYWORDS

### NAME

Tk_Main — Tk-基準の応用譜のための主算譜　 main program for Tk-based applications

### SYNOPSIS

#include <tk.h>
Tk_Main(argc, argv, appInitProc)

### 引数 ARGUMENTS

int argc (入力in)
  argv 内の要素の数｡ Number of elements in argv.

char *argv[] (入力in)
  命令行引数を含む文字列の配列｡Windows で-DUNICODE,を使う時は､假引数の型は wchar_t * に変化する｡ Array of strings containing command-line arguments. On Windows, when using -DUNICODE, the parameter type changes to wchar_t *.

Tcl_AppInitProc *appInitProc (入力in)
  応用譜固有の初期化手続函数の番地｡この引数の値は通常Tcl_AppInit である｡ Address of an application-specific initialization procedure. The value for this argument is usually Tcl_AppInit.

### 説明 DESCRIPTION

Tk_Main は､多くのTk-基準の応用譜の為の主算譜として働く｡ Tk 4.0 版の開始と共に､最早 main は呼ばれなくなった､理由は､それが Tk 外部函数の一部であり､外部函数内に main 函数(特に共有外部函数)を有する事は多くの系で厄介を生じるから｡ Tk 外部函数内に main を有する事は C++ 算譜内での Tk の使用を困難にする､理由は C++ 算譜では特別の C++ main 函数を有さねばならないから｡ Tk_Main acts as the main program for most Tk-based applications. Starting with Tk 4.0 it is not called main anymore because it is part of the Tk library and having a function main in a library (particularly a shared library) causes problems on many systems. Having main in the Tk library would also make it hard to use Tk in C++ programs, since C++ programs must have special C++ main functions.

通常それぞれの応用譜は小さな main 函数を含み､それはTk_Main の起動以外は何も行わない｡Tk_Main.は wish-様応用譜の作成と実行の全ての活動を行う｡ Normally each application contains a small main function that does nothing but invoke Tk_Main. Tk_Main then does all the work of creating and running a wish-like application.

自身の初期化が完了し､命令は未だ処理しする前の時､Tk_Main は appInitProc 引数に与えられた手続函数を呼ぶ｡この手続函数は､自己の初期化のための応用譜に関する “接続” ､譬えば応用譜固有の命令を定義すること､を提供する｡この手続函数は Tcl_AppInitProc 型に合致する相互接続機能を有さねばならない: When it is has finished its own initialization, but before it processes commands, Tk_Main calls the procedure given by the appInitProc argument. This procedure provides a “hook” for the application to perform its own initialization, such as defining application-specific commands. The procedure must have an interface that matches the type Tcl_AppInitProc:

    typedef int Tcl_AppInitProc(
            Tcl_Interp *interp);

AppInitProc は殆ど常に Tcl_AppInit へのポインターである; この手続函数に拘わる更なる詳細は説明書の Tcl_AppInit を参照されたい｡ AppInitProc is almost always a pointer to Tcl_AppInit; for more details on this procedure, see the documentation for Tcl_AppInit.

Tk_Main は Tcl_Main と同様に機能する｡特に､ Tk_Main は相互対話様式と記述譜開始様式の両方をファイル名と Tcl_SetStartupScript の制御の元で開始の符号化と Tcl_GetStartupScript 専用譜を伴って運営している｡しかし､何かの記述譜を処理した後､ Tk_MainLoop を呼び､対話的に使用者の入力を処理する為に Tcl_CreateFileHandler によって登録された行事を使う｡ Tk_Main functions much the same as Tcl_Main. In particular, Tk_Main supports both an interactive mode and a startup script mode, with the file name and encoding of a startup script under the control of the Tcl_SetStartupScript and Tcl_GetStartupScript routines. However it calls Tk_MainLoop after processing any supplied script, and in interactive uses events registered with Tcl_CreateFileHandler to process user input.

### SEE ALSO

Tcl_DoOneEvent

### KEYWORDS

application-specific initialization, command-line arguments, main program
Copyright © 1994 The Regents of the University of California.
Copyright © 1994-1996 Sun Microsystems, Inc.