S
santosh
Hi
I am developing an add-in for MS WORD in which
I am adding a toolbar which contains a button and combobox using COM in
visual c++ .
For that I'm using a sample addin in msdn "comaddin.exe".
this is the link for downloading 'comaddin.exe'
http://support.microsoft.com/?kbid=230689
I modified the code to add one combobox.
like this.
STDMETHODIMP CMyAddin::OnStartupComplete(LPSAFEARRAY* custom)
{
......................
.......................
/***********************************************************************************/
/* Code For adding ComboBox */
/***********************************************************************************/
vtParam.vt = VT_BSTR;
vtParam.bstrVal = ::SysAllocString(L"ComboBox1");
hr = CallMethod(vtCtrls.pdispVal, L"Item", &vtComboBox, 1, &vtParam);
VariantClear(&vtParam);
if (FAILED(hr)) {
vtParam.vt = VT_I4; vtParam.lVal = COMBOBOX;
hr = CallMethod(vtCtrls.pdispVal, L"Add", &vtComboBox, 1, &vtParam);
if (FAILED(hr)) goto cleanup;
//I tried this method for populating the listBox but it is not working.
I TRIED THIS METHOD FOR POPULATING THE LIST BOX BUT IT IS NOT WORKING
vtParam.vt = VT_BSTR;
vtParam.bstrVal = ::SysAllocString(L"String1; String2;String3");
hr = PutProperty(vtComboBox.pdispVal, L"Data", &vtParam);
if (FAILED(hr)) goto cleanup;
CAN SOMEONE PLEASE SUGGEST ANY SOLUTION TO THIS PROBLEM.I ALSO WANT TO
HANDLE TEXT CHANGE EVENT OF COMBOBOX AND BUTTON CLICK
(FOR MORE THAN ONE BUTTON IT FIRES SAME EVENT). IS THERE ANY METHOD TO FIRE
DIFFERENT EVENTS FOR DIFFERENT BUTTONS.
RIGHT NOW I HAVE WRITTEN DIFFERENT CLASSES FOR ALL BUTTONS FOR HANDLING
"CLICK" EVENTS. BUT I DONT WANT TO DO THIS AND SEARCHING
FOR SOME BETTER SOLUTION
PLEASE HELP, ITS URGENT
Santosh
I am developing an add-in for MS WORD in which
I am adding a toolbar which contains a button and combobox using COM in
visual c++ .
For that I'm using a sample addin in msdn "comaddin.exe".
this is the link for downloading 'comaddin.exe'
http://support.microsoft.com/?kbid=230689
I modified the code to add one combobox.
like this.
STDMETHODIMP CMyAddin::OnStartupComplete(LPSAFEARRAY* custom)
{
......................
.......................
/***********************************************************************************/
/* Code For adding ComboBox */
/***********************************************************************************/
vtParam.vt = VT_BSTR;
vtParam.bstrVal = ::SysAllocString(L"ComboBox1");
hr = CallMethod(vtCtrls.pdispVal, L"Item", &vtComboBox, 1, &vtParam);
VariantClear(&vtParam);
if (FAILED(hr)) {
vtParam.vt = VT_I4; vtParam.lVal = COMBOBOX;
hr = CallMethod(vtCtrls.pdispVal, L"Add", &vtComboBox, 1, &vtParam);
if (FAILED(hr)) goto cleanup;
//I tried this method for populating the listBox but it is not working.
I TRIED THIS METHOD FOR POPULATING THE LIST BOX BUT IT IS NOT WORKING
vtParam.vt = VT_BSTR;
vtParam.bstrVal = ::SysAllocString(L"String1; String2;String3");
hr = PutProperty(vtComboBox.pdispVal, L"Data", &vtParam);
if (FAILED(hr)) goto cleanup;
CAN SOMEONE PLEASE SUGGEST ANY SOLUTION TO THIS PROBLEM.I ALSO WANT TO
HANDLE TEXT CHANGE EVENT OF COMBOBOX AND BUTTON CLICK
(FOR MORE THAN ONE BUTTON IT FIRES SAME EVENT). IS THERE ANY METHOD TO FIRE
DIFFERENT EVENTS FOR DIFFERENT BUTTONS.
RIGHT NOW I HAVE WRITTEN DIFFERENT CLASSES FOR ALL BUTTONS FOR HANDLING
"CLICK" EVENTS. BUT I DONT WANT TO DO THIS AND SEARCHING
FOR SOME BETTER SOLUTION
PLEASE HELP, ITS URGENT
Santosh