| 1 | /* |
|---|
| 2 | * tkAppInit.c -- |
|---|
| 3 | * |
|---|
| 4 | * Provides a default version of the Tcl_AppInit procedure for |
|---|
| 5 | * use in wish and similar Tk-based applications. |
|---|
| 6 | * |
|---|
| 7 | * Copyright (c) 1993 The Regents of the University of California. |
|---|
| 8 | * Copyright (c) 1994-1997 Sun Microsystems, Inc. |
|---|
| 9 | * |
|---|
| 10 | * See the file "license.terms" for information on usage and redistribution |
|---|
| 11 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
|---|
| 12 | */ |
|---|
| 13 | |
|---|
| 14 | #include "tk.h" |
|---|
| 15 | #include "locale.h" |
|---|
| 16 | #include <windows.h> |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | #ifdef TK_TEST |
|---|
| 20 | extern int Tktest_Init _ANSI_ARGS_((Tcl_Interp *interp)); |
|---|
| 21 | #endif /* TK_TEST */ |
|---|
| 22 | |
|---|
| 23 | /* |
|---|
| 24 | *---------------------------------------------------------------------- |
|---|
| 25 | * |
|---|
| 26 | * main -- |
|---|
| 27 | * |
|---|
| 28 | * This is the main program for the application. |
|---|
| 29 | * |
|---|
| 30 | * Results: |
|---|
| 31 | * None: Tk_Main never returns here, so this procedure never |
|---|
| 32 | * returns either. |
|---|
| 33 | * |
|---|
| 34 | * Side effects: |
|---|
| 35 | * Whatever the application does. |
|---|
| 36 | * |
|---|
| 37 | *---------------------------------------------------------------------- |
|---|
| 38 | */ |
|---|
| 39 | |
|---|
| 40 | #pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") |
|---|
| 41 | |
|---|
| 42 | int |
|---|
| 43 | main(argc, argv) |
|---|
| 44 | int argc; /* Number of command-line arguments. */ |
|---|
| 45 | char **argv; /* Values of command-line arguments. */ |
|---|
| 46 | { |
|---|
| 47 | /* |
|---|
| 48 | * The following #if block allows you to change the AppInit |
|---|
| 49 | * function by using a #define of TCL_LOCAL_APPINIT instead |
|---|
| 50 | * of rewriting this entire file. The #if checks for that |
|---|
| 51 | * #define and uses Tcl_AppInit if it doesn't exist. |
|---|
| 52 | */ |
|---|
| 53 | |
|---|
| 54 | #ifndef TK_LOCAL_APPINIT |
|---|
| 55 | #define TK_LOCAL_APPINIT Tcl_AppInit |
|---|
| 56 | #endif |
|---|
| 57 | extern int TK_LOCAL_APPINIT _ANSI_ARGS_((Tcl_Interp *interp)); |
|---|
| 58 | |
|---|
| 59 | //HWND hwnd = GetConsoleWindow(); |
|---|
| 60 | //ShowWindow(hwnd, 0); |
|---|
| 61 | |
|---|
| 62 | /* |
|---|
| 63 | * The following #if block allows you to change how Tcl finds the startup |
|---|
| 64 | * script, prime the library or encoding paths, fiddle with the argv, |
|---|
| 65 | * etc., without needing to rewrite Tk_Main() |
|---|
| 66 | */ |
|---|
| 67 | |
|---|
| 68 | #ifdef TK_LOCAL_MAIN_HOOK |
|---|
| 69 | extern int TK_LOCAL_MAIN_HOOK _ANSI_ARGS_((int *argc, char ***argv)); |
|---|
| 70 | TK_LOCAL_MAIN_HOOK(&argc, &argv); |
|---|
| 71 | #endif |
|---|
| 72 | |
|---|
| 73 | Tk_Main(argc, argv, TK_LOCAL_APPINIT); |
|---|
| 74 | return 0; /* Needed only to prevent compiler warning. */ |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | /* |
|---|
| 78 | *---------------------------------------------------------------------- |
|---|
| 79 | * |
|---|
| 80 | * Tcl_AppInit -- |
|---|
| 81 | * |
|---|
| 82 | * This procedure performs application-specific initialization. |
|---|
| 83 | * Most applications, especially those that incorporate additional |
|---|
| 84 | * packages, will have their own version of this procedure. |
|---|
| 85 | * |
|---|
| 86 | * Results: |
|---|
| 87 | * Returns a standard Tcl completion code, and leaves an error |
|---|
| 88 | * message in the interp's result if an error occurs. |
|---|
| 89 | * |
|---|
| 90 | * Side effects: |
|---|
| 91 | * Depends on the startup script. |
|---|
| 92 | * |
|---|
| 93 | *---------------------------------------------------------------------- |
|---|
| 94 | */ |
|---|
| 95 | |
|---|
| 96 | int |
|---|
| 97 | Tcl_AppInit(interp) |
|---|
| 98 | Tcl_Interp *interp; /* Interpreter for application. */ |
|---|
| 99 | { |
|---|
| 100 | if (Tcl_Init(interp) == TCL_ERROR) { |
|---|
| 101 | return TCL_ERROR; |
|---|
| 102 | } |
|---|
| 103 | if (Tk_Init(interp) == TCL_ERROR) { |
|---|
| 104 | return TCL_ERROR; |
|---|
| 105 | } |
|---|
| 106 | Tcl_StaticPackage(interp, "Tk", Tk_Init, Tk_SafeInit); |
|---|
| 107 | #ifdef TK_TEST |
|---|
| 108 | if (Tktest_Init(interp) == TCL_ERROR) { |
|---|
| 109 | return TCL_ERROR; |
|---|
| 110 | } |
|---|
| 111 | Tcl_StaticPackage(interp, "Tktest", Tktest_Init, |
|---|
| 112 | (Tcl_PackageInitProc *) NULL); |
|---|
| 113 | #endif /* TK_TEST */ |
|---|
| 114 | |
|---|
| 115 | |
|---|
| 116 | /* |
|---|
| 117 | * Call the init procedures for included packages. Each call should |
|---|
| 118 | * look like this: |
|---|
| 119 | * |
|---|
| 120 | * if (Mod_Init(interp) == TCL_ERROR) { |
|---|
| 121 | * return TCL_ERROR; |
|---|
| 122 | * } |
|---|
| 123 | * |
|---|
| 124 | * where "Mod" is the name of the module. |
|---|
| 125 | */ |
|---|
| 126 | |
|---|
| 127 | /* |
|---|
| 128 | * Call Tcl_CreateCommand for application-specific commands, if |
|---|
| 129 | * they weren't already created by the init procedures called above. |
|---|
| 130 | */ |
|---|
| 131 | |
|---|
| 132 | /* |
|---|
| 133 | * Specify a user-specific startup file to invoke if the application |
|---|
| 134 | * is run interactively. Typically the startup file is "~/.apprc" |
|---|
| 135 | * where "app" is the name of the application. If this line is deleted |
|---|
| 136 | * then no user-specific startup file will be run under any conditions. |
|---|
| 137 | */ |
|---|
| 138 | |
|---|
| 139 | Tcl_PkgRequire( interp, "TolbaseApp", TOLBASE_VERSION, 1); |
|---|
| 140 | return TCL_OK; |
|---|
| 141 | } |
|---|