Saturday, May 22, 2010

Enabling "Cut" in Mac OS X Finder

For some reason you can't "cut" files in Mac OS X out of the box, but you can enable it by running this in the terminal window:

defaults write com.apple.finder AllowCutForItems 1

Sunday, February 21, 2010

AxAcroPDF Acrobat Reader Stealing Focus

I have been having a problem where an embedded ActiveX reader control will steal the focus from the form it's on. This is very annoying as I've got a list of PDFs and I want the user to be able to use the up and down arrow keys to preview them.

I did a lot of searching and didn't find a solution. Basically after you call the LoadFile method on the control it loads the PDF asynchronously and once the PDF is loaded it will steal the focus. What you need to do is to spawn a new thread, wait half a second to give the ActiveX control a bit of time to load the file, then call the focus method on the appropriate control again.

private void LoadPDF(string path) {
axPDF.LoadFile(path);

Thread t = new Thread(new ThreadStart(Refocus));
t.Start();
jobsList.Focus();
}

private delegate void RefocusDelegate();

private void RefocusMethod()
{
jobsList.Focus();
}

private void Refocus()
{
Thread.Sleep(500);
this.BeginInvoke(new RefocusDelegate(RefocusMethod));
}

Sunday, February 7, 2010

Outlook CommandBarButton events

Hey guys!

CommandBars in Outlook (probably Word and all the others too, haven't checked) seem to fire the same click handlers of similarly tagged buttons on CommandBars with the same name. So that means if you have an Explorer command bar named the same thing as an Inspector command bar, and you add a click handler to similar buttons on it, both click handlers will fire for both buttons.

I guess the point I'm trying to make is that the Name of the CommandBar is important! I wish I knew this ages ago!

That is all.

Thursday, May 28, 2009

ReadOnlyNameValueCollection

Hey guys!

If you try using a System.Configuration.DictionarySectionHandler to store values that you need to come out in the order they're specified in the app.config, they'll actually come out in the order the hashing algorithm dumps them in there. So you have to use a System.Configuration.NameValueSectionHandler.

System.Configuration.ReadOnlyNameValueCollection is internal, but you can cast it to System.Collections.Specialized.NameValueCollection.

Also, the System.Configuration.ConfigurationManager class doesn't show up by default in Visual Studio 2008. You have to manually include a reference to System.Configuration.

It took me way too long to figure this out.