# Sunday, 21 May 2006

As most of my readers know, there are three kinds of managed-to-native interop available to the C++/CLI programmer using Visual Studio 2005, as there were to the Managed C++ programmer using Visual Studio 2002 or 2003. Those are COM Interop, P/Invoke, and C++ Interop (formerly and more colourfully known as It Just Works Interop.) COM Interop is slow, but if you have a COM component already written, maybe in VB 5 or something, it's just the ticket. P/Invoke is good for C-style DLLs, and popular with people who want to call into the Windows API. C++ Interop is the easiest (say it with me: include the header, link to the lib) and fastest, and it's available only from C++.

So why would a C++ dev, who can just include-the-header-link-to-the-lib, ever use P/Invoke? Because it handles marshalling and translation for you. Take a look at this (reasonably old) post by Kenny Kerr. He includes this function in the post:

[DllImport("Native.dll", PreserveSig=false, CharSet=CharSet::Unicode)]
bool BrowseForComputers(IntPtr parentWindow,
                        bool multiSelect,
                        [MarshalAs(UnmanagedType::SafeArray, SafeArraySubType=VarEnum::VT_VARIANT)]
                        array<String^>^% computers);

That would be pretty grody work without P/Invoke. Let the feature help you where it can.

Kate

Sunday, 21 May 2006 07:22:49 (Eastern Daylight Time, UTC-04:00)  #    
# Saturday, 20 May 2006

I first saw this idea at http://www.flourish.org/upsidedownmap/:

You can see a whole pile of these "upside down" maps there and learn about some "sideways" ones as well. Of course there's no reason why north has to be at the top all the time (unless you want to use the map to navigate, and even then it's likely you'll rotate the map nine ways to Sunday, the issue is just in which rotation the words are right side up.)

I found a page that sells a variety of maps... I think I want a lot of these ones :-)

Kate

Saturday, 20 May 2006 08:30:56 (Eastern Daylight Time, UTC-04:00)  #    
# Friday, 19 May 2006

I have a number of talks I do about C++/CLI and Visual C++ 2005. The one thing they have in common is that there's never enough time for all the demos. There's one particular demo that is technically in two different talks, but never gets done... it shows how to put a WinForms control onto an MFC dialog, and how to implement MFC message passing (and the new DELEGATE family of macros, that are like the existing command routing macros) to hook a WinForms into an MFC View, complete with menu updating and implementation.

If you are one of the people in those audiences who was a little disappointed you didn't get to see the MFC stuff, here's a new paper that might help you out a bit: Integrate Windows Forms Into Your MFC Applications Through C++ Interop. It's by Marcus Heege, a new C++ MVP. I just have to like a guy who includes a subheading "C++ Interop Is Your Friend" :-)

Kate

Friday, 19 May 2006 08:25:33 (Eastern Daylight Time, UTC-04:00)  #    
# Thursday, 18 May 2006

You know, I'm all about the interop. Why port an entire application to something new when you can port part of it and interop to the rest? Why inisist one application be ported so it can talk to another if interop could solve the problem instead? While it may be difficult, it's typically the faster and cheaper option. Plus it's just more fun than re-implementing something that already works.

Microsoft Canada is holding an interop seminar on June 8th (actually one in the morning and one in the afternoon) at their Meadowvale offices. The email I got says:

Microsoft recognizes that most customers have diverse IT environments and Microsoft is building software and technologies that allow you to leverage your existing investments in non-Microsoft-based solutions.

The interoperability seminar is focused on discussing strategies for interoperability with diverse technologies including J2EE, Mainframes, Identity, Monitoring, Messaging and Data storage systems.

In this seminar we will:

  • Discuss organizational processes for architecture, development, quality assurance and deployment that may be instituted to accommodate varying technologies while maximizing reuse;
  • Explain Microsoft’s interoperability strategy, showcase our commitment to interoperability and provide links to resources for more detailed information;
  • Discuss real-life strategies, best practices and examples for interoperability between J2EE and .NET-based software.

I can't be there myself (I'll be out of the country) but you probably should! Register for either the morning or the afternoon session.

Kate

Thursday, 18 May 2006 08:15:52 (Eastern Daylight Time, UTC-04:00)  #    
# Wednesday, 17 May 2006

At the end of next week, May 26th to be precise, we're going to give a free "What is SharePoint" seminar in Peterborough. We'll be focusing on what it can do "out of the box" and demonstrating how much functionality you get for free. So if you know someone who lives northeast of Toronto (or feels like a Friday afternoon headstart to the cottage) please do pass the details along. It's from 2:30 to 4:00, it doesn't cost anything but we would like you to register, and we'd love to see you (or your friend or client) there.

http://www.gregcons.com/seminar2006.htm for details.

Kate

ps: no C++, I promise :-)

Wednesday, 17 May 2006 22:54:17 (Eastern Daylight Time, UTC-04:00)  #    
# Tuesday, 16 May 2006

As you probably know, when you're looking at a document library in Sharepoint, each document name is a link to the document:

If you click the link, the document opens in Word. I do that a lot, or else I right-click the link and Save Target As to put a copy on my own machine. You probably also know that there's a menu hanging off that triangle, and you could edit the document using that menu:

What I didn't realize until today is that these two choices behave differently. Click the link and Word opens the document as Read Only, so that when you click the Save icon in Word or choose File, Save, you get the Save As dialog. You can save it back into the same Sharepoint directory you opened it from, but it's an extra step:

If you use the menu item, it's not read-only and if you save it just saves with no further conversation. Now normally I would NEVER drop down a menu and choose an item from it when I could click a link. But since it turns out there's a difference, I'm going with the menu from now on.

Kate

Tuesday, 16 May 2006 16:48:06 (Eastern Daylight Time, UTC-04:00)  #    
# Monday, 15 May 2006

Spotted on the Monster Jobs Blog, ten rules for being a happy employee. I think that even though these rules are designed for the benefit and enjoyment of the individual, it would make your employer happy if you followed them. These are a good way to live. My favourite? "You Will Make Mistakes -- It’s How You Handle Them That Matters" . I tell my kids (and staff) something very similar quite often. Anyone can give into temptation, screw up, forget, or make a mistake once in a while. What matters is what you do next. Lying, covering up, blaming, denying, and not learning are the bad things here. A close second: "It Takes More than Talent". The only iffy one? "Keep Business and Romance Separate". But then again, we were already married when we started this business together, so that's not the same as falling for each other at work. I like having all my eggs in one basket. That way I know where they all are :-)

Kate

Monday, 15 May 2006 22:51:49 (Eastern Daylight Time, UTC-04:00)  #    
# Sunday, 14 May 2006

While at DevTeach, a colleague was struggling with a laptop that was flaky because it was running hot. He had it on an exhibitor's table, which was cloth-covered, and the soft surface was impeding the vents, which were mostly on the bottom. I passed along this tip to him, and I just heard that it worked as well for him as it has for me, so I thought I'd share it more widely.

Take three or four pens, the same size as each other, and lay them parallel on the desk or table like this: I I I I

Then carefully put the laptop down onto the pens. If you only had one it would wobble, if you only had two it would roll around, but three or four are pretty stable. Presto, your cooling is dramatically improved and your laptop stops being quite so flaky. I've even presented like this, for one of those talks with two VPCs that really pushes your CPU hard.

Kate

Sunday, 14 May 2006 07:37:15 (Eastern Daylight Time, UTC-04:00)  #    
# Saturday, 13 May 2006

In the June MSDN Magazine, Stan Lippman's Pure C++ column has become Netting C++. Here's the path he's laid out for himself. He's starting with a working console application written entirely in native C++. In this first column he's just going to make it run as a .NET executable with no use of .NET libraries and no exposing his classes to other .NET applications over the runtime. In the next column, he'll show how to wrap the native classes in managed wrappers so they can be called from VB or C#. Stan goes on to say:

Subsequent columns will focus on mapping the native types to types supported by the .NET Common Type System (CTS) and examining the performance characteristics of the application as it transitions. We'll also look at the type information available to the runtime, using the ildasm command to explore the Common Intermediate Language (CIL) into which all .NET-based languages are compiled.

When that's done, we'll explore multithreading, Web services, cross-language interoperability with a C# ASP.NET front, XML support, and integrating with Windows Vista™. So, we have our work cut out for us.

This will be a series to read as it appears.

Kate

Saturday, 13 May 2006 10:41:45 (Eastern Daylight Time, UTC-04:00)  #    
# Friday, 12 May 2006

Jerome Carron from Microsoft will be coming to the East of Toronto .NET User Group May 17th to talk about mobile applications:

This session will be an introduction to developing Windows Mobile applications with Visual Studio 2005. The focus of the session will be on Devices and the Mobile platform, getting started with device development (user interfaces and controls), data management (SQL Server Mobile) and Visual Studio tools for Data Management and close out with a look at Windows Mobile 5.

This meeting will be at the Whitby Library. Please register so we're expecting you.

Kate

Friday, 12 May 2006 16:19:33 (Eastern Daylight Time, UTC-04:00)  #