Stoplights in Infopath

W

wls

I have a number of forms in Excel that I'm converting into InfoPath for
a client. On one such form, I have a series of interactive "stop
light" controls to indicate status.

By 'stop light' I mean a simple text box that can hold one, and only
one, letter, of the set R, Y, or G (for red, yellow, or green,
respectively). The background changes to the color of the letter.
While trivial in HTML, I have only the conditional background colors
working in InfoPath.

What's elusive is that the customer wants to be able to type the single
letter R, Y, or G in the text box, and if so, accept it and instantly
move focus to the next one without hitting tab or return. If not, do
nothing. Additionally, if clicked in, the letter should cycle to the
next in the series.

Only the problem is I can't get InfoPath to actively interact with the
user in real time. There seems to be no onFocus() or onKeyPress()
events. Even onClick() is missing when it comes to non-button objects.


I tried manually tweaking the XSLT file, injecting JavaScript. No
dice. InfoPath ignores it. I've got 90% of a workable solution, and
my hands tied behind my back for the rest.

I'm stunned at the lack of interactivity provided by InfoPath, and I
have no idea how I'm going to address more complex forms. Is there any
way to turn on some advanced mode and get more detailed event handler
notifications? Can I add my own ActiveX controls to a form?
 
B

Brian Teutsch [MSFT]

The events you are looking for on InfoPath are not present. You will not be
able to catch each key press or an onFocus event. ActiveX controls can be
added to InfoPath SP1 forms, so that's definitely an option.

InfoPath has to be many things to many people, so sorry something you view
as critical isn't present. Thanks for the feedback on it.

Brian
 
M

Mike Sharp

How about making them buttons instead of letters in a text box? You can
make it look like a link by hiding the border of the button

[red][yellow][green]

The button onclick event does whatever you need to do. The user would only
have to click once for each item.

Just a thought.
Mike
 
W

wls

I had considered this as an option, but then I got to wondering, does
InfoPath store in it's XML the label of the button?

Put another way, does InfoPath treat a button itself as data, or simply
as a thing to click that does stuff and has no information worthy of
retaining.

Will have to experiment to see.
 
W

wls

Brian,

Thanks for the note - at least I'll stop walking down a dead end path.

Do you know of any Microsoft documentation or articles that explain the
process of developing ActiveX controls explictly for InfoPath?
 
W

wls

Yeah, I had found that. Ideally, I wanted to stay with C# and .NET,
opposed to adding C++, ATL, and COM to the mix of growing complexity.

None the less, I did run through the tutorial. Like many MS tutorials,
it simply said things like "go to this line and enter this end" while
the new user (who is the target of a tutorial) has no clue what the
magic line is doing or why. For instance, I'm adding a COM Interface
Map to the IObjectSafety interface, but having never used IObjectSafety
it isn't clear why I need it, what it is doing, and whether it's
optional or mandatory for InfoPath.

I got down to the obtain test certificate, and executed the instructed
command:
makecert newCert.cer -sv privatekey.pvk
....only to have makecert claim there was no -sv parameter, nor did I
have a privatekey.pvk file, which I guess was input and not a created
output.

Even so, reading the "To add the ActiveX control tothe Controls task
pane" the magic step of getting the ActiveX control in the "Select a
control" list seems to be missing. I suspect there's some registration
or something that must take place so InfoPath (and other applications)
know about my control's existance.

Ironically, this is as far as I progressed when creating an Windows
Control Library assembly; I could add it to other projects as a
reference, and it works great. However, I could never get it to appear
in InfoPath's list of known custom controls.

Perhaps there is a command line utilitiy I should be running? Neither
regasm.exe and installutil.exe seemed to work. So much for guessing.
 
B

Brian Teutsch [MSFT]

IObjectSafety must be implemented. That interface is required, and missing
it will result in the inability to add the control. A quick search on MSDN
should help you get started with that.
 
W

wls

Brian said:
IObjectSafety must be implemented. That interface is required, and missing
it will result in the inability to add the control. A quick search on MSDN
should help you get started with that.

Brian,

First of all, I wanted to thank you for your help -- you've been very
responsive and sent me down a number of paths I otherwise would have
overlooked.

In short, while I have managed to exert a lot of effort, I haven't
made much progress in adding a custom control to InfoPath as easily as
the blog seems to make this out to be.
(http://blogs.msdn.com/infopath/archive/2004/04/09/110504.aspx)

It seems that all roads eventually return to the ever famous "Lab 6"
which discusses ActiveX controls in InfoPath.
(http://msdn.microsoft.com/library/d...y/en-us/odc_ip2003_tr/html/odc_INF_Lab_06.asp)

First of all, the "lab" is in making an ActiveX control in C++. I'm
looking for an article ==any article or sample== that does something
trivial in C#. As you're aware, there are a lot of method decorations,
in addition to code, that are needed to pull off this stunt.

I also notice the article talks about using 'makecert' with the '-sv'
parameter. I'm sure it's a typo, but my makecert doesn't have a -sv
switch, but has a number of similar switches (-sk, -ss, and -sr), so
it's unclear which one is needed. Both -ss and -sk say "Succeeded",
though the help implies very diffferent things are going on, and in no
case is privatekey.pvk created. I assume it must be supplied, but from
where?

In addition to IObjectSafety, does a custom control have to bind to a
data source? For instance, can I provide the user with a widget like a
mini-desktop calculator -- something they can interact with, but is not
persisted with the page?

Thanks again,
-wls
 
B

Brian Teutsch [MSFT]

I don't think we have any examples of ActiveX in C#, because my limited
knowledge of COM interop in managed code is that it's difficult. Hence the
examples in C++. There are a few internet samples I found using my favorite
search engine.

I don't think -sv is a typo. This MSDN page documents it.
http://winfx.msdn.microsoft.com/lib...html/b0343f8e-9c41-4852-a85c-f8a0c408cf0d.asp.

I'm not sure if it's possible to get an ActiveX control onto the page which
doesn't bind to anything.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top