John R. Durant's WebLog

Blog of "The" Office Developer

Outlook Reading Pane and Charles Petzold

I am working on a cool Outlook add-in, and it involves knowing if the Outlook Reading Pane is displayed or not and what its size is. This is an extra little challenge because the Outlook OM does not expose any info about the pane. One might guess that the Outlook View would perhaps disclose this info, but you get bupkis! There is a previewPane element in the View schema, but it is of no use when trying to figure out what is going on with the Reading Pane in the current view.

Well, this is where I turned to the Win32 API, a dangerous pass-time for a .NET coder who makes only occassional direct calls the "Charles Petzold" way (I did read his incredible book "Programming Windows 3.1" back in 1997 [I think], I found the hwnd of the Reading Pane window. Anyway, I found out a couple of interesting things. I start with the basic, obvious fact and add the others as I go.

1) The Reading Pane hwnd is there when the pane is on (duh) but...

2) The hwnd for the pane remains there when the pane is subsequently turned off in the folder where it can appear.

3) You can query this hwnd and find its children and so forth. It still thinks it is alive. It will contain all of the controls with data from the last viewed Outlook item with the pane was turned off.

3) Moving to a folder where there is no reading pane (ie: Calendar) causes the hwnd for the pane to finally go away.

4) Going back to a folder where the reading pane can appear (ie: Inbox) but where the reading pane is still off causes the hwnd for that pane to become alive again. However, it will no longer contain controls and data of the last viewed Item when it was turned off.

So, if you are in a pane where the Reading Pane can appear, it will actually be alive in memory, lurking in the background and will need to keep this in mind when writing an add-in that takes into account the Reading Pane behavior.

 Second Rock Thought for the Day: I was picking up one of my sons from track practice the other day, and I pulled up with Linkin Park's Meteora CD at near full volume in my car. He loves this album as much as I do, and I am pleased that he sings the words (even though a little too quietly). Always encourage kids to sing. Rock and roll and music in general is about freedom and letting ourselves go, if only for 3.5 minutes. I've pretended to be Robert Plant rasping out the lyrics so many times, and it always feels good, and I'm not embarrassed. I'm actually more embarrassed if I hold myself back because it shows my fears (although my sense of public propriety prevents from doing my Robert Plant impressions where it will be truly annoying to others). "I don't care what the people say, I know where their jive is at."

Rock On

Published Thursday, September 22, 2005 9:44 AM by johnrdurant

Comments

 

Cameron said:

Excellent reverse-engineering, my man! It reminds me of the time I tried to figure out the base line to "The Immigrant Song". Anyway, this behavior in Outlook is easier to understand if you think about what it is trying to do. Deferred creation is a popular approach toward optional features, and this is the key. Outlook tries not to create the preview pane until it knows it is needed. This explains why switching to a new folder that does not use the preview pane avoids its creation. This saves extra processing and overhead. You also note though, that when the pane is unchecked, we don't get the same cost-savings. Instead, the pane is merely hidden from view. This optimizes for the possibility that the pane will be shown again in the near future - a debatable optimization, but a design decision that happens to also be very simple to implement.

By the way - the new Foo Fighters, I find, compels me to sing the way Zeppelin does. It's a visceral thing.
September 22, 2005 1:33 PM
 

johnrdurant said:

Awesome explanation, Cameron. It makes a lot of sense.

I am way enthusiastic about the Foo Fighters as well. Anyone who saw them do the CCR cover for the Katrina benefit a couple of weeks ago know that this band is very arguably the best in the world right now.

Rock On!
September 22, 2005 2:41 PM
Anonymous comments are disabled

© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Microsoft
Page view tracker