Category Archives: microsoft

Audio and image support – Gotcha!

I’m currently working on a WPF application to extend a Silverlight control to support the capture of audio and webcam still images.   All seems to be going pretty well using a Logitech QuickCam Communicate STX as the capture device, using Avicap32.dll to handle images and NAudio for the audio.

Or so I thought.  When I deployed the application to my second dev environment, I kept getting the error “NoDriver calling waveInOpen”.  I spent a long while researching what the problem was, and kept coming up with the answer “Everyone says there is no audio driver installed, but I know it is there because I built the machine myself.”

That’s when it hit me.  The light bulb moment.  The moment when one tiny detail that was staring me in the face suddenly made itself apparent.  I was using the second machine in an MSTSC session from my main dev box, and had opted to bring audio across to the main box, too.  A quick setting change in the client configuration for MSTSC and all was well again.  I thought I’d better blog it to stop anyone else beating their head against a wall for an hour.

Hint text in ASP.NET TextBox controls

More and more often these days, you see hint text in a textbox control on a web form.  You know the kind of thing – “user name” or “password” appearing in silver text within an input control.  Well, I had to implement that functionality today and it is surprisingly easy to achieve.

The first thing you need to do is create your TextBox control on the page.  Once you’ve done that, add the following method to your codebehind file.

private void SetTextBoxHints(TextBox textBox, string defaultText)
{
textBox.Attributes.Add(“onfocus”, “clearText(this,'” + defaultText + “‘)”);
textBox.Attributes.Add(“onblur”, “resetText(this,'” + defaultText + “‘)”);
if (textBox.Text == “”)
{
textBox.Text = defaultText;
textBox.ForeColor = System.Drawing.Color.Silver;
}
else if (textBox.Text == defaultText)
{
textBox.ForeColor = System.Drawing.Color.Silver;
}
else
{
textBox.ForeColor = System.Drawing.Color.Black;

}

 Next, you’ll need to add the javascript to the page/user control to look after the dynamic changes in content/colour. 

<script type="text/javascript" language="javascript">
<!--
function clearText(ctrl,defaultText) {
if(ctrl.value == defaultText)
ctrl.value = ""
ctrl.style.color = "#000000";
}
function resetText(ctrl,defaultText) {
if(ctrl.value == "")
{
 ctrl.value = defaultText
 ctrl.style.color = "#C0C0C0";
}
}
// -->
</script>

Then, you need to call the setup method for each Textbox you want to control.

SetTextBoxHints(myControl, "the text you want to show as default...");

And that, as they say, is that. Enjoy.

Multiple Async calls to a web service

I’m currently working on a project that requires making several concurrent asynchronous calls to a web service.  Now, the service work fine synchrounously, but change the pattern slightly and I was getting the following error.

“There was an error during asynchronous processing. Unique state object is required for multiple asynchronous simultaneous operations to be outstanding.”

The solution, courtesy of a post on the MSDN forums was to pass a new GUID as a state object.

Problem solved.

 

Windows Home Server RC2

I’ve just installed the RC2 release of Windows Home Server. It looks pretty good, to be honest. I wasn’t expecting much, but the feature set seems to be rich enough for most users’ purposes. I’ll update this post later when I can tell you how it’s getting along.

**UPDATE**

I’ve just spent a few hours playing with the server software, and it appears to be quite useful.  I popped the client cd into each of my laptops, and within a few minutes, they were backing their data up to the server.  A few hours later, and everything was backed up. 

I also looked at the remote access features (although I have since disabled them – I don’t want to open up a hole in my firewall if I don’t need to).  Setting my router/firewall to UPNP mode, the server was able to auto-configure everything to allow access from the nasty ole web without hitch.  I am sure that there will be many users who will find this feature very useful, but I’m not one of them.  As I said before I don’t want to open up my firewall any more than I have to.

I also took a chance and installed SlimServer on the box.  I doubt it is supported, but it works well enough so I am happy to leave it on there.  It also means I can migrate the music from my existing SlimServer – handy as the old box is about 3MB short of running out of disk space.

That was a very quick spin through the server’s capabilities.  I’ll hopefully get some more time next weekend to play again.  If I find anything I missed, I’ll let you know.