File: tkWin32Dll.c

package info (click to toggle)
perl-tk 1%3A804.027-7
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 30,204 kB
  • ctags: 33,761
  • sloc: ansic: 340,354; perl: 44,606; sh: 8,869; makefile: 5,658; asm: 996; yacc: 883; cpp: 570; pascal: 536
file content (127 lines) | stat: -rw-r--r-- 2,848 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * tkWin32Dll.c --
 *
 *	This file contains a stub dll entry point.
 *
 * Copyright (c) 1995 Sun Microsystems, Inc.
 *
 * See the file "license.terms" for information on usage and redistribution
 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 * SCCS: @(#) tkWin32Dll.c 1.9 96/08/06 15:59:08
 */

#include "pTk/tkPort.h"

#if defined(WIN32) || (defined(__WIN32__) && defined(__CYGWIN__))

#include "pTk/tkWinInt.h"

static HINSTANCE tclInstance;	/* Global library instance handle. */

/*
 * The following declaration is for the VC++ DLL entry point.
 */

BOOL APIENTRY		DllMain _ANSI_ARGS_((HINSTANCE hInst,
			    DWORD reason, LPVOID reserved));

/*
 *----------------------------------------------------------------------
 *
 * DllEntryPoint --
 *
 *	This wrapper function is used by Borland to invoke the
 *	initialization code for Tk.  It simply calls the DllMain
 *	routine.
 *
 * Results:
 *	See DllMain.
 *
 * Side effects:
 *	See DllMain.
 *
 *----------------------------------------------------------------------
 */

BOOL APIENTRY
DllEntryPoint(hInst, reason, reserved)
    HINSTANCE hInst;		/* Library instance handle. */
    DWORD reason;		/* Reason this function is being called. */
    LPVOID reserved;		/* Not used. */
{
    return DllMain(hInst, reason, reserved);
}

/*
 *----------------------------------------------------------------------
 *
 * DllMain --
 *
 *	DLL entry point.
 *
 * Results:
 *	TRUE on sucess, FALSE on failure.
 *
 * Side effects:
 *	None.
 *
 *----------------------------------------------------------------------
 */

BOOL APIENTRY
DllMain(hInstance, reason, reserved)
    HINSTANCE hInstance;
    DWORD reason;
    LPVOID reserved;
{
    /*
     * If we are attaching to the DLL from a new process, tell Tk about
     * the hInstance to use. If we are detaching then clean up any
     * data structures related to this DLL.
     */

    if (reason == DLL_PROCESS_ATTACH) {
        /* We pretend to be Tcl as well - perhaps 
           we should use perl's or Tk::Event's hInstance for this ?
         */
	tclInstance = hInstance;
        /* and it is important to set Tk instance so 
           we can find bitmaps and cursors
         */
        TkWinSetHINSTANCE(hInstance);
        /* don't do this here - (do it in Boot?)
           as it makes calls to Tcl_Xxxx from Tk::Event and 
           we have not set vtables yet.
         */
#ifndef _LANG  
         TkWinXInit(hInstance);
#endif
    } else if (reason == DLL_PROCESS_DETACH) {
/* this is done by clean call now */
#if 0
      TkWinXCleanup(hInstance);
#endif
    }
    return(TRUE);
}

/*
 * TkWin32DllPresent() can be referenced elsewhere to
 * force inclusion of this file and hence DLLMain()
 */

int
TkWin32DllPresent()
{
 return 1;
}

HINSTANCE
TclWinGetTclInstance()
{
    return tclInstance;
}

#endif /* WIN32 */