Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / July 2004

Tip: Looking for answers? Try searching our database.

Custom ActiveX Control in C++

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wolfgang - 30 Jun 2004 09:51 GMT
Hello,

i managed to go through the hands-on-lab-6 for infopath dealing with
the creation of custom activex controls for infopath. the lab shows
how a control can be created that returns a variable of type long to
infopath.

I tried to modify the activex control from the lab to return a string,
but it doesn't work. I don't know which data type i have to use
therefore and how to define the appropriate methods using the MIDL
file of the control.

Can anybody help me and show how this can be done ?

Greetings,
Wolfgang
Andrew Ma [MSFT] - 30 Jun 2004 19:14 GMT
What return types have you tried when returning a string?

Signature

Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias.  This alias is for
newsgroup purposes only.

> Hello,
>
[quoted text clipped - 12 lines]
> Greetings,
> Wolfgang
Wolfgang - 14 Jul 2004 11:55 GMT
Hallo again,

> What return types have you tried when returning a string?

i first used the control from the hands-on-lab6 with a long. that
worked fine.
then i changed the code of the lab to transfer a single char. this
also worked.

the next thing i thought about was to modify this example to transfer
a string to infopath.

i know that i have to specify a get-Method for the string that
infopath should insert into its xml-tree. My problem is that I do not
know ..

1.) which datatype is the correct one for a string (char, char[],
byte[], ...) ?

2.) how to edit the get-Method in the IDL-file for the control in a
way that an array of a specified datatype (if array is needed) can be
used ?

Greetings,
Wolfgang
Andrew Ma [MSFT] - 14 Jul 2004 22:33 GMT
BSTR is what you want to use for strings.

Signature

Andrew J. Ma
Software Test Engineer
Microsoft Office InfoPath
http://blogs.msdn.com/ajma
---------------------------------------
This posting is provided "As Is" with no warranties, and confers no rights.
Use of any included script sample are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm.
Please do not send email directly to this alias.  This alias is for
newsgroup purposes only.

> Hallo again,
>
[quoted text clipped - 21 lines]
> Greetings,
> Wolfgang
Wolfgang - 19 Jul 2004 09:47 GMT
Hello,

i tried with BSTR but it does not work. My hardcoded string value
wasn't saved into the xml-file when saving the form in Fill-Out-Mode.

This is how I implemented it:

1. Generated IDL-Definitions using VS.NET 2003-Wizard.
 
[propget, id(2), helpstring("property BValue")] HRESULT BValue([out,
retval] BSTR* pVal);
[propput, id(2), helpstring("property BValue")] HRESULT BValue([in]
BSTR newVal);

2. Implemented the get-Method with the following code.

STDMETHODIMP CTestControl::get_BValue(BSTR* pVal)
{
    BSTR testValue = new WCHAR[11];
    swprintf(testValue,L"TestString");
    pVal = &testValue;
    return S_OK;
}

Can you help me ?

Greetings,
Wolfgang

> BSTR is what you want to use for strings.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.