Centering a WPF Window in an Outlook 2013 Add-in

I recently came upon the need to show a WPF window in an Outlook add-in, preferably centered on the Outlook window (WindowStartupLocation = CenterInParent).  Easy enough, but without setting Window.Owner, it will appear in an uncontrolled location when calling ShowDialog().

Setting Window.Owner is where things get a little tricky.

Searching online produced a few variations of the theme of using the WindowInteropHelper class in combination with the win32 FindWindow API with the window caption discovered via Reflection.  Yuck.  Surely there’s a better way.

Enter System.Process.  One of the properties of the System.Process class is MainWindowHandle, which Microsoft states:

The main window is the window opened by the process that currently has the focus (the TopLevel form).

Sounds like exactly what I’m looking for.  A quick call to Process.GetCurrentProcess() and we’ve got everything we need.  The final code to show the WPF window is:

Simple as that!

 

Corel VideoStudio Pro and QuickTime, a Workaround

I really like Corel VideoStudio Pro for video editing, and I’ve been using it for 4 years now.  Unfortunately it really falls down when it comes to QuickTime videos.  Now that I own a Canon 7D that records in QuickTime format, this is a problem.

The underlying issue is that the software seems to lose all knowledge of its QuickTime capabilities when QuickTime has been upgraded on the machine.  Since I use iTunes on this computer for my iPhone and iPad, there’s no possibility for me to downgrade QuickTime for VideoStudio.

So tonight I set out to find a solution.

QuickTime Pro and some C#

I purchased QuickTime Pro ($30) and found that I could take a .mov file and perform a Pass Through MP4 conversion which essentially just strips the embedded mp4 data from the .mov file without doing any real transcoding.  This is exactly what I want – I don’t want to lose any video quality just because I want the raw mp4.

The problem now is that this is a completely manual process that I would need to do on each and every video file.  File -> Export -> MPEG-4 -> Pass Through -> blah blah.

There’s just no way that was going to work, so I decided to write some code against the QuickTime COM api to automate the process.

The following code is for a command-line executable that will do this mov to mp4 conversion to a batch of mov files:

After building this, I added a shortcut to my Windows 7 SendTo folder.

Now, in my video folder I’m able to multi-select as many .mov files as necessary, righ-click and select Send To -> QTExtractor.  An .mp4 file will be created for each .mov!

The only downside is that the QT UI pops up as it is working – I haven’t looked but I suspect I can’t get around this.  Oh well, this should suffice until Corel gets their act together.

Dey-tuh

I just read David‘s post on the usage of the word code in the context of software and have to add that, to someone in the field, hearing that usage is akin to fingernails on a chalkboard.

This got me thinking about one of my biggest pet peaves in the computer world.  I know that I’m  not right on this and they aren’t wrong, but it still annoys the hell out of me.  What is it, you ask?   Nothing other than the pronunciation of the word Data.  In my mind (zip it..) it’s pronounced [Dey-tuh].  Not [Dat-uh].  It’s [Dey-tuh base], not [Dat-uh base].

Seriously, I’ll be having a conversation with someone and they’ll mention their Dat-uhbase and it takes all I can muster to not make a face like I just ate a lemon.  I can understand if these people were British and said it with a cool accent.  But no, they’re just plain-ol’ Americans like myself.  Dey-tuh people.  Not Dat-uh.  Please.

I recall when Ana came home from her new, at the time, job at a local mortgage company.  She was describing her day, and the let the Dat-uh word slip.  It stopped me in my tracks, caused me to interrupt her quite rudely, and show now makes sure to call it Dey-tuh whenever I’m within earshot.  She uses Dey-tuh from a Dey-tuh base.