// @pymethod |PyCToolTipCtrl|CreateWindow|Creates the actual control. static PyObject * PyCToolTipCtrl_create_window(PyObject *self, PyObject *args) { int style; PyObject *obParent; if (!PyArg_ParseTuple(args, "Oi:CreateWindow", &obParent, // @pyparm <o PyCWnd>|parent||The parent window of the control. &style)) // @pyparm int|style||The style for the control. return NULL; if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type)) RETURN_TYPE_ERR("parent argument must be a window object"); CWnd *pParent = GetWndPtr( obParent ); if (pParent==NULL) return NULL; CToolTipCtrl *pTTC = GetToolTipCtrl(self); if (!pTTC) return NULL; BOOL ok; GUI_BGN_SAVE; ok = pTTC->Create(pParent,style); GUI_END_SAVE; if (!ok) RETURN_ERR("CToolTipCtrl::Create"); RETURN_NONE; }
// @pymethod |PyCToolTipCtrl|UpdateTipText|Update the tool tip text for a control's tools static PyObject * PyCToolTipCtrl_update_tip_text(PyObject *self, PyObject *args) { PyObject *obWnd; TCHAR *pszText; PyObject *obText; UINT nIDTool; if (!PyArg_ParseTuple(args, "OOi:UpdateTipText", &obText,// @pyparm string|text||The text for the tool. &obWnd, // @pyparm <o PyCWnd>|wnd||The window of the tool. &nIDTool// @pyparm int|id||The id of the tool )) return NULL; CWnd *pWndToolOwner = NULL; if (obWnd != Py_None) { if (!ui_base_class::is_uiobject(obWnd,&PyCWnd::type)) RETURN_TYPE_ERR("wnd argument must be a window object"); pWndToolOwner = GetWndPtr(obWnd); if (pWndToolOwner==NULL) RETURN_TYPE_ERR("The window is not a valid PyCWnd"); } CToolTipCtrl *pTTC = GetToolTipCtrl(self); if (!pTTC)return NULL; if (!PyWinObject_AsTCHAR(obText, &pszText, FALSE)) return NULL; GUI_BGN_SAVE; pTTC->UpdateTipText(pszText,pWndToolOwner,nIDTool); GUI_END_SAVE; PyWinObject_FreeTCHAR(pszText); RETURN_NONE; }
// @pymethod |PyCEdit|CreateWindow|Creates the window for a new Edit object. static PyObject * PyCEdit_create_window(PyObject *self, PyObject *args) { int style, id; PyObject *obParent; RECT rect; if (!PyArg_ParseTuple(args, "i(iiii)Oi:CreateWindow", &style, // @pyparm int|style||The style for the Edit. Use any of the win32con.BS_* constants. &rect.left,&rect.top,&rect.right,&rect.bottom, // @pyparm (left, top, right, bottom)|rect||The size and position of the Edit. &obParent, // @pyparm <o PyCWnd>|parent||The parent window of the Edit. Usually a <o PyCDialog>. &id )) // @pyparm int|id||The Edits control ID. return NULL; if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type)) RETURN_TYPE_ERR("parent argument must be a window object"); CWnd *pParent = GetWndPtr( obParent ); if (pParent==NULL) return NULL; CEdit *pEdit = GetEditCtrl(self); if (!pEdit) return NULL; BOOL ok; GUI_BGN_SAVE; ok = pEdit->Create(style, rect, pParent, id ); GUI_END_SAVE; if (!ok) RETURN_ERR("CEdit::Create"); RETURN_NONE; }
// @pymethod |PyCToolTipCtrl|AddTool|Adds a tool to tooltip control. static PyObject * PyCToolTipCtrl_add_tool(PyObject *self, PyObject *args) { PyObject *obWnd,*obRect; TCHAR *pszText; PyObject *obText; UINT nIDTool; if (!PyArg_ParseTuple(args, "OOOi:CreateWindow", &obWnd, // @pyparm <o PyCWnd>|wnd||The window of the tool. &obText,// @pyparm string|text||The text for the tool. &obRect, // @pyparm int, int, int, int|rect|None|The default rectangle &nIDTool// @pyparm int|id||The id of the tool )) return NULL; CWnd *pWnd = NULL; if (obWnd != Py_None) { if (!ui_base_class::is_uiobject(obWnd,&PyCWnd::type)) RETURN_TYPE_ERR("wnd argument must be a window object"); pWnd = GetWndPtr(obWnd); if (pWnd==NULL) RETURN_TYPE_ERR("The window is not a valid PyCWnd"); } RECT rect; RECT *pRectTool=NULL; 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)"); } pRectTool=▭ } CToolTipCtrl *pTTC = GetToolTipCtrl(self); if (!pTTC)return NULL; if (!PyWinObject_AsTCHAR(obText, &pszText, FALSE)) return NULL; GUI_BGN_SAVE; BOOL ok=pTTC->AddTool(pWnd,pszText,pRectTool,nIDTool); GUI_END_SAVE; PyWinObject_FreeTCHAR(pszText); if (!ok) RETURN_ERR("CToolTipCtrl::AddTool"); RETURN_NONE; }
// @pymethod |PyCMenu|TrackPopupMenu|Creates a popup menu anywhere on the screen. PyObject *PyCMenu::TrackPopupMenu(PyObject *self, PyObject *args) { // @comm The TrackPopupMenu function displays a floating pop-up menu at the // specified location and tracks the selection of items on the pop-up menu. // The floating pop-up menu can appear anywhere on the screen. HMENU hMenu = GetMenu( self ); if (!hMenu) return NULL; HWND hTarget; PyObject *wndObject = NULL; int flags=TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON; int x,y; if (!PyArg_ParseTuple(args,"(ii)|iO", &x, &y, // @pyparm (int, int)|(x,y)||The position for the menu.. &flags, // @pyparm int|flags|win32con.TPM_LEFTALIGN\|win32con.TPM_LEFTBUTTON\|win32con.TPM_RIGHTBUTTON|Flags for the menu. &wndObject)) // @pyparm <o PyCWnd>|owner|(main application frame)|The owner of the menu. return NULL; if (wndObject) { CWnd *wnd=GetWndPtr(wndObject); if (wnd==NULL) return NULL; hTarget = wnd->m_hWnd; } else { CWinApp *pApp = GetApp(); if (!pApp) return NULL; hTarget=pApp->m_pMainWnd->GetSafeHwnd(); } GUI_BGN_SAVE; BOOL rc = ::TrackPopupMenu(hMenu,flags,x,y,0,hTarget,NULL); GUI_END_SAVE; // @rdesc If the underlying MFC function fails, but TPM_RETURNCMD is set in the flags parameter, then None is returned instead of the normal exception. if (!rc) { if (flags & TPM_RETURNCMD) { RETURN_NONE; } else { RETURN_API_ERR("TrackPopupMenu"); } } return Py_BuildValue("i",rc); }
// @pymethod |PyCWinThread|SetMainFrame|Sets the threads main frame static PyObject * ui_thread_set_main_frame(PyObject *self, PyObject *args) { PyObject *wndObject; if (!PyArg_ParseTuple(args, "O:SetMainFrame", &wndObject )) // @pyparm <o PyCWnd>|mainFrame||The applications main frame. return NULL; CWinThread *pThread = GetCWinThreadPtr(self); if (!pThread) return NULL; if (wndObject==Py_None) { // @comm You can pass None to this function to reset the main frame. pThread->m_pMainWnd = NULL; // Should I free this? I dont think so! } else { CWnd *pMainWnd = GetWndPtr(wndObject); if (!pMainWnd) return NULL; pThread->m_pMainWnd = pMainWnd; } RETURN_NONE; }
// @pymethod <o PyIDispatch>|win32uiole|GetIDispatchForWindow|Gets an OCX IDispatch pointer, if the window has one! static PyObject * win32uiole_GetIDispatchForWindow(PyObject *self, PyObject *args) { PyObject *obWnd; if (!PyArg_ParseTuple(args, "O:GetIDispatchForWindow", &obWnd)) return NULL; WndHack *pWnd = (WndHack *)GetWndPtr(obWnd); if (!pWnd) return NULL; COleControlSite *pSite = pWnd->GetCtrlSite(); if (pSite==NULL || pSite->m_pObject==NULL) { RETURN_ERR("There is no OLE object available"); } IDispatch *disp = NULL; GUI_BGN_SAVE; SCODE sc = pSite->m_pObject->QueryInterface(IID_IDispatch, (void**)&disp); GUI_END_SAVE; if (FAILED(sc) || disp == NULL) RETURN_ERR("The OLE object does not support IDispatch"); return PyCom_PyObjectFromIUnknown(disp, IID_IDispatch, FALSE); }