Michael Morisak schrieb: > Hi > > > I have the following Situation: > > I have a dialog resource in an dll and I want to open a modal dialog > with this resource. > > dlg= pywin.mfc.dialog.Dialog(myDialogID) > dlg.DoModal() > > works but the problem is that i would set the Parent of the Dialog > in MFC the CDialog Constructor allows to pass a Parent (which i need): > > explicit CDialog( > UINT /nIDTemplate/, > CWnd* /pParentWnd/ = NULL > ); > > but i really do not know how to do this with python-win32 > > thanx for the help and the great work done in python.win32 > > c.u. > > > > ok i could fix this by opening the dialog in my C++ extension and writing the whole dialog in c++
but now a have a different problem when I did the dialog in c++ i found out that in my case the dialog only works if I add AFX_MANAGE_STATE(AfxGetStaticModuleState()); so i opened the dialog the following way: static PyObject* createConnectOptionsDlg(PyObject *self, PyObject *args) { HWND hwnd; PyObject* settings; CWnd* parent; CDialog* dlg; AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (!PyArg_ParseTuple(args,"iO",&hwnd,&settings)) return NULL; parent= CWnd::FromHandle(hwnd); dlg= new CConnectOptionsDlg(parent,settings); int res= dlg->DoModal(); delete dlg; return Py_BuildValue("i", res); } w0rks fine :) I found out that I need this AFX_MANAGE_STATE(AfxGetStaticModuleState()); because it is a python c++ extension which is used in an ComObject I created in python which is some automation for SolidEdge I read in the article (sorry only in german): http://www.hki.uni-koeln.de/teach/ss06/PS_C++/tag23/21/kap17.htm that if you do mfc stuff in an dll you need to add AFX_MANAGE_STATE(AfxGetStaticModuleState()) to every exported function that uses MFC This information really helped me a lot! After adding this line it started working (SolidEdge did not crash anymore) Now I have a different situation: I need to do the following lines: self.dlg = win32ui.CreateDialog(SolidEdge.PySolidEdge.IDD_LayerStyle) self.dlg.CreateWindow(self.pagewin) self.dlg.ShowWindow(win32con.SW_SHOWNORMAL) self.dlg.HookMessage(self.layerListSelChangeMsgHandler, win32con.WM_COMMAND) the problem is that in principle this works fine but SolidEdge crashes after CreateWindow My suspicion is that i need: AFX_MANAGE_STATE(AfxGetStaticModuleState()) in CreateWindow i tried to add this to the source of python-win32 but i refuses to compile with some link issue Does anybody know what i could do about this problem I do not want to write this whole dlg in c++ since i would have to do a lot of COM in this dialog then thx Michael -- Michael Morisak RISC Software GmbH -- Johannes Kepler Universitaet Linz IT-Center, Hauptstrasse 119 phone: ++43 7236 3343-251 4232 Hagenberg, Austria fax: ++43 7236 3343-250 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32