Example #1
0
// @pymethod int|PyIShellBrowser|SendControlMsg|Sends a control msg to browser's toolbar or status bar
PyObject *PyIShellBrowser::SendControlMsg(PyObject *self, PyObject *args)
{
	IShellBrowser *pISB = GetI(self);
	if ( pISB == NULL )
		return NULL;
	// @pyparm int|id||shellcon.FCW_TOOLBAR or FCW_STATUS
	// @pyparm int|uMsg||The message to send
	// @pyparm int|wParam||Value is dependent on the message
	// @pyparm long|lParam||Value is dependent on the message
	UINT id;
	UINT uMsg;
	PyObject *obwparam, *oblparam;
	if ( !PyArg_ParseTuple(args, "IIOO:SendControlMsg", &id, &uMsg, &obwparam, &oblparam) )
		return NULL;
	WPARAM wParam;
	LPARAM lParam;
	if (!PyWinObject_AsPARAM(obwparam, &wParam))
		return NULL;
	// WPARAM and LPARAM are defined as UINT_PTR and LONG_PTR, so they can't be used interchangeably without a cast
	if (!PyWinObject_AsPARAM(oblparam, (WPARAM *)&lParam))
		return NULL;
	
	HRESULT hr;
	LRESULT ret;
	PY_INTERFACE_PRECALL;
	hr = pISB->SendControlMsg( id, uMsg, wParam, lParam, &ret );
	PY_INTERFACE_POSTCALL;
	if ( FAILED(hr) )
		return PyCom_BuildPyException(hr, pISB, IID_IShellBrowser );
	// LRESULT is defined as LONG_PTR.  This should work for either 32 or 64 bit.
	return PyLong_FromLongLong(ret);
}
Example #2
0
// @object PyMSG|A tuple representing a win32 MSG structure.
BOOL PyWinObject_AsMSG(PyObject *ob, MSG *pMsg)
{
	PyObject *obhwnd, *obwParam, *oblParam;
	if (!PyArg_ParseTuple(ob, "OiOOi(ii):MSG param",
			&obhwnd, // @tupleitem 0|<o PyHANDLE>|hwnd|Handle to the window whose window procedure receives the message.
			&pMsg->message, // @tupleitem 1|int|message|Specifies the message identifier.
			&obwParam, // @tupleitem 2|int|wParam|Specifies additional information about the message.
			&oblParam, // @tupleitem 3|int|lParam|Specifies additional information about the message.
			&pMsg->time, // @tupleitem 4|int|time|Specifies the time at which the message was posted (retrieved via GetTickCount()).
			&pMsg->pt.x, // @tupleitem 5|(int, int)|point|Specifies the cursor position, in screen coordinates, when the message was posted.
			&pMsg->pt.y))
		return FALSE;
	return PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&pMsg->hwnd)
		&&PyWinObject_AsPARAM(obwParam, &pMsg->wParam)
		&&PyWinObject_AsPARAM(oblParam, &pMsg->lParam);
}
Example #3
0
STDMETHODIMP PyGContextMenu3::HandleMenuMsg2(
    UINT uMsg,
    WPARAM wParam,
    LPARAM lParam,
    LRESULT *lpResult)
{
    PY_GATEWAY_METHOD;
    PyObject *ret;
    HRESULT hr=InvokeViaPolicy("HandleMenuMsg2", &ret, "INN", uMsg,
                               PyWinObject_FromPARAM(wParam),
                               PyWinObject_FromPARAM(lParam));
    if (FAILED(hr)) return hr;
    if (lpResult) {
        if (ret == Py_None)
            *lpResult = FALSE;
        else {
            PyWinObject_AsPARAM(ret, (WPARAM *)lpResult);
            hr = PyCom_SetAndLogCOMErrorFromPyException("HandleMenuMsg2",
                    IID_IContextMenu3);
        }
    }
    Py_DECREF(ret);
    return hr;
}