Update of /cvsroot/pywin32/pywin32/Pythonwin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7141
Modified Files:
Tag: py3k
Win32app.h Win32uiHostGlue.h dbgthread.cpp ddeconv.cpp
ddeitem.cpp ddemodule.cpp ddemodule.h ddeserver.cpp
dllmain.cpp pythondoc.h stddde.cpp win32ImageList.cpp
win32RichEdit.cpp win32app.cpp win32assoc.cpp win32bitmap.cpp
win32cmd.cpp win32cmdui.cpp win32cmdui.h win32control.cpp
win32control.h win32ctledit.cpp win32ctrlList.cpp
win32ctrlRichEdit.cpp win32ctrlTree.cpp win32dc.cpp
win32dlg.cpp win32dlg.h win32dlgbar.cpp win32dll.cpp
win32doc.cpp win32menu.cpp win32notify.cpp
win32oleDlgInsert.cpp win32prop.cpp win32splitter.cpp
win32template.cpp win32thread.cpp win32toolbar.cpp
win32toolbar.h win32tooltip.cpp win32ui.h win32uiExt.h
win32uimodule.cpp win32uiole.cpp win32uioleClientItem.cpp
win32uioledoc.cpp win32uioledoc.h win32util.cpp win32view.cpp
win32virt.cpp win32win.cpp win32win.h
Log Message:
Changes for py3k and to build as UNICODE
Index: win32ctledit.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctledit.cpp,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** win32ctledit.cpp 1 Sep 1999 23:33:00 -0000 1.1
--- win32ctledit.cpp 29 Aug 2008 05:53:29 -0000 1.1.4.1
***************
*** 199,209 ****
{
CEdit *pEdit = GetEditCtrl(self);
! char *msg;
// @pyparm string|text||The text to replace the selection with.
! if (!pEdit || !PyArg_ParseTuple(args, "s:ReplaceSel", &msg))
return NULL;
GUI_BGN_SAVE;
pEdit->ReplaceSel(msg); // @pyseemfc CEdit|ReplaceSel
GUI_END_SAVE;
RETURN_NONE;
}
--- 199,213 ----
{
CEdit *pEdit = GetEditCtrl(self);
! TCHAR *msg;
! PyObject *obmsg;
// @pyparm string|text||The text to replace the selection with.
! if (!pEdit
! || !PyArg_ParseTuple(args, "O:ReplaceSel", &obmsg)
! || !PyWinObject_AsTCHAR(obmsg, &msg, FALSE))
return NULL;
GUI_BGN_SAVE;
pEdit->ReplaceSel(msg); // @pyseemfc CEdit|ReplaceSel
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(msg);
RETURN_NONE;
}
***************
*** 351,355 ****
// and handle worst case, and look what happens!
CString csBuffer; // use dynamic mem for buffer
! char *buf;
int bytesCopied;
// this TRACE _always_ returns the length of the first line - hence the
--- 355,359 ----
// and handle worst case, and look what happens!
CString csBuffer; // use dynamic mem for buffer
! TCHAR *buf;
int bytesCopied;
// this TRACE _always_ returns the length of the first line - hence the
***************
*** 377,381 ****
--bytesCopied;
buf[bytesCopied] = '\0';
! return Py_BuildValue("s",buf);
}
--- 381,385 ----
--bytesCopied;
buf[bytesCopied] = '\0';
! return PyWinObject_FromTCHAR(buf);
}
Index: win32app.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32app.cpp,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -d -r1.6 -r1.6.2.1
*** win32app.cpp 3 Jun 2007 12:35:57 -0000 1.6
--- win32app.cpp 29 Aug 2008 05:53:29 -0000 1.6.2.1
***************
*** 74,85 ****
// FindOpenDocument - if the C++ framework has a document with this name open,
// then return a pointer to it, else NULL.
! CDocument *CProtectedWinApp::FindOpenDocument(const char *lpszFileName)
{
POSITION posTempl = m_pDocManager->GetFirstDocTemplatePosition();
CDocument* pOpenDocument = NULL;
! char szPath[_MAX_PATH];
! if (!GetFullPath(szPath, lpszFileName))
! strcpy(szPath, lpszFileName);
while (posTempl) {
--- 74,85 ----
// FindOpenDocument - if the C++ framework has a document with this name open,
// then return a pointer to it, else NULL.
! CDocument *CProtectedWinApp::FindOpenDocument(const TCHAR *lpszFileName)
{
POSITION posTempl = m_pDocManager->GetFirstDocTemplatePosition();
CDocument* pOpenDocument = NULL;
! TCHAR szPath[_MAX_PATH];
! if (!AfxFullPath(szPath, lpszFileName))
! _tcscpy(szPath, lpszFileName);
while (posTempl) {
***************
*** 189,195 ****
ui_open_document_file(PyObject *self, PyObject *args)
{
! char *fileName;
! if (!PyArg_ParseTuple(args, "s:OpenDocumentFile",
! &fileName )) // @pyparm string|fileName||The name of the document to open.
return NULL;
CWinApp *pApp = GetApp();
--- 189,198 ----
ui_open_document_file(PyObject *self, PyObject *args)
{
! TCHAR *fileName;
! PyObject *obfileName;
! if (!PyArg_ParseTuple(args, "O:OpenDocumentFile",
! &obfileName )) // @pyparm string|fileName||The name of the document to open.
! return NULL;
! if (!PyWinObject_AsTCHAR(obfileName, &fileName))
return NULL;
CWinApp *pApp = GetApp();
***************
*** 202,205 ****
--- 205,209 ----
CDocument *pDoc = pApp->OpenDocumentFile(fileName);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(fileName);
if (PyErr_Occurred())
return NULL;
***************
*** 213,226 ****
ui_find_open_document(PyObject *self, PyObject *args)
{
! char *fileName;
// @pyparm string|fileName||The fully qualified filename to search for.
! if (!PyArg_ParseTuple(args,"s", &fileName))
return NULL;
CProtectedWinApp *pApp = GetProtectedApp();
if (!pApp) return NULL;
// Let MFC framework search for a filename for us.
GUI_BGN_SAVE;
CDocument *pDoc=pApp->FindOpenDocument(fileName);
GUI_END_SAVE;
if (pDoc==NULL)
RETURN_NONE;
--- 217,235 ----
ui_find_open_document(PyObject *self, PyObject *args)
{
! TCHAR *fileName;
! PyObject *obfileName;
// @pyparm string|fileName||The fully qualified filename to search for.
! if (!PyArg_ParseTuple(args,"O", &obfileName))
return NULL;
CProtectedWinApp *pApp = GetProtectedApp();
if (!pApp) return NULL;
+
+ if (!PyWinObject_AsTCHAR(obfileName, &fileName, FALSE))
+ return NULL;
// Let MFC framework search for a filename for us.
GUI_BGN_SAVE;
CDocument *pDoc=pApp->FindOpenDocument(fileName);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(fileName);
if (pDoc==NULL)
RETURN_NONE;
***************
*** 267,284 ****
static PyObject *ui_load_cursor(PyObject *self, PyObject *args)
{
! UINT cid;
! char *csid;
HCURSOR hc;
! if ( PyArg_ParseTuple(args, "i",
! &cid)) // @pyparm int|cursorId||The ID of the cursor to load.
! hc = GetApp()->LoadCursor(cid);
! else {
! PyErr_Clear();
! if (PyArg_ParseTuple(args, "s",
! &csid)) // @pyparmalt1 string|cursorId||The ID of the cursor to load.
! hc = GetApp()->LoadCursor(csid);
! else
! RETURN_TYPE_ERR("The first param must be an integer or a string");
! }
if (hc==0)
RETURN_API_ERR("LoadCursor");
--- 276,292 ----
static PyObject *ui_load_cursor(PyObject *self, PyObject *args)
{
! TCHAR *csid;
HCURSOR hc;
! PyObject *obid;
! if (!PyArg_ParseTuple(args, "O:LoadCursor",
! &obid)) // @pyparm <o PyResourceId>|cursorId||The resource id or name of the cursor to load.
! return NULL;
! if (!PyWinObject_AsResourceId(obid, &csid, TRUE))
! return NULL;
! if (IS_INTRESOURCE(csid))
! hc = GetApp()->LoadCursor((UINT)csid);
! else
! hc = GetApp()->LoadCursor(csid);
! PyWinObject_FreeResourceId(csid);
if (hc==0)
RETURN_API_ERR("LoadCursor");
***************
*** 289,306 ****
static PyObject *ui_load_standard_cursor(PyObject *self, PyObject *args)
{
! UINT cid;
! char *csid;
HCURSOR hc;
! if ( PyArg_ParseTuple(args, "i",
! &cid)) // @pyparm int|cursorId||The ID of the cursor to load.
! hc = GetApp()->LoadStandardCursor(MAKEINTRESOURCE(cid));
! else {
! PyErr_Clear();
! if (PyArg_ParseTuple(args, "s", // @pyparmalt1 string|cursorId||The ID of the cursor to load.
! &csid))
! hc = GetApp()->LoadStandardCursor(csid);
! else
! RETURN_TYPE_ERR("The first param must be an integer or a string");
! }
if (hc==0)
RETURN_API_ERR("LoadStandardCursor");
--- 297,310 ----
static PyObject *ui_load_standard_cursor(PyObject *self, PyObject *args)
{
! PyObject *obid;
! TCHAR *csid;
HCURSOR hc;
! if (!PyArg_ParseTuple(args, "O:LoadStandardCursor",
! &obid)) // @pyparm <o PyResourceId>|cursorId||The resource ID or name of the cursor to load.
! return NULL;
! if (!PyWinObject_AsResourceId(obid, &csid, TRUE))
! return NULL;
! hc = GetApp()->LoadStandardCursor(csid);
! PyWinObject_FreeResourceId(csid);
if (hc==0)
RETURN_API_ERR("LoadStandardCursor");
***************
*** 313,317 ****
UINT cid;
HCURSOR hc;
! if ( !PyArg_ParseTuple(args, "i",
&cid)) // @pyparm int|cursorId||The ID of the cursor to load.
return NULL;
--- 317,321 ----
UINT cid;
HCURSOR hc;
! if ( !PyArg_ParseTuple(args, "i:LoadOEMCursor",
&cid)) // @pyparm int|cursorId||The ID of the cursor to load.
return NULL;
***************
*** 332,336 ****
CWinApp *pApp = GetApp();
if (!pApp) return NULL;
! return Py_BuildValue("i", pApp->LoadIcon(idResource));
}
--- 336,340 ----
CWinApp *pApp = GetApp();
if (!pApp) return NULL;
! return PyWinLong_FromHANDLE(pApp->LoadIcon(idResource));
}
***************
*** 339,352 ****
ui_load_standard_icon(PyObject *self, PyObject *args)
{
! char *resName;
! // @pyparm string|resourceName||The name of the standard icon to load.
! if (!PyArg_ParseTuple(args,"s:LoadStandardIcon", &resName))
return NULL;
CWinApp *pApp = GetApp();
if (!pApp) return NULL;
! return Py_BuildValue("i", pApp->LoadStandardIcon(resName));
}
-
// @pymethod int|PyCWinApp|Run|Starts the message pump. Advanced users only
static PyObject *
--- 343,362 ----
ui_load_standard_icon(PyObject *self, PyObject *args)
{
! TCHAR *resName;
! PyObject *obName;
! // @pyparm <o PyResourceId>|resourceName||The resource name or id of the standard icon to load.
! if (!PyArg_ParseTuple(args,"O:LoadStandardIcon", &obName))
return NULL;
CWinApp *pApp = GetApp();
if (!pApp) return NULL;
! if (!PyWinObject_AsResourceId(obName, &resName, FALSE))
! return NULL;
! HICON hicon = pApp->LoadStandardIcon(resName);
! PyWinObject_FreeResourceId(resName);
! if (hicon==0)
! RETURN_API_ERR("LoadStandardIcon");
! return PyWinLong_FromHANDLE(hicon);
}
// @pymethod int|PyCWinApp|Run|Starts the message pump. Advanced users only
static PyObject *
Index: win32win.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32win.cpp,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -C2 -d -r1.21 -r1.21.2.1
*** win32win.cpp 26 Feb 2008 09:36:22 -0000 1.21
--- win32win.cpp 29 Aug 2008 05:53:30 -0000 1.21.2.1
***************
*** 74,77 ****
--- 74,79 ----
PyObject *method;
CWnd *pWnd = bInFatalShutdown ? NULL : CWnd::FromHandlePermanent(msg->hwnd);
+ // is_uiobjects calls python methods, must already hold lock
+ CEnterLeavePython _celp;
if (pWnd &&
(pObj=ui_assoc_object::GetPyObject(pWnd)) &&
***************
*** 84,88 ****
#endif
// Our Python convention is TRUE means "pass it on"
! CEnterLeavePython _celp;
return Python_callback(method, msg)==0;
}
--- 86,90 ----
#endif
// Our Python convention is TRUE means "pass it on"
! // CEnterLeavePython _celp;
return Python_callback(method, msg)==0;
}
***************
*** 117,121 ****
} else {
char buf[128];
! wsprintf(buf,"Argument must be a %s object, or integer containing a HWND", type.tp_name);
RETURN_ERR(buf);
}
--- 119,123 ----
} else {
char buf[128];
! snprintf(buf, sizeof(buf), "Argument must be a %s object, or integer containing a HWND", type.tp_name);
RETURN_ERR(buf);
}
***************
*** 176,180 ****
return FALSE;
}
! PyErr_Clear(); // clear any errors, so I can detect my own.
// 0 - mask.
if ((ob=PyTuple_GetItem(args, 0))==NULL)
--- 178,182 ----
return FALSE;
}
! assert (!PyErr_Occurred()); // PyErr_Clear(); // clear any errors, so I can detect my own.
// 0 - mask.
if ((ob=PyTuple_GetItem(args, 0))==NULL)
***************
*** 278,288 ****
PyObject *obParent;
RECT rect;
! const char *szClass, *szWndName;
CCreateContext *pCCPass = NULL;
PythonCreateContext cc;
PyObject *contextObject = Py_None;
! if (!PyArg_ParseTuple(args, "zzi(iiii)Oi|O:CreateWindow",
! &szClass, // @pyparm string|classId||The class ID for the window, or None
! &szWndName, // @pyparm string|windowName||The title for the window, or None
&style, // @pyparm int|style||The style for the window.
&rect.left,&rect.top,&rect.right,&rect.bottom,
--- 280,291 ----
PyObject *obParent;
RECT rect;
! TCHAR *szClass=NULL, *szWndName=NULL;
! PyObject *obClass, *obWndName, *ret=NULL;
CCreateContext *pCCPass = NULL;
PythonCreateContext cc;
PyObject *contextObject = Py_None;
! if (!PyArg_ParseTuple(args, "OOi(iiii)Oi|O:CreateWindow",
! &obClass, // @pyparm string|classId||The class ID for the window, or None
! &obWndName, // @pyparm string|windowName||The title for the window, or None
&style, // @pyparm int|style||The style for the window.
&rect.left,&rect.top,&rect.right,&rect.bottom,
***************
*** 310,321 ****
return NULL;
! BOOL ok;
! GUI_BGN_SAVE;
! // @pyseemfc CWnd|Create
! ok = pWnd->Create(szClass, szWndName, style, rect, pParent, id, pCCPass);
! GUI_END_SAVE;
! if (!ok)
! RETURN_ERR("CWnd::Create");
! RETURN_NONE;
}
--- 313,333 ----
return NULL;
! if (PyWinObject_AsTCHAR(obClass, &szClass, TRUE)&&
! PyWinObject_AsTCHAR(obWndName, &szWndName, TRUE)){
! BOOL ok;
! GUI_BGN_SAVE;
! // @pyseemfc CWnd|Create
! ok = pWnd->Create(szClass, szWndName, style, rect, pParent, id, pCCPass);
! GUI_END_SAVE;
! if (!ok)
! PyErr_SetString(ui_module_error, "CWnd::Create");
! else{
! Py_INCREF(Py_None);
! ret=Py_None;
! }
! }
! PyWinObject_FreeTCHAR(szClass);
! PyWinObject_FreeTCHAR(szWndName);
! return ret;
}
***************
*** 327,337 ****
PyObject *obParent;
RECT rect;
! const char *szClass, *szWndName;
DWORD dwStyleEx;
PyObject *csObject = Py_None;
! if (!PyArg_ParseTuple(args, "iszi(iiii)Oi|O:CreateWindowEx",
&dwStyleEx, // @pyparm int|styleEx||The extended style of the window being created.
! &szClass, // @pyparm string|classId||The class ID for the window. May not be None.
! &szWndName, // @pyparm string|windowName||The title for the window, or None
&style, // @pyparm int|style||The style for the window.
&rect.left,&rect.top,&rect.right,&rect.bottom,
--- 339,350 ----
PyObject *obParent;
RECT rect;
! TCHAR *szClass=NULL, *szWndName=NULL;
! PyObject *obClass, *obWndName;
DWORD dwStyleEx;
PyObject *csObject = Py_None;
! if (!PyArg_ParseTuple(args, "iOOi(iiii)Oi|O:CreateWindowEx",
&dwStyleEx, // @pyparm int|styleEx||The extended style of the window being created.
! &obClass, // @pyparm string|classId||The class ID for the window. May not be None.
! &obWndName, // @pyparm string|windowName||The title for the window, or None
&style, // @pyparm int|style||The style for the window.
&rect.left,&rect.top,&rect.right,&rect.bottom,
***************
*** 364,367 ****
--- 377,386 ----
return NULL;
+ if (!PyWinObject_AsTCHAR(obClass, &szClass, FALSE))
+ return NULL;
+ if (!PyWinObject_AsTCHAR(obWndName, &szWndName, TRUE)){
+ PyWinObject_FreeTCHAR(szClass);
+ return NULL;
+ }
BOOL ok;
GUI_BGN_SAVE;
***************
*** 369,372 ****
--- 388,393 ----
ok = pWnd->CreateEx(dwStyleEx, szClass, szWndName, style, rect, pParent, id, pcs);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(szClass);
+ PyWinObject_FreeTCHAR(szWndName);
if (!ok)
RETURN_ERR("CWnd::CreateEx");
***************
*** 396,400 ****
PyCWnd::CreateControl(PyObject *self, PyObject *args)
{
- USES_CONVERSION;
PyObject *parent = Py_None;
int id;
--- 417,420 ----
***************
*** 403,411 ****
PyObject *obPersist = Py_None;
int bStorage = FALSE;
! const char *szClass, *szWndName;
PyObject *obLicKey = Py_None;
! if (!PyArg_ParseTuple(args, "szi(iiii)Oi|OiO",
! &szClass, // @pyparm string|classId||The class ID for the window.
! &szWndName, // @pyparm string|windowName||The title for the window.
&style, // @pyparm int|style||The style for the control.
// @pyparm (left, top, right, bottom)|rect||The default position of the window.
--- 423,432 ----
PyObject *obPersist = Py_None;
int bStorage = FALSE;
! TCHAR *szClass=NULL, *szWndName=NULL;
! PyObject *obClass, *obWndName;
PyObject *obLicKey = Py_None;
! if (!PyArg_ParseTuple(args, "OOi(iiii)Oi|OiO:CreateControl",
! &obClass, // @pyparm string|classId||The class ID for the window.
! &obWndName, // @pyparm string|windowName||The title for the window.
&style, // @pyparm int|style||The style for the control.
// @pyparm (left, top, right, bottom)|rect||The default position of the window.
***************
*** 418,423 ****
--- 439,447 ----
return NULL;
+ if (!PyWinObject_AsTCHAR(obClass, &szClass, FALSE))
+ return NULL;
CLSID clsid;
HRESULT hr = AfxGetClassIDFromString(szClass, &clsid);
+ PyWinObject_FreeTCHAR(szClass);
if (FAILED(hr))
RETURN_ERR("The CLSID is invalid");
***************
*** 436,443 ****
--- 460,470 ----
if (afxOccManager == NULL)
RETURN_ERR("win32ui.EnableControlContainer() has not been called yet.");
+ if (!PyWinObject_AsTCHAR(obWndName, &szWndName, TRUE))
+ return NULL;
BOOL ok;
GUI_BGN_SAVE;
ok = pWnd->CreateControl(clsid, szWndName, style, rect, pWndParent, id, NULL, bStorage, bstrLicKey);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(szWndName);
if (!ok)
RETURN_ERR("CreateControl failed");
***************
*** 493,505 ****
PyCWnd::FindWindow(PyObject *self, PyObject *args)
{
! char *szClassName;
! char *szWndName;
! if (!PyArg_ParseTuple(args, "zz:FindWindow",
! &szClassName, // @pyparm string|className||The window class name to find, else None
! &szWndName)) // @pyparm string|windowName||The window name (ie, title) to find, else None
return NULL;
GUI_BGN_SAVE;
CWnd *pWnd = CWnd::FindWindow( szClassName, szWndName );
GUI_END_SAVE;
if (pWnd==NULL)
RETURN_ERR("No window can be found.");
--- 520,541 ----
PyCWnd::FindWindow(PyObject *self, PyObject *args)
{
! TCHAR *szClassName=NULL;
! TCHAR *szWndName=NULL;
! PyObject *obClassName, *obWndName;
! if (!PyArg_ParseTuple(args, "OO:FindWindow",
! &obClassName, // @pyparm string|className||The window class name to find, else None
! &obWndName)) // @pyparm string|windowName||The window name (ie, title) to find, else None
! return NULL;
! if (!PyWinObject_AsTCHAR(obClassName, &szClassName, TRUE))
! return NULL;
! if (!PyWinObject_AsTCHAR(obWndName, &szWndName, TRUE)){
! PyWinObject_FreeTCHAR(szClassName);
return NULL;
+ }
GUI_BGN_SAVE;
CWnd *pWnd = CWnd::FindWindow( szClassName, szWndName );
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(szClassName);
+ PyWinObject_FreeTCHAR(szWndName);
if (pWnd==NULL)
RETURN_ERR("No window can be found.");
***************
*** 512,524 ****
PyCWnd::FindWindowEx(PyObject *self, PyObject *args)
{
! char *szClassName;
! char *szWndName;
PyObject *obParent;
PyObject *obChildAfter;
! if (!PyArg_ParseTuple(args, "OOzz:FindWindowEx",
&obParent, // @pyparm <o PyCWnd>|parentWindow||The parent whose children will be searched. If None, the desktops window will be used.
&obChildAfter, // @pyparm <o PyCWnd>|childAfter||The search begins with the next window in the Z order. If None, all children are searched.
! &szClassName, // @pyparm string|className||The window class name to find, else None
! &szWndName)) // @pyparm string|windowName||The window name (ie, title) to find, else None
return NULL;
CWnd *pParent = NULL;
--- 548,561 ----
PyCWnd::FindWindowEx(PyObject *self, PyObject *args)
{
! TCHAR *szClassName=NULL;
! TCHAR *szWndName=NULL;
! PyObject *obClassName, *obWndName, *ret=NULL;
PyObject *obParent;
PyObject *obChildAfter;
! if (!PyArg_ParseTuple(args, "OOOO:FindWindowEx",
&obParent, // @pyparm <o PyCWnd>|parentWindow||The parent whose children will be searched. If None, the desktops window will be used.
&obChildAfter, // @pyparm <o PyCWnd>|childAfter||The search begins with the next window in the Z order. If None, all children are searched.
! &obClassName, // @pyparm string|className||The window class name to find, else None
! &obWndName)) // @pyparm string|windowName||The window name (ie, title) to find, else None
return NULL;
CWnd *pParent = NULL;
***************
*** 530,540 ****
if ((pChildAfter=GetWndPtrFromParam(obChildAfter, PyCWnd::type))==NULL)
return NULL;
! GUI_BGN_SAVE;
! HWND hwnd = ::FindWindowEx(pParent->GetSafeHwnd(), pChildAfter->GetSafeHwnd(),
szClassName, szWndName);
! GUI_END_SAVE;
! if (hwnd==NULL)
! RETURN_ERR("No window can be found.");
! return PyCWnd::make( PyCWnd::type, NULL, hwnd)->GetGoodRet();
// @rdesc The result is a <o PyCWnd> (or derived) object, or a win32ui.error exception is raised.
}
--- 567,584 ----
if ((pChildAfter=GetWndPtrFromParam(obChildAfter, PyCWnd::type))==NULL)
return NULL;
! if (PyWinObject_AsTCHAR(obClassName, &szClassName, TRUE)
! &&PyWinObject_AsTCHAR(obWndName, &szWndName, TRUE)){
! GUI_BGN_SAVE;
! HWND hwnd = ::FindWindowEx(pParent->GetSafeHwnd(), pChildAfter->GetSafeHwnd(),
szClassName, szWndName);
! GUI_END_SAVE;
! if (hwnd==NULL)
! PyErr_SetString(ui_module_error, "FindWindowEx: No window can be found.");
! else
! ret = PyCWnd::make( PyCWnd::type, NULL, hwnd)->GetGoodRet();
! }
! PyWinObject_FreeTCHAR(szClassName);
! PyWinObject_FreeTCHAR(szWndName);
! return ret;
// @rdesc The result is a <o PyCWnd> (or derived) object, or a win32ui.error exception is raised.
}
***************
*** 809,816 ****
if (!pWnd)
return NULL;
! char *defPath;
int nIDListBox, nIDStaticPath, nFileType;
! if (!PyArg_ParseTuple(args,"siii:DlgDirList",
! &defPath, // @pyparm string|defPath||The file spec to fill the list box with
&nIDListBox, // @pyparm int|idListbox||The Id of the listbox control to fill.
&nIDStaticPath, // @pyparm int|idStaticPath||The Id of the static control used to display the current drive and directory. If idStaticPath is 0, it is assumed that no such control exists.
--- 853,861 ----
if (!pWnd)
return NULL;
! TCHAR *defPath;
! PyObject *obdefPath;
int nIDListBox, nIDStaticPath, nFileType;
! if (!PyArg_ParseTuple(args,"Oiii:DlgDirList",
! &obdefPath, // @pyparm string|defPath||The file spec to fill the list box with
&nIDListBox, // @pyparm int|idListbox||The Id of the listbox control to fill.
&nIDStaticPath, // @pyparm int|idStaticPath||The Id of the static control used to display the current drive and directory. If idStaticPath is 0, it is assumed that no such control exists.
***************
*** 818,823 ****
// It can be any combination of DDL_READWRITE, DDL_READONLY, DDL_HIDDEN, DDL_SYSTEM, DDL_DIRECTORY, DDL_ARCHIVE, DDL_POSTMSGS, DDL_DRIVES or DDL_EXCLUSIVE
return NULL;
! char pathBuf[MAX_PATH+1];
! strncpy(pathBuf, defPath, MAX_PATH);
pathBuf[MAX_PATH] = '\0';
int rc;
--- 863,870 ----
// It can be any combination of DDL_READWRITE, DDL_READONLY, DDL_HIDDEN, DDL_SYSTEM, DDL_DIRECTORY, DDL_ARCHIVE, DDL_POSTMSGS, DDL_DRIVES or DDL_EXCLUSIVE
return NULL;
! if (!PyWinObject_AsTCHAR(obdefPath, &defPath, FALSE))
! return NULL;
! TCHAR pathBuf[MAX_PATH+1];
! _tcsncpy(pathBuf, defPath, MAX_PATH);
pathBuf[MAX_PATH] = '\0';
int rc;
***************
*** 826,829 ****
--- 873,877 ----
rc = pWnd->DlgDirList( pathBuf, nIDListBox, nIDStaticPath, nFileType);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(defPath);
if (!rc)
RETURN_ERR("DlgDirList failed");
***************
*** 837,846 ****
if (!pWnd)
return NULL;
! char *defPath;
int nIDListBox, nIDStaticPath, nFileType;
! if (!PyArg_ParseTuple(args,"siii:DlgDirListComboBox", &defPath, &nIDListBox, &nIDStaticPath, &nFileType))
return NULL;
! char pathBuf[MAX_PATH+1];
! strncpy(pathBuf, defPath, MAX_PATH);
pathBuf[MAX_PATH] = '\0';
int rc;
--- 885,897 ----
if (!pWnd)
return NULL;
! TCHAR *defPath;
! PyObject *obdefPath;
int nIDListBox, nIDStaticPath, nFileType;
! if (!PyArg_ParseTuple(args,"Oiii:DlgDirListComboBox", &obdefPath, &nIDListBox, &nIDStaticPath, &nFileType))
return NULL;
! if (!PyWinObject_AsTCHAR(obdefPath, &defPath, FALSE))
! return NULL;
! TCHAR pathBuf[MAX_PATH+1];
! _tcsncpy(pathBuf, defPath, MAX_PATH);
pathBuf[MAX_PATH] = '\0';
int rc;
***************
*** 850,853 ****
--- 901,905 ----
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(defPath);
if (!rc)
RETURN_ERR("DlgDirListComboBox failed");
***************
*** 867,874 ****
return NULL;
int rc;
! char buf[MAX_PATH];
GUI_BGN_SAVE;
#if _MFC_VER >= 0x0800
! rc = pWnd->DlgDirSelect( buf, sizeof(buf), nIDListBox);
#else
rc = pWnd->DlgDirSelect( buf, nIDListBox);
--- 919,926 ----
return NULL;
int rc;
! TCHAR buf[MAX_PATH];
GUI_BGN_SAVE;
#if _MFC_VER >= 0x0800
! rc = pWnd->DlgDirSelect( buf, sizeof(buf)/sizeof(TCHAR), nIDListBox);
#else
rc = pWnd->DlgDirSelect( buf, nIDListBox);
***************
*** 878,883 ****
if (!rc)
RETURN_ERR("DlgDirSelect failed");
! return Py_BuildValue("s", buf);
}
// @pymethod string|PyCWnd|DlgDirSelectComboBox|
// Retrieves the current selection from the list box of a combo box. It assumes that the list box has been filled by the <om PyCWnd.DlgDirListComboBox> member function and that the selection is a drive letter, a file, or a directory name.
--- 930,936 ----
if (!rc)
RETURN_ERR("DlgDirSelect failed");
! return PyWinObject_FromTCHAR(buf);
}
+
// @pymethod string|PyCWnd|DlgDirSelectComboBox|
// Retrieves the current selection from the list box of a combo box. It assumes that the list box has been filled by the <om PyCWnd.DlgDirListComboBox> member function and that the selection is a drive letter, a file, or a directory name.
***************
*** 893,901 ****
return NULL;
int rc;
! char buf[MAX_PATH];
GUI_BGN_SAVE;
// @pyseemfc CWnd|DlgDirSelectComboBox
#if _MFC_VER >= 0x0800
! rc = pWnd->DlgDirSelectComboBox( buf, sizeof(buf), nIDListBox);
#else
rc = pWnd->DlgDirSelectComboBox( buf, nIDListBox);
--- 946,954 ----
return NULL;
int rc;
! TCHAR buf[MAX_PATH];
GUI_BGN_SAVE;
// @pyseemfc CWnd|DlgDirSelectComboBox
#if _MFC_VER >= 0x0800
! rc = pWnd->DlgDirSelectComboBox( buf, sizeof(buf)/sizeof(TCHAR), nIDListBox);
#else
rc = pWnd->DlgDirSelectComboBox( buf, nIDListBox);
***************
*** 904,908 ****
if (!rc)
RETURN_ERR("DlgDirSelectComboBox failed");
! return Py_BuildValue("s", buf);
}
--- 957,961 ----
if (!rc)
RETURN_ERR("DlgDirSelectComboBox failed");
! return PyWinObject_FromTCHAR(buf);
}
***************
*** 1020,1034 ****
{
int id;
! char *szText;
// @pyparm int|idControl||The Id of the control
// @pyparm string|text||The new text
! if (!PyArg_ParseTuple(args, "is:SetDlgItemText", &id, &szText ))
return NULL;
CWnd *pWnd = GetWndPtrGoodHWnd(self);
if (!pWnd)
return NULL;
GUI_BGN_SAVE;
pWnd->SetDlgItemText(id, szText);
GUI_END_SAVE;
RETURN_NONE;
// @pyseemfc CWnd|SetDlgItemText
--- 1073,1091 ----
{
int id;
! TCHAR *szText;
! PyObject *obText;
// @pyparm int|idControl||The Id of the control
// @pyparm string|text||The new text
! if (!PyArg_ParseTuple(args, "iO:SetDlgItemText", &id, &obText ))
return NULL;
CWnd *pWnd = GetWndPtrGoodHWnd(self);
if (!pWnd)
return NULL;
+ if (!PyWinObject_AsTCHAR(obText, &szText, FALSE))
+ return NULL;
GUI_BGN_SAVE;
pWnd->SetDlgItemText(id, szText);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(szText);
RETURN_NONE;
// @pyseemfc CWnd|SetDlgItemText
***************
*** 1074,1078 ****
pWnd->GetDlgItemText(id, csRet);
GUI_END_SAVE;
! return PyString_FromString((char *)(const char *)csRet);
// @pyseemfc CWnd|GetDlgItemText
}
--- 1131,1135 ----
pWnd->GetDlgItemText(id, csRet);
GUI_END_SAVE;
! return PyWinObject_FromTCHAR(csRet);
// @pyseemfc CWnd|GetDlgItemText
}
***************
*** 1476,1480 ****
pWnd->GetWindowText( csText );
GUI_END_SAVE;
! return Py_BuildValue("s",(const char *)csText);
}
// @pymethod object|PyCWnd|HookKeyStroke|Hook a key stroke handler
--- 1533,1537 ----
pWnd->GetWindowText( csText );
GUI_END_SAVE;
! return PyWinObject_FromTCHAR(csText);
}
// @pymethod object|PyCWnd|HookKeyStroke|Hook a key stroke handler
***************
*** 1641,1652 ****
ui_window_message_box(PyObject * self, PyObject * args)
{
! char *message;
long style = MB_OK;
- const char *title = NULL;
-
! if (!PyArg_ParseTuple(args, "s|zl:MessageBox",
! &message, // @pyparm string|message||The message to be displayed in the message box.
! &title, // @pyparm string/None|title|None|The title for the message box. If None, the applications title will be used.
&style)) // @pyparm int|style|win32con.MB_OK|The style of the message box.
return NULL;
--- 1698,1708 ----
ui_window_message_box(PyObject * self, PyObject * args)
{
! TCHAR *message, *title=NULL;
! PyObject *obmessage, *obtitle=Py_None;
long style = MB_OK;
! if (!PyArg_ParseTuple(args, "O|Ol:MessageBox",
! &obmessage, // @pyparm string|message||The message to be displayed in the message box.
! &obtitle, // @pyparm string/None|title|None|The title for the message box. If None, the applications title will be used.
&style)) // @pyparm int|style|win32con.MB_OK|The style of the message box.
return NULL;
***************
*** 1654,1657 ****
--- 1710,1719 ----
if (!pWnd)
return NULL;
+ if (!PyWinObject_AsTCHAR(obmessage, &message, FALSE))
+ return NULL;
+ if (!PyWinObject_AsTCHAR(obtitle, &title, TRUE)){
+ PyWinObject_FreeTCHAR(message);
+ return NULL;
+ }
int rc;
GUI_BGN_SAVE;
***************
*** 1659,1662 ****
--- 1721,1726 ----
rc = pWnd->MessageBox(message, title, style);
+ PyWinObject_FreeTCHAR(message);
+ PyWinObject_FreeTCHAR(title);
GUI_END_SAVE;
return Py_BuildValue("i",rc);
***************
*** 1861,1871 ****
{
LRESULT res;
! int msg, wParam, lParam;
CRect rect;
BOOL bRepaint= TRUE;
! if (!PyArg_ParseTuple(args, "iii:OnWndMsg",
&msg, // @pyparm int|msg||The message
! (int *)&wParam, // @pyparm int|wParam||The wParam for the message
! (int *)&lParam)) // @pyparm int|lParam||The lParam for the message
return NULL;
--- 1925,1938 ----
{
LRESULT res;
! int msg;
! WPARAM wParam;
! LPARAM lParam;
! PyObject *obwParam, *oblParam;
CRect rect;
BOOL bRepaint= TRUE;
! if (!PyArg_ParseTuple(args, "iOO:OnWndMsg",
&msg, // @pyparm int|msg||The message
! &obwParam, // @pyparm int|wParam||The wParam for the message
! &oblParam)) // @pyparm int|lParam||The lParam for the message
return NULL;
***************
*** 1873,1876 ****
--- 1940,1947 ----
if (!pWnd)
return NULL;
+ if (!PyWinObject_AsPARAM(obwParam, &wParam))
+ return NULL;
+ if (!PyWinObject_AsPARAM(oblParam, &lParam))
+ return NULL;
GUI_BGN_SAVE;
BOOL rc = pWnd->WndHack::OnWndMsg(msg, wParam, lParam, &res );
***************
*** 2185,2191 ****
if (!pWnd)
return NULL;
! char *msg;
// @pyparm string|text||The windows text.
! if (!PyArg_ParseTuple(args, "s:SetWindowText", &msg))
return NULL;
// @pyseemfc CWnd|SetWindowText
--- 2256,2265 ----
if (!pWnd)
return NULL;
! TCHAR *msg;
! PyObject *obmsg;
// @pyparm string|text||The windows text.
! if (!PyArg_ParseTuple(args, "O:SetWindowText", &obmsg))
! return NULL;
! if (!PyWinObject_AsTCHAR(obmsg, &msg, FALSE))
return NULL;
// @pyseemfc CWnd|SetWindowText
***************
*** 2193,2196 ****
--- 2267,2271 ----
pWnd->SetWindowText(msg);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(msg);
RETURN_NONE;
}
***************
*** 3263,3268 ****
UINT_PTR numMsg = pMessageHookList ? pMessageHookList->GetCount() : 0;
UINT_PTR numKey = pKeyHookList ? pKeyHookList->GetCount() : 0;
! char *hookStr = obKeyStrokeHandler ? " (AllKeys Hook Active)" : "";
! csRet.Format("%s, mh=%Iu, kh=%Iu%s", (const char *)base_repr, numMsg, numKey, hookStr);
return csRet;
}
--- 3338,3343 ----
UINT_PTR numMsg = pMessageHookList ? pMessageHookList->GetCount() : 0;
UINT_PTR numKey = pKeyHookList ? pKeyHookList->GetCount() : 0;
! TCHAR *hookStr = obKeyStrokeHandler ? _T(" (AllKeys Hook Active)") : _T("");
! csRet.Format(_T("%s, mh=%Iu, kh=%Iu%s"), (const TCHAR *)base_repr, numMsg, numKey, hookStr);
return csRet;
}
***************
*** 3324,3333 ****
PyObject *obContext = Py_None;
PyObject *obMenuID = Py_None;
! char *szClass=NULL, *szTitle=NULL;
DWORD styleEx=0;
DWORD style = WS_VISIBLE | WS_OVERLAPPEDWINDOW;
! if(!PyArg_ParseTuple(args, "zs|lOOOOl:Create",
! &szClass, // @pyparm string|wndClass||The window class name, or None
! &szTitle, // @pyparm string|title||The window title
&style, // @pyparm int|style| WS_VISIBLE \| WS_OVERLAPPEDWINDOW|The window style
&obRect, // @pyparm int, int, int, int|rect|None|The default rectangle
--- 3399,3409 ----
PyObject *obContext = Py_None;
PyObject *obMenuID = Py_None;
! TCHAR *szClass = NULL, *szTitle = NULL, *szMenuName = NULL;
! PyObject *obClass, *obTitle, *ret=NULL;
DWORD styleEx=0;
DWORD style = WS_VISIBLE | WS_OVERLAPPEDWINDOW;
! if(!PyArg_ParseTuple(args, "OO|lOOOOl:Create",
! &obClass, // @pyparm string|wndClass||The window class name, or None
! &obTitle, // @pyparm string|title||The window title
&style, // @pyparm int|style| WS_VISIBLE \| WS_OVERLAPPEDWINDOW|The window style
&obRect, // @pyparm int, int, int, int|rect|None|The default rectangle
***************
*** 3344,3355 ****
pContext = &cc;
}
! if (obRect != Py_None)
! {
! if (!PyArg_ParseTuple(obRect, "iiii", &rect.left, &rect.top, &rect.right,&rect.bottom))
! {
! PyErr_Clear();
! RETURN_TYPE_ERR("Rect must be None or a tuple of (iiii)");
! }
}
CFrameWnd *pParent = NULL;
if (obParent != Py_None)
--- 3420,3429 ----
pContext = &cc;
}
!
! if (obRect != Py_None){
! if (!PyArg_ParseTuple(obRect, "iiii:RECT", &rect.left, &rect.top, &rect.right,&rect.bottom))
! return NULL;
}
+
CFrameWnd *pParent = NULL;
if (obParent != Py_None)
***************
*** 3359,3380 ****
RETURN_TYPE_ERR("The parent window is not a valid PyFrameWnd");
}
- char *szMenuName = NULL;
- if (obMenuID != Py_None)
- {
- if (PyInt_Check(obMenuID))
- szMenuName = MAKEINTRESOURCE(PyInt_AsLong(obMenuID));
- else if (PyString_Check(obMenuID))
- szMenuName = PyString_AsString(obMenuID);
- else
- RETURN_TYPE_ERR("The menu id must be an integer or string");
- }
! GUI_BGN_SAVE;
! // @pyseemfc CFrameWnd|Create
! BOOL ok = pFrame->Create(szClass, szTitle, style, rect,pParent,szMenuName,styleEx,pContext);
! GUI_END_SAVE;
! if (!ok)
! RETURN_ERR("CFrameWnd::Create failed");
! RETURN_NONE;
}
--- 3433,3456 ----
RETURN_TYPE_ERR("The parent window is not a valid PyFrameWnd");
}
! if (PyWinObject_AsTCHAR(obClass, &szClass, TRUE)
! &&PyWinObject_AsTCHAR(obTitle, &szTitle, FALSE)
! &&PyWinObject_AsResourceId(obMenuID, &szMenuName, TRUE)){
! BOOL ok;
! GUI_BGN_SAVE;
! // @pyseemfc CFrameWnd|Create
! ok = pFrame->Create(szClass, szTitle, style, rect,pParent,szMenuName,styleEx,pContext);
! GUI_END_SAVE;
! if (!ok)
! PyErr_SetString(ui_module_error, "CFrameWnd::Create failed");
! else{
! Py_INCREF(Py_None);
! ret=Py_None;
! }
! }
! PyWinObject_FreeTCHAR(szClass);
! PyWinObject_FreeTCHAR(szTitle);
! PyWinObject_FreeResourceId(szMenuName);
! return ret;
}
***************
*** 3416,3433 ****
if (!PyArg_ParseTuple(args, "O", &obID))
return NULL;
! char *res;
! if (PyInt_Check(obID))
! res = MAKEINTRESOURCE(PyInt_AsLong(obID));
! else if (PyString_Check(obID))
! res = PyString_AsString(obID);
! else
! RETURN_TYPE_ERR("The param must be an integer or string");
GUI_BGN_SAVE;
BOOL ok = pFrame->LoadAccelTable(res);
GUI_END_SAVE;
if (!ok)
RETURN_ERR("LoadAccelTable failed");
RETURN_NONE;
}
// @pymethod |PyCFrameWnd|LoadFrame|Loads a Windows frame window and associated resources
static PyObject *
--- 3492,3508 ----
if (!PyArg_ParseTuple(args, "O", &obID))
return NULL;
! // @pyparm <o PyResourceId>|id||Name or id of the resource that contains the table
! TCHAR *res;
! if (!PyWinObject_AsResourceId(obID, &res, FALSE))
! return NULL;
GUI_BGN_SAVE;
BOOL ok = pFrame->LoadAccelTable(res);
GUI_END_SAVE;
+ PyWinObject_FreeResourceId(res);
if (!ok)
RETURN_ERR("LoadAccelTable failed");
RETURN_NONE;
}
+
// @pymethod |PyCFrameWnd|LoadFrame|Loads a Windows frame window and associated resources
static PyObject *
***************
*** 3603,3613 ****
if (!pFrame)
return NULL;
! char *profileName;
! if (!PyArg_ParseTuple(args,"s:SaveBarState",
! &profileName)) // @pyparm string|profileName||Name of a section in the initialization file or a key in the Windows registry where state information is stored.
return NULL;
GUI_BGN_SAVE;
pFrame->SaveBarState(profileName); // @pyseemfc CFrameWnd|SaveBarState
GUI_END_SAVE;
RETURN_NONE;
}
--- 3678,3692 ----
if (!pFrame)
return NULL;
! TCHAR *profileName;
! PyObject *obprofileName;
! if (!PyArg_ParseTuple(args,"O:SaveBarState",
! &obprofileName)) // @pyparm string|profileName||Name of a section in the initialization file or a key in the Windows registry where state information is stored.
! return NULL;
! if (!PyWinObject_AsTCHAR(obprofileName, &profileName, FALSE))
return NULL;
GUI_BGN_SAVE;
pFrame->SaveBarState(profileName); // @pyseemfc CFrameWnd|SaveBarState
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(profileName);
RETURN_NONE;
}
***************
*** 3620,3626 ****
if (!pFrame)
return NULL;
! char *profileName;
! if (!PyArg_ParseTuple(args,"s:LoadBarState",
! &profileName)) // @pyparm string|profileName||Name of a section in the initialization file or a key in the Windows registry where state information is stored.
return NULL;
GUI_BGN_SAVE;
--- 3699,3708 ----
if (!pFrame)
return NULL;
! TCHAR *profileName;
! PyObject *obprofileName;
! if (!PyArg_ParseTuple(args,"O:LoadBarState",
! &obprofileName)) // @pyparm string|profileName||Name of a section in the initialization file or a key in the Windows registry where state information is stored.
! return NULL;
! if (!PyWinObject_AsTCHAR(obprofileName, &profileName, FALSE))
return NULL;
GUI_BGN_SAVE;
***************
*** 3630,3636 ****
--- 3712,3720 ----
catch (...) {
GUI_BLOCK_THREADS;
+ PyWinObject_FreeTCHAR(profileName);
RETURN_ERR("LoadBarState failed (with win32 exception!)");
}
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(profileName);
RETURN_NONE;
}
***************
*** 3706,3710 ****
pFrame->CFrameWnd::GetMessageString(id, csRet);
GUI_END_SAVE;
! return Py_BuildValue("s", (const char *)csRet);
}
--- 3790,3794 ----
pFrame->CFrameWnd::GetMessageString(id, csRet);
GUI_END_SAVE;
! return PyWinObject_FromTCHAR(csRet);
}
***************
*** 4096,4104 ****
PyObject *obParent = Py_None;
PyObject *obContext = Py_None;
! char *szClass, *szTitle;
DWORD style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW;
! if (!PyArg_ParseTuple(args, "zs|lOOO:CreateWindow",
! &szClass, // @pyparm string|wndClass||The window class name, or None
! &szTitle, // @pyparm string|title||The window title
&style, // @pyparm int|style|WS_CHILD \| WS_VISIBLE \| WS_OVERLAPPEDWINDOW|The window style
&obRect, // @pyparm int, int, int, int|rect|None|The default rectangle
--- 4180,4189 ----
PyObject *obParent = Py_None;
PyObject *obContext = Py_None;
! TCHAR *szClass=NULL, *szTitle=NULL;
! PyObject *obClass, *obTitle;
DWORD style = WS_CHILD | WS_VISIBLE | WS_OVERLAPPEDWINDOW;
! if (!PyArg_ParseTuple(args, "OO|lOOO:CreateWindow",
! &obClass, // @pyparm string|wndClass||The window class name, or None
! &obTitle, // @pyparm string|title||The window title
&style, // @pyparm int|style|WS_CHILD \| WS_VISIBLE \| WS_OVERLAPPEDWINDOW|The window style
&obRect, // @pyparm int, int, int, int|rect|None|The default rectangle
***************
*** 4113,4121 ****
}
if (obRect != Py_None) {
! if (!PyArg_ParseTuple(obRect, "iiii", &rect.left, &rect.top, &rect.right, &rect.bottom)) {
! PyErr_Clear();
! RETURN_TYPE_ERR("Rect must be None or a tuple of (iiii)");
}
- }
CMDIFrameWnd *pParent = NULL;
if (obParent != Py_None) {
--- 4198,4204 ----
}
if (obRect != Py_None) {
! if (!PyArg_ParseTuple(obRect, "iiii:RECT", &rect.left, &rect.top, &rect.right, &rect.bottom))
! return NULL;
}
CMDIFrameWnd *pParent = NULL;
if (obParent != Py_None) {
***************
*** 4125,4131 ****
--- 4208,4223 ----
}
+ if (!PyWinObject_AsTCHAR(obClass, &szClass, TRUE))
+ return NULL;
+ if (!PyWinObject_AsTCHAR(obTitle, &szTitle, FALSE)){
+ PyWinObject_FreeTCHAR(szClass);
+ return NULL;
+ }
+
GUI_BGN_SAVE;
BOOL ok = pWnd->Create(szClass, szTitle, style, rect, pParent, pContext);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(szClass);
+ PyWinObject_FreeTCHAR(szTitle);
if (!ok)
RETURN_ERR("CMDIChildWnd::Create");
Index: win32uioledoc.h
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uioledoc.h,v
retrieving revision 1.1
retrieving revision 1.1.4.1
diff -C2 -d -r1.1 -r1.1.4.1
*** win32uioledoc.h 1 Sep 1999 23:33:03 -0000 1.1
--- win32uioledoc.h 29 Aug 2008 05:53:30 -0000 1.1.4.1
***************
*** 12,13 ****
--- 12,24 ----
static ui_type_CObject type;
};
+
+ class PyCOleClientItem : public PyCCmdTarget {
+ protected:
+ PyCOleClientItem() {;}
+ ~PyCOleClientItem() {;}
+ public:
+ static COleClientItem *GetOleClientItem(PyObject *self);
+
+ MAKE_PY_CTOR(PyCOleClientItem);
+ static ui_type_CObject type;
+ };
\ No newline at end of file
Index: win32assoc.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32assoc.cpp,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -C2 -d -r1.9 -r1.9.2.1
*** win32assoc.cpp 24 Feb 2008 16:06:09 -0000 1.9
--- win32assoc.cpp 29 Aug 2008 05:53:29 -0000 1.9.2.1
***************
*** 28,35 ****
{
#ifdef _DEBUG
! char buf[256];
if (cacheLookups) {
// cant use TRACE, as CWinApp may no longer be valid.
! wsprintf(buf, "AssocManager cache hit ratio is %d percent\n", cacheHits * 100 / cacheLookups);
OutputDebugString(buf);
}
--- 28,35 ----
{
#ifdef _DEBUG
! TCHAR buf[256];
if (cacheLookups) {
// cant use TRACE, as CWinApp may no longer be valid.
! wsprintf(buf, _T("AssocManager cache hit ratio is %d percent\n"), cacheHits * 100 / cacheLookups);
OutputDebugString(buf);
}
***************
*** 107,115 ****
// and auto-convert it to the classes AttachedObject.
if (ui_type_check && !is_uiobject(self, ui_type_check)) {
- CString csRet = "object is not a ";
- csRet += ui_type_check->tp_name;
TRACE("GetGoodCppObject fails RTTI\n");
! const char *ret = csRet;
! RETURN_TYPE_ERR((char *)ret);
}
ui_assoc_object *s = (ui_assoc_object *)self;
--- 107,112 ----
// and auto-convert it to the classes AttachedObject.
if (ui_type_check && !is_uiobject(self, ui_type_check)) {
TRACE("GetGoodCppObject fails RTTI\n");
! return PyErr_Format(PyExc_TypeError, "object is not a %s", ui_type_check->tp_name);
}
ui_assoc_object *s = (ui_assoc_object *)self;
***************
*** 295,304 ****
{
CString csRet;
! PyObject *vi_repr = virtualInst ? PyObject_Repr(virtualInst) : NULL;
! // sprintf(buf, " - assoc is %p, vi=%s", assoc, vi_repr ? PyString_AsString(vi_repr) : "<None>" );
! csRet.Format(" - assoc is %p, vi=%s", assoc, vi_repr ? PyString_AsString(vi_repr) : "<None>" );
! Py_XDECREF(vi_repr);
return ui_base_class::repr() + csRet;
}
#ifdef _DEBUG
void ui_assoc_object::Dump( CDumpContext &dc ) const
--- 292,324 ----
{
CString csRet;
! static TCHAR *no_repr=_T("<None>");
! TCHAR *py_repr=NULL;
! BOOL bfree_repr=FALSE;
!
! if (virtualInst == NULL)
! py_repr=no_repr;
! else
! py_repr=_T("??? some object ???");
! // else{
! /* PyObject_Repr or PyObject_Str will cause an infinite loop here, since subclasses will inherit
! *this* repr if they don't define __repr__,
! */
! /*
! PyObject *vi_repr=PyObject_Str(virtualInst);
! if (vi_repr==NULL || !PyWinObject_AsTCHAR(vi_repr, &py_repr, FALSE)){
! PyErr_Clear();
! py_repr=no_repr;
! }
! else
! bfree_repr=TRUE;
! Py_XDECREF(vi_repr);
! }
! */
! csRet.Format(_T(" - assoc is %p, vi=%s"), assoc, py_repr);
! if (bfree_repr)
! PyWinObject_FreeTCHAR(py_repr);
return ui_base_class::repr() + csRet;
}
+
#ifdef _DEBUG
void ui_assoc_object::Dump( CDumpContext &dc ) const
Index: win32ctrlRichEdit.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32ctrlRichEdit.cpp,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -d -r1.4 -r1.4.2.1
*** win32ctrlRichEdit.cpp 3 Jun 2007 12:35:58 -0000 1.4
--- win32ctrlRichEdit.cpp 29 Aug 2008 05:53:29 -0000 1.4.2.1
***************
*** 424,428 ****
// and handle worst case, and look what happens!
CString csBuffer; // use dynamic mem for buffer
! char *buf;
int bytesCopied;
// this TRACE _always_ returns the length of the first line - hence the
--- 424,428 ----
// and handle worst case, and look what happens!
CString csBuffer; // use dynamic mem for buffer
! TCHAR *buf;
int bytesCopied;
// this TRACE _always_ returns the length of the first line - hence the
***************
*** 450,454 ****
// --bytesCopied;
buf[bytesCopied] = '\0';
! return Py_BuildValue("s",buf);
}
--- 450,454 ----
// --bytesCopied;
buf[bytesCopied] = '\0';
! return PyWinObject_FromTCHAR(buf);
}
***************
*** 470,480 ****
{
CRichEditCtrl *pEdit = GetRichEditCtrl(self);
! char *msg;
// @pyparm string|text||The text to replace the selection with.
! if (!pEdit || !PyArg_ParseTuple(args, "s:ReplaceSel", &msg))
return NULL;
GUI_BGN_SAVE;
pEdit->ReplaceSel(msg); // @pyseemfc CRichEditCtrl|ReplaceSel
GUI_END_SAVE;
RETURN_NONE;
}
--- 470,484 ----
{
CRichEditCtrl *pEdit = GetRichEditCtrl(self);
! TCHAR *msg;
! PyObject *obmsg;
// @pyparm string|text||The text to replace the selection with.
! if (!pEdit
! || !PyArg_ParseTuple(args, "O:ReplaceSel", &obmsg)
! || !PyWinObject_AsTCHAR(obmsg, &msg, FALSE))
return NULL;
GUI_BGN_SAVE;
pEdit->ReplaceSel(msg); // @pyseemfc CRichEditCtrl|ReplaceSel
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(msg);
RETURN_NONE;
}
Index: win32view.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32view.cpp,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -C2 -d -r1.4 -r1.4.2.1
*** win32view.cpp 14 Feb 2008 19:05:23 -0000 1.4
--- win32view.cpp 29 Aug 2008 05:53:30 -0000 1.4.2.1
***************
*** 186,191 ****
return NULL;
- PyErr_Clear();
CView *pActivate = obActivate==Py_None ? NULL : PyCView::GetViewPtr (obActivate);
CView *pDevactive = obDeactivate==Py_None ? NULL : PyCView::GetViewPtr (obDeactivate);
if (PyErr_Occurred())
--- 186,192 ----
return NULL;
CView *pActivate = obActivate==Py_None ? NULL : PyCView::GetViewPtr (obActivate);
+ if (PyErr_Occurred())
+ return NULL;
CView *pDevactive = obDeactivate==Py_None ? NULL : PyCView::GetViewPtr (obDeactivate);
if (PyErr_Occurred())
***************
*** 640,649 ****
{
PyObject *doc;
! char *szClass;
int style=0;
// @pyparm <o PyCDocument>|doc||The document.
// @pyparm string|className||The class name of the control
// @pyparm int|style|0|Additional style bits
! if (!PyArg_ParseTuple(args, "Os|i:CreateCtrlView", &doc, &szClass, &style))
return NULL;
if (!ui_base_class::is_uiobject(doc, &PyCDocument::type))
--- 641,651 ----
{
PyObject *doc;
! TCHAR *szClass;
! PyObject *obClass;
int style=0;
// @pyparm <o PyCDocument>|doc||The document.
// @pyparm string|className||The class name of the control
// @pyparm int|style|0|Additional style bits
! if (!PyArg_ParseTuple(args, "OO|i:CreateCtrlView", &doc, &obClass, &style))
return NULL;
if (!ui_base_class::is_uiobject(doc, &PyCDocument::type))
***************
*** 651,658 ****
--- 653,663 ----
CDocument *pDoc = PyCDocument::GetDoc( doc );
CCtrlView *pView;
+ if (!PyWinObject_AsTCHAR(obClass, &szClass, FALSE))
+ return NULL;
GUI_BGN_SAVE;
pView = new CPythonCtrlView(szClass, style);
((CProtectedView *)pView)->SetDocument(pDoc);
GUI_END_SAVE;
+ PyWinObject_FreeTCHAR(szClass);
return ui_assoc_object::make( PyCCtrlView::type, pView, TRUE );
}
***************
*** 682,686 ****
GET_PY_CTOR(PyCCtrlView));
! /* Implement an psuedo-inheritance for ControlView */
PyObject *
PyCCtrlView::getattr(char *name)
--- 687,692 ----
GET_PY_CTOR(PyCCtrlView));
! /* Inheritance from PyCView and control type is now done via tp_bases */
! /*
PyObject *
PyCCtrlView::getattr(char *name)
***************
*** 696,699 ****
--- 702,706 ----
return retMethod;
}
+ */
/////////////////////////////////////////////////////////////////////
***************
*** 766,772 ****
ui_edit_window_load_file(PyObject *self, PyObject *args)
{
! char *fileName;
// @pyparm string|fileName||The name of the file to be loaded.
! if (!PyArg_ParseTuple(args, "s:LoadFile", &fileName))
return NULL;
--- 773,781 ----
ui_edit_window_load_file(PyObject *self, PyObject *args)
{
! USES_CONVERSION;
! TCHAR *fileName;
! PyObject *obfileName;
// @pyparm string|fileName||The name of the file to be loaded.
! if (!PyArg_ParseTuple(args, "O:LoadFile", &obfileName))
return NULL;
***************
*** 774,789 ****
if (!(pView=GetEditViewPtr(self)))
return NULL;
!
CFile file;
CFileException fe;
if (!file.Open(fileName, CFile::modeRead | CFile::shareDenyWrite, &fe)) {
long errCode = fe.m_lOsError;
CString csMessage = GetAPIErrorString(errCode);
! if (csMessage.GetLength())
! PyErr_SetString(PyExc_IOError, (char *)(const char *)csMessage);
else
PyErr_SetString(PyExc_IOError, "Unknown IO error?");
return NULL;
}
GUI_BGN_SAVE;
pView->DeleteContents();
--- 783,805 ----
if (!(pView=GetEditViewPtr(self)))
return NULL;
! if (!PyWinObject_AsTCHAR(obfileName, &fileName, FALSE))
! return NULL;
CFile file;
CFileException fe;
if (!file.Open(fileName, CFile::modeRead | CFile::shareDenyWrite, &fe)) {
+ PyWinObject_FreeTCHAR(fileName);
long errCode = fe.m_lOsError;
CString csMessage = GetAPIErrorString(errCode);
! if (csMessage.GetLength()){
! LPTSTR msg=csMessage.GetBuffer(csMessage.GetLength());
! PyErr_SetString(PyExc_IOError, T2A(msg));
! csMessage.ReleaseBuffer();
! }
else
PyErr_SetString(PyExc_IOError, "Unknown IO error?");
return NULL;
}
+ PyWinObject_FreeTCHAR(fileName);
+
GUI_BGN_SAVE;
pView->DeleteContents();
***************
*** 819,825 ****
ui_edit_window_save_file(PyObject *self, PyObject *args)
{
! char *fileName;
// @pyparm string|fileName||The name of the file to be written.
! if (!PyArg_ParseTuple(args, "s:SaveFile", &fileName))
return NULL;
--- 835,843 ----
ui_edit_window_save_file(PyObject *self, PyObject *args)
{
! USES_CONVERSION;
! TCHAR *fileName;
! PyObject *obfileName;
// @pyparm string|fileName||The name of the file to be written.
! if (!PyArg_ParseTuple(args, "O:SaveFile", &obfileName))
return NULL;
***************
*** 828,840 ****
return NULL;
CFile file;
CFileException fe;
-
if (!file.Open(fileName, CFile::modeCreate |
CFile::modeReadWrite | CFile::shareExclusive, &fe)) {
long errCode = fe.m_lOsError;
CString csMessage = GetAPIErrorString(errCode);
! if (csMessage.GetLength())
! PyErr_SetString(PyExc_IOError, (char *)(const char *)csMessage);
else
PyErr_SetString(PyExc_IOError, "Unknown IO error?");
--- 846,862 ----
return NULL;
+ if (!PyWinObject_AsTCHAR(obfileName, &fileName, FALSE))
+ return NULL;
CFile file;
CFileException fe;
if (!file.Open(fileName, CFile::modeCreate |
CFile::modeReadWrite | CFile::shareExclusive, &fe)) {
long errCode = fe.m_lOsError;
CString csMessage = GetAPIErrorString(errCode);
! if (csMessage.GetLength()){
! LPTSTR msg=csMessage.GetBuffer(csMessage.GetLength());
! PyErr_SetString(PyExc_IOError, T2A(msg));
! csMessage.ReleaseBuffer();
! }
else
PyErr_SetString(PyExc_IOError, "Unknown IO error?");
***************
*** 865,868 ****
--- 887,891 ----
if (pDocument)
pDocument->SetModifiedFlag(FALSE); // start off with unmodified
+ PyWinObject_FreeTCHAR(fileName);
GUI_END_SAVE;
RETURN_NONE;
***************
*** 997,1001 ****
PyCCtrlView_Type PyCListView::type("PyCListView",
&PyCCtrlView::type, // @base PyCListView|PyCCtrlView
! &PyCListCtrl::type,
RUNTIME_CLASS(CListView),
sizeof(PyCListView),
--- 1020,1024 ----
PyCCtrlView_Type PyCListView::type("PyCListView",
&PyCCtrlView::type, // @base PyCListView|PyCCtrlView
! &PyCListCtrl::type, // ??? need to add this to tp_bases so PyCListView inherits PyCListCtrl methods ???
RUNTIME_CLASS(CListView),
sizeof(PyCListView),
***************
*** 1096,1123 ****
PyObject * PyCFormView::create(PyObject *self, PyObject *args)
{
! PyObject *doc;
! char *szTemplate = NULL;
! int iTemplate;
// @pyparm <o PyCDocument>|doc||The document to use with the view.
! // @pyparm int|iTemplate||The ID of the dialog control.
! if (!PyArg_ParseTuple(args, "Oi:CreateFormView", &doc, &iTemplate)) {
! PyErr_Clear();
! // @pyparmalt1 <o PyCDocument>|doc||The document to use with the view.
! // @pyparmalt1 string|template||The ID of the dialog control.
! if (!PyArg_ParseTuple(args, "Os:CreateFormView", &doc, &szTemplate))
! return NULL;
! }
if (!ui_base_class::is_uiobject(doc, &PyCDocument::type))
RETURN_TYPE_ERR("Argument must be a PyCDocument");
CDocument *pDoc = PyCDocument::GetDoc( doc );
CFormView *pView;
! GUI_BGN_SAVE;
! if (szTemplate)
! pView = new CPythonFormView(szTemplate);
else
! pView = new CPythonFormView(iTemplate);
((CProtectedView *)pView)->SetDocument(pDoc);
GUI_END_SAVE;
return ui_assoc_object::make( PyCFormView::type, pView, TRUE );
}
--- 1119,1144 ----
PyObject * PyCFormView::create(PyObject *self, PyObject *args)
{
! PyObject *doc, *obTemplate;
! TCHAR *szTemplate = NULL;
// @pyparm <o PyCDocument>|doc||The document to use with the view.
! // @pyparm int/str|Template||Name or ID of the dialog template resource
! if (!PyArg_ParseTuple(args, "OO:CreateFormView", &doc, &obTemplate))
! return NULL;
!
if (!ui_base_class::is_uiobject(doc, &PyCDocument::type))
RETURN_TYPE_ERR("Argument must be a PyCDocument");
CDocument *pDoc = PyCDocument::GetDoc( doc );
CFormView *pView;
! if (!PyWinObject_AsResourceId(obTemplate, &szTemplate))
! return NULL;
! GUI_BGN_SAVE;
! if (IS_INTRESOURCE(szTemplate))
! pView = new CPythonFormView(MAKEINTRESOURCE(szTemplate));
else
! pView = new CPythonFormView(szTemplate);
((CProtectedView *)pView)->SetDocument(pDoc);
GUI_END_SAVE;
+ PyWinObject_FreeResourceId(szTemplate);
return ui_assoc_object::make( PyCFormView::type, pView, TRUE );
}
Index: win32dlg.cpp
===================================================================
RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32dlg.cpp,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -C2 -d -r1.10 -r1.10.2.1
*** win32dlg.cpp 12 Feb 2008 19:26:13 -0000 1.10
--- win32dlg.cpp 29 Aug 2008 05:53:29 -0000 1.10.2.1
***************
*** 87,97 ****
if (hGlob==NULL)
RETURN_API_ERR("LoadResource");
-
- CDialog *pDlg = new CPythonDlg();
- PyCDialog *ret = (PyCDialog *)ui_assoc_object::make( PyCDialog::type, pDlg, TRUE);
- if (ret) {
- ret->hTemplate = hGlob;
- ret->hInstance = hMod;
- }
return MakeDlgListFromResource(hGlob);
}
--- 87,90 ----
***************
*** 199,214 ****
}
PyObject *
! PyCDialog::getattr(char *name)
{
if (strcmp(name,"data")==0) {
Py_INCREF(dddict);
return dddict;
! }
! else if (strcmp(name,"datalist")==0) {
Py_INCREF(ddlist);
return ddlist;
! }
! else
! return ui_base_class::getattr(name);
}
--- 192,207 ----
}
PyObject *
! PyCDialog::getattro(PyObject *obname)
{
+ char *name=PYWIN_ATTR_CONVERT(obname);
if (strcmp(name,"data")==0) {
Py_INCREF(dddict);
return dddict;
! }
! if (strcmp(name,"datalist")==0) {
Py_INCREF(ddlist);
return ddlist;
! }
! return PyObject_GenericGetAttr(this, obname);
}
***************
*** 216,220 ****
{
static char errBuf[256];
! wsprintf(errBuf, "Data exchange list index %d - %s", index, msg);
PyErr_SetString(PyExc_TypeError,errBuf);
return NULL;
--- 209,213 ----
{
static char errBuf[256];
! snprintf(errBuf, 256, "Data exchange list index %d - %s", index, msg);
PyErr_SetString(PyExc_TypeError,errBuf);
return NULL;
***************
*** 242,249 ****
}
case 's': {
! char *strVal = NULL;
! if (oldVal && PyString_Check(oldVal))
! strVal = PyString_AsString(oldVal);
! CString csVal(strVal?strVal:"");
GUI_BGN_SAVE;
DDX_Text(pDX, id, csVal);
--- 235,248 ----
}
case 's': {
! CString csVal;
! TCHAR *strVal = NULL;
! if (PyWinObject_AsTCHAR(oldVal, &strVal, TRUE)){
! csVal=strVal;
! PyWinObject_FreeTCHAR(strVal);
! }
! else{
! PyErr_Clear();
! csVal=_T("");
! }
GUI_BGN_SAVE;
DDX_Text(pDX, id, csVal);
***************
*** 255,259 ****
return set_exchange_error("Edit - must be tuple of control_id, key, 's', maxLength", index);
}
! newOb = Py_BuildValue("s", (const char *)csVal);
break;
}
--- 254,258 ----
return set_exchange_error("Edit - must be tuple of control_id, key, 's', maxLength", index);
}
! newOb = PyWinObject_FromTCHAR(csVal);
break;
}
***************
*** 290,299 ****
}
case 's': {
! char *strVal = NULL;
! if (oldVal && oldVal != Py_None) {
! if (!PyString_Check(oldVal)) return set_exchange_error("'s' format requires strings", index);
! strVal = PyString_AsString(oldVal);
! }
! CString csVal(strVal?strVal:"");
GUI_BGN_SAVE;
if (bList)
--- 289,298 ----
}
case 's': {
! TCHAR *strVal = NULL;
! if (!PyWinObject_AsTCHAR(oldVal, &strVal, TRUE))
! return set_exchange_error("'s' format requires strings", index);
! CString csVal(strVal ? strVal : _T(""));
! PyWinObject_FreeTCHAR(strVal);
!
GUI_BGN_SAVE;
if (bList)
***************
*** 302,315 ****
DDX_CBString(pDX, id, csVal);
GUI_END_SAVE;
! newOb = Py_BuildValue("s", (const char *)csVal);
break;
}
case 'S': {
! char *strVal = NULL;
! if (oldVal && oldVal != Py_None) {
! if (!PyString_Check(oldVal)) return set_exchange_error("'S' format requires strings", index);
! strVal = PyString_AsString(oldVal);
! }
! CString csVal(strVal?strVal:"");
GUI_BGN_SAVE;
if (bList)
--- 301,313 ----
DDX_CBString(pDX, id, csVal);
GUI_END_SAVE;
! newOb = PyWinObject_FromTCHAR(csVal);
break;
}
case 'S': {
! TCHAR *strVal = NULL;
! if (!PyWinObject_AsTCHAR(oldVal, &strVal, TRUE))
! return set_exchange_error("'S' form...
[truncated message content] |