App Building Diary Day 2: Multi-Monitor Support!
10:44 Shut Down Outlook: I’ve been here since 9 working on “immediate attention required” e-mails. I can finally start coding again. I’m looking forward to making progress today with Phish kicking off the coding.
11:12 Suggestions #1 and #2: A double click selects a word, but now I’m wishing for triple click to select a whole line of code. I also had three instances of “connect.cs” open in my file tab channel. Two are misc files that I’ve been dissecting sample code from and the third is mine from the current project. I wish there was a visual indication of which files are not included in your open projects in the file tab channel.
1:30 Multi-monitor Support for my Auto-Complete browser: I spent a bunch of time working out the algorithm to get my auto-complete dropdown to show up at the right location and disappear at the right times. Then I floated my toolwindow to my secondary moniter and tried it out… Doh! If you just use the System.Windows.Forms.Screen.GetBounds() command you will only get it for your primary display. I was tempted to say “Hey, no one outside of Microsoft uses multi-monitor support anyway”, but then I remembered this post and the fact that I’ve tried to be pretty hard-line internally in support of multi-monitor scenarios. Here is new the code I put where my mouth is.
In my cmdTextBox (Extended richTextBox) class…
//Get the position within the richtextbox of the cursor
Point browserLocation = GetPositionFromCharIndex (this.TextLength-1);
//Map that position to an actual screen location
browserLocation = this.PointToScreen(browserLocation);
//Pass this location to the auto-complete browser with the font height
//and let it do the rest
dteCmdBrowser.ShowBrowser (browserLocation,this.FontHeight);
In my base auto-complete browser class…
public void ShowBrowser(Point location, int fontHeightAdjustment)
{
//Get rect for *entire*screen!
Rectangle screenSize = SystemInformation.VirtualScreen; //Adjust Y to put browser below the current line with
//the font height
location.Y += fontHeightAdjustment;
if ( location.Y + this.Height > screenSize.Height )
{
//If the bottem would be off of the screen adjust to
//put it above the current line
location.Y -= fontHeightAdjustment + this.Height;
}
//First find out if it would draw over the right edge of the
//screen then test the left. Pick the right X location.
location.X = Math.Max(Math.Min(screenSize.Right - this.Width, location.X), screenSize.X);
this.Location = location;
this.Visible = true;
}
Time for some REM…
2:00 EnvDte80 Discovery: Yesterday I was cursing that the DTE did not have a way to subscribe to window events for just that particular window. This meant I had to capture all the window events and then check the HWND for my window. I just found (while listening to the classic “Green” album) that there is a get_WindowVisibilityEvents(dtewindow) method you can use to subscribe to events for just that window. A good improvement for VS 2005 tool window writers. I’ll probably stick with my method for now since I want my add-in to work in VS 2002 and VS 2003 as well and I haven’t noticed a perf issue yet. It would be great if someone would create a diff sheet for the object models. I found this with an object browser search for “event”.
3:00 Gave Up on Whidbey Search: I’m not sure what it was exactly, but as of an hour ago I stopped going to Help->Search and went back to Browser->Google Toolbar. I think it is a combination of:
· Several local help topics being incomplete or non-existent for beta 1
· The added time it takes to run the MSDN search (yes, searching the internet is still faster than local help)
· The additional community hits I get from google (not just the Codewise Community)
· UI bugs I’ve hit that cut off the topic abstracts in our search UI.
· The fact I was reminded google existed after receiving my own gmail invite. J
F1 is still cool, but I wonder how useful an “Alt+F1” to google search would be. Maybe that will be my next project.
4:00 Off to a Meeting: I’m probably done for the day since I have a baseball game @6. I felt like I made steady progress today, but most of it was little bits of bug fixing. It’s pretty stable so I might spin a release off tomorrow AM before I start adding more features again.