> Такая проблема есть DHTML control, хочу сделать на нем так > чтоб по правой кнопке вылазило меню. Для этого > используеться SetContextMenu метод. Проблема в том что хрен > знает что ему надо передавать. В SDK написано > > SetContextMenu Method > Sets the menu items for the current document's right-click > context menu. > > Syntax > > object.SetContextMenu menuStrings, menuState > > Parameters > > object > > The DHTML Editing control > > menuStrings > > SafeArray containing VARIANTs of type VT_BSTR, one for each > of the context menu items to show. An empty string > indicates a separator line. An ampersand (&) in an element > of menuString indicates that the character after the > ampersand is an access (mnemonic) key. To clear the context > menu, pass an array dimensioned to zero in this parameter. > > menuState > > SafeArray of VARIANTs of type OLE_TRISTATE (long). Each > element corresponds to an element in menuStrings. Possible > values are: > > OLE_TRISTATE_UNCHECKED (0) Displays the menu item > unchecked. > > > OLE_TRISTATE_CHECKED (1) Displays a check mark next to the > menu item. > > > OLE_TRISTATE_GRAY (2) Makes the menu item appear > unavailable. > To clear the context menu, pass an array dimensioned to > zero in this parameter. > > Error Codes > > Error Return Value Description > DE_E_INVALIDARG Invalid argument (invalid parameter, > missing parameter, or incorrect type) > DE_E_UNEXPECTED Control is in an unexpected state. This > error can occur if this method is invoked prior to the > DocumentComplete event occurring. > ----------------------------------------------------------- > ------ > ----------------------------------------------------------- > ------ > Как понял надо передать 2 VARIANTа типа VT_ARRAY, а в > SafeArray запихать VARIANTы с типом VT_BSTR и VT_I4 > соответсвенно. > Делаю так: > > _variant_t vr_t; > VARIANT vr1,vr2,vr; > LONG t; > OLE_TRISTATE k; > SAFEARRAY FAR *arr1,*arr2; > SAFEARRAYBOUND bound; > HRESULT hr; > char str[256]; > BSTR bstr; > > bound.lLbound=0; > bound.cElements=1; > > i=0; > > arr1=SafeArrayCreate(VT_VARIANT,1,&bound); > vr1.vt=VT_ARRAY;
//dolzhin byt` array of variant
vr1.vt=VT_ARRAY | VT_VARIANT ;
> VariantClear(&vr); > //I ne znau declaraion of SetContextMenu() no I dumau chto tam VARIANT not VARIANT* (pointers obychno ne return arg types)
m_edit.SetContextMenu(&vr1,&vr2);
> > SafeArrayDestroy(arr1); > SafeArrayDestroy(arr2); > > Но ничо не выходит exception и усе. Че я делаю не так? > В контроле есть event onclick который срабатывает при > нажатии ЛЮБОЙ клавиши мыша, можно ли отфильтровать нажатие > только правой кнопки? Posmotri kakoi tam parameter u etogo eventa.
Такая проблема есть DHTML control, хочу сделать на нем так чтоб по правой кнопке вылазило меню. Для этого используеться SetContextMenu метод. Проблема в том что хрен знает что ему надо передавать. В SDK написано
SetContextMenu Method
Sets the menu items for the current document's right-click context menu.
Syntax
object.SetContextMenu menuStrings, menuState
Parameters
object
The DHTML Editing control
menuStrings
SafeArray containing VARIANTs of type VT_BSTR, one for each of the context menu items to show. An empty string indicates a separator line. An ampersand (&) in an element of menuString indicates that the character after the ampersand is an access (mnemonic) key. To clear the context menu, pass an array dimensioned to zero in this parameter.
menuState
SafeArray of VARIANTs of type OLE_TRISTATE (long). Each element corresponds to an element in menuStrings. Possible values are:
OLE_TRISTATE_UNCHECKED (0) Displays the menu item unchecked.
OLE_TRISTATE_CHECKED (1) Displays a check mark next to the menu item.
OLE_TRISTATE_GRAY (2) Makes the menu item appear unavailable.
To clear the context menu, pass an array dimensioned to zero in this parameter.
Error Codes
Error Return Value Description
DE_E_INVALIDARG Invalid argument (invalid parameter, missing parameter, or incorrect type)
DE_E_UNEXPECTED Control is in an unexpected state. This error can occur if this method is invoked prior to the DocumentComplete event occurring.
-----------------------------------------------------------------
-----------------------------------------------------------------
Как понял надо передать 2 VARIANTа типа VT_ARRAY, а в SafeArray запихать VARIANTы с типом VT_BSTR и VT_I4 соответсвенно.
Делаю так:
_variant_t vr_t;
VARIANT vr1,vr2,vr;
LONG t;
OLE_TRISTATE k;
SAFEARRAY FAR *arr1,*arr2;
SAFEARRAYBOUND bound;
HRESULT hr;
char str[256];
BSTR bstr;
Но ничо не выходит exception и усе. Че я делаю не так?
В контроле есть event onclick который срабатывает при нажатии ЛЮБОЙ клавиши мыша, можно ли отфильтровать нажатие только правой кнопки?
> Такая проблема есть DHTML control, хочу сделать на нем так > чтоб по правой кнопке вылазило меню. Для этого > используеться SetContextMenu метод. Проблема в том что хрен > знает что ему надо передавать. В SDK написано > > SetContextMenu Method > Sets the menu items for the current document's right-click > context menu. > > Syntax > > object.SetContextMenu menuStrings, menuState > > Parameters > > object > > The DHTML Editing control > > menuStrings > > SafeArray containing VARIANTs of type VT_BSTR, one for each > of the context menu items to show. An empty string > indicates a separator line. An ampersand (&) in an element > of menuString indicates that the character after the > ampersand is an access (mnemonic) key. To clear the context > menu, pass an array dimensioned to zero in this parameter. > > menuState > > SafeArray of VARIANTs of type OLE_TRISTATE (long). Each > element corresponds to an element in menuStrings. Possible > values are: > > OLE_TRISTATE_UNCHECKED (0) Displays the menu item > unchecked. > > > OLE_TRISTATE_CHECKED (1) Displays a check mark next to the > menu item. > > > OLE_TRISTATE_GRAY (2) Makes the menu item appear > unavailable. > To clear the context menu, pass an array dimensioned to > zero in this parameter. > > Error Codes > > Error Return Value Description > DE_E_INVALIDARG Invalid argument (invalid parameter, > missing parameter, or incorrect type) > DE_E_UNEXPECTED Control is in an unexpected state. This > error can occur if this method is invoked prior to the > DocumentComplete event occurring. > ----------------------------------------------------------- > ------ > ----------------------------------------------------------- > ------ > Как понял надо передать 2 VARIANTа типа VT_ARRAY, а в > SafeArray запихать VARIANTы с типом VT_BSTR и VT_I4 > соответсвенно. > Делаю так: > > _variant_t vr_t; > VARIANT vr1,vr2,vr; > LONG t; > OLE_TRISTATE k; > SAFEARRAY FAR *arr1,*arr2; > SAFEARRAYBOUND bound; > HRESULT hr; > char str[256]; > BSTR bstr; > > bound.lLbound=0; > bound.cElements=1; > > i=0; > > arr1=SafeArrayCreate(VT_VARIANT,1,&bound); > vr1.vt=VT_ARRAY;
//dolzhin byt` array of variant
vr1.vt=VT_ARRAY | VT_VARIANT ;
> VariantClear(&vr); > //I ne znau declaraion of SetContextMenu() no I dumau chto tam VARIANT not VARIANT* (pointers obychno ne return arg types)
m_edit.SetContextMenu(&vr1,&vr2);
> > SafeArrayDestroy(arr1); > SafeArrayDestroy(arr2); > > Но ничо не выходит exception и усе. Че я делаю не так? > В контроле есть event onclick который срабатывает при > нажатии ЛЮБОЙ клавиши мыша, можно ли отфильтровать нажатие > только правой кнопки? Posmotri kakoi tam parameter u etogo eventa.