Exemplo n.º 1
0
// @pymethod |PyCDialogBar|CreateWindow|Creates the window for the <o PyCDialogBar> object.
static PyObject *PyCDialogBar_CreateWindow(PyObject *self, PyObject *args)
{
	TCHAR *szTemplate;
	UINT style, id;
	PyObject *obParent, *obTemplate;
	// @pyparm <o PyCWnd>|parent||The parent window
	// @pyparm <o PyResourceId>|template||Template name or integer resource id
	// @pyparm int|style||The style for the window
	// @pyparm int|id||The ID of the window
    if (!PyArg_ParseTuple(args, "OOii", &obParent, &obTemplate, &style, &id))
		return NULL;

    CDialogBar *pDialog = PyCDialogBar::GetDialogBar(self);
    if (pDialog==NULL) return NULL;
	CWnd *pParent = NULL;
	if (obParent != Py_None) {
		pParent = PyCWnd::GetPythonGenericWnd(obParent, &PyCWnd::type);
		if (pParent==NULL)
			RETURN_TYPE_ERR("The parent window is not a valid PyCWnd");
	}
	if (!PyWinObject_AsResourceId(obTemplate, &szTemplate, FALSE))
		return NULL;
	BOOL rc;
    GUI_BGN_SAVE;
    if (IS_INTRESOURCE(szTemplate))
		rc=pDialog->Create(pParent, MAKEINTRESOURCE(szTemplate), style, id);
	else
        rc=pDialog->Create(pParent, szTemplate, style, id);
    GUI_END_SAVE;
	PyWinObject_FreeResourceId(szTemplate);
	if (!rc)
        RETURN_ERR("CDialogBar::Create failed");
    RETURN_NONE;
}
Exemplo n.º 2
0
// @pymethod <o PyCPropertyPage>|win32ui|CreatePropertyPage|Creates a property page object.
PyObject *PyCPropertyPage::create( PyObject *self, PyObject *args )
{
	TCHAR *Template=NULL;
	PyObject *obTemplate = NULL;
	int idCaption = 0;
	if (!PyArg_ParseTuple(args,"O|i", 
		&obTemplate, // @pyparm <o PyResourceId>|resource||String template name or inteter resource ID to use for the page.
		&idCaption)) // @pyparm int|caption|0|The ID if the string resource to use for the caption.
		return NULL;
	CPythonPropertyPage *pPP;
	if (!PyWinObject_AsResourceId(obTemplate, &Template, FALSE))
		return NULL;

	if (IS_INTRESOURCE(Template)){
		if (!PropSheetCheckForPageCreate((UINT)Template))
			return NULL;
		GUI_BGN_SAVE;
		pPP = new CPythonPropertyPage((UINT)Template, idCaption);
		GUI_END_SAVE;
		}
	else{
		if (!PropSheetCheckForPageCreate(Template))
			return NULL;
		GUI_BGN_SAVE;
		pPP = new CPythonPropertyPage(Template, idCaption);
		GUI_END_SAVE;
	}
	PyWinObject_FreeResourceId(Template);
	PyCPropertyPage *ret = (PyCPropertyPage *)ui_assoc_object::make( PyCPropertyPage::type, pPP);
	return ret;
}
Exemplo n.º 3
0
// @pymethod <o PyCPropertySheet>|win32ui|CreatePropertySheet|Creates a property sheet object.
PyObject *PyCPropertySheet::create( PyObject *self, PyObject *args )
{
	PyObject 	*obParent = NULL,
			*obCaption;
	TCHAR *Caption;
	CWnd *pParent = NULL;
	int iSelect = 0;
	if (!PyArg_ParseTuple(args,"O|Oi", 
	          &obCaption, // @pyparm <o PyResourceId>|caption||The caption for the property sheet, or id of the caption
	          &obParent,  // @pyparm <o PyCWnd>|parent|None|The parent window of the property sheet.
	          &iSelect))  // @pyparm int|select|0|The index of the first page to be selected.
		return NULL;
	if (obParent) {
		if (!ui_base_class::is_uiobject(obParent, &PyCWnd::type))
			RETURN_TYPE_ERR("parameter 2 must be a PyCWnd object");
  		pParent = (CWnd *)PyCWnd::GetPythonGenericWnd(obParent);
	}
	CPythonPropertySheet *pPS;
	if (!PyWinObject_AsResourceId(obCaption, &Caption, FALSE))
		return NULL;

	if (IS_INTRESOURCE(Caption)){
		GUI_BGN_SAVE;
		pPS = new CPythonPropertySheet(MAKEINTRESOURCE(Caption), pParent, iSelect);
		GUI_END_SAVE;
	}
	else{
		GUI_BGN_SAVE;
		pPS = new CPythonPropertySheet(Caption, pParent, iSelect);
		GUI_END_SAVE;
	}
	PyWinObject_FreeResourceId(Caption);
	PyCPropertySheet *ret = (PyCPropertySheet *)ui_assoc_object::make( PyCPropertySheet::type, pPS);
	return ret;
}
Exemplo n.º 4
0
// @pymethod int|PyCWinApp|LoadStandardCursor|Loads a standard cursor.
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");
	return PyWinLong_FromHANDLE(hc);
}
Exemplo n.º 5
0
// @pymethod int|win32ui|CreateImageList|Creates an image list.
PyObject *PyCImageList_Create( PyObject *self, PyObject *args )
{
	int cx, cy, nInitial, nGrow;
	COLORREF crMask;
	BOOL bMask;
	CImageList *pList = new PythonImageList();

	if (PyArg_ParseTuple(args, "iiiii", 
			&cx, // @pyparm int|cx||Dimension of each image, in pixels.
			&cy, // @pyparm int|cy||Dimension of each image, in pixels.
			&bMask, // @pyparm int|mask||TRUE if the image contains a mask; otherwise FALSE.
			&nInitial, // @pyparm int|initial||Number of images that the image list initially contains.
			&nGrow)){ // @pyparm int|grow||Number of images by which the image list can grow when the system needs to resize the list to make room for new images. This parameter represents the number of new images the resized image list can contain.
		if (pList->Create(cx, cy, bMask, nInitial, nGrow))
			return ui_assoc_object::make( PyCImageList::type, pList )->GetGoodRet();
		GUI_BGN_SAVE;
		delete pList;
		GUI_END_SAVE;
		RETURN_ERR("PyCImage::Create failed");
		}

	PyErr_Clear();
	BOOL bRet;
	PyObject *obID;
	TCHAR *bitmapID=NULL;
	if (PyArg_ParseTuple(args, "Oiii", 
			&obID, // @pyparmalt1 <o PyResourceId>|bitmapId||Resource name or ID of the bitmap to be associated with the image list.
			&cx, // @pyparmalt1 int|cx||Dimension of each image, in pixels.
			&nGrow, // @pyparmalt1 int|grow||Number of images by which the image list can grow when the system needs to resize the list to make room for new images. This parameter represents the number of new images the resized image list can contain.
			&crMask) // @pyparmalt1 int|crMask||Color used to generate a mask. Each pixel of this color in the specified bitmap is changed to black, and the corresponding bit in the mask is set to one.
		&&PyWinObject_AsResourceId(obID, &bitmapID, FALSE)){
		if (IS_INTRESOURCE(bitmapID))
			bRet = pList->Create(MAKEINTRESOURCE(bitmapID),cx,nGrow,crMask);
		else
			bRet = pList->Create(bitmapID,cx,nGrow,crMask);
		PyWinObject_FreeResourceId(bitmapID);
		if (bRet)
			return ui_assoc_object::make( PyCImageList::type, pList )->GetGoodRet();
		else
			PyErr_SetString(ui_module_error, "PyCImage::Create failed");
		}
	GUI_BGN_SAVE;
	delete pList;
	GUI_END_SAVE;
	return NULL;
}
Exemplo n.º 6
0
// @pymethod int|PyCWinApp|LoadStandardIcon|Loads an icon resource.
static PyObject *
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);
}