-
Notifications
You must be signed in to change notification settings - Fork 851
Expand file tree
/
Copy pathpythonwin.cpp
More file actions
123 lines (103 loc) · 3.2 KB
/
pythonwin.cpp
File metadata and controls
123 lines (103 loc) · 3.2 KB
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
// pythonwin.cpp : Defines the class behaviors for the application.
//
#include "stdafxpw.h"
#include "pythonwin.h"
#include "Win32uiHostGlue.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
////////////////////////////////////////////////////////////////////////////
// CPythonWinApp
BEGIN_MESSAGE_MAP(CPythonWinApp, CWinApp)
//{{AFX_MSG_MAP(CPythonWinApp)
//}}AFX_MSG_MAP
// Standard file based document commands
// Standard print setup command
ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPythonWinApp construction
CPythonWinApp::CPythonWinApp()
{
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CPythonWinApp object
CPythonWinApp NEAR theApp;
// The one and only Glue object.
Win32uiHostGlue NEAR glue;
/////////////////////////////////////////////////////////////////////////////
// CPythonWinApp initialization
BOOL CPythonWinApp::InitApplication()
{
// create mem mapped file for switching instances.
m_pDocManager = new CDocManager();
if (!CWinApp::InitApplication())
return FALSE;
CString startup;
startup.LoadString(57346); // Grrr....
if (startup.GetLength() == 0)
startup = "import pywin.framework.startup";
if (!glue.DynamicApplicationInit(startup))
return FALSE;
return TRUE;
}
BOOL CPythonWinApp::InitInstance()
{
if (!glue.InitInstance())
return FALSE;
// dialog based apps don't have a message pump.
return m_pMainWnd && !m_pMainWnd->IsKindOf(RUNTIME_CLASS(CDialog));
}
int CPythonWinApp::ExitInstance()
{
int rc = glue.ExitInstance();
CWinApp::ExitInstance();
return rc;
}
// special idle handling to ignore WM_TIMER messages
// (mainly for Scintilla until it uses WM_SYSTIMER messages)
BOOL CPythonWinApp::IsIdleMessage(MSG *pmsg)
{
BOOL is = CWinApp::IsIdleMessage(pmsg);
if (is)
is = pmsg->message != WM_TIMER;
return is;
}
BOOL CPythonWinApp::OnCmdMsg(UINT nID, int nCode, void *pExtra, AFX_CMDHANDLERINFO *pHandlerInfo)
{
// yield to Python first
if (glue.OnCmdMsg(this, nID, nCode, pExtra, pHandlerInfo))
return TRUE;
else
return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
BOOL CPythonWinApp::PreTranslateMessage(MSG *pMsg)
{
if (glue.PreTranslateMessage(pMsg))
return TRUE;
else
return CWinApp::PreTranslateMessage(pMsg);
/* BOOL ret=CWinApp::PreTranslateMessage(pMsg);
BOOL ret2 = glue.PreTranslateMessage(pMsg);
return ret||ret2;
*/
}
BOOL CPythonWinApp::OnIdle(LONG lCount)
{
// call base class idle first
if (CWinApp::OnIdle(lCount))
return TRUE;
return glue.OnIdle(lCount);
}
CDocument *CPythonWinApp::OpenDocumentFile(LPCTSTR lpszFileName) { return CWinApp::OpenDocumentFile(lpszFileName); }
int CPythonWinApp::Run()
{
// Allow our Python app to override the run!
int rc = glue.Run();
glue.ApplicationFinalize();
return rc;
}
/////////////////////////////////////////////////////////////////////////////
// CPythonWinApp commands