Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Sarita Bafna: VC++ "Orcas" - Marshaling Library and MFC support for Common Controls

Download

Right click “Save as…”

If you write managed code and interop with unmanaged, you know the pain involved with marshaling string types across runtimes... If you write MFC apps and want to take advantage of new whiz bang shell UI features (aka common controls) without writing more code that specifically targets Vista, for example, well you can. All of this thanks to Sarita and team!

Sarita Bafna is a Program Manager on the VC++ Libraries team. Her current focus is on MFC support for common controls (including Vista's new set of cool common controls) and the new Marshaling library (it marshals managed types to unmanaged types and vice-versa. Only string types are supported in this release) in VC++ "Orcas".

Tune in and learn about these new VC++ constructs available in "Orcas".

Tags:

Follow the Discussion

  • Only support for strings?  Uhm, that's like saying "Hey, we have this great marshaling library but it only supports strings".  LOL

    That's not really a library but more like a code snippet.  Don't get me all excited about interop then give me something so trivial.  Is something wrong with the code below?

    Utils::Utils(void)
    {
    }

    const char* Utils::MarshalString( String ^ s )
    {
       using namespace Runtime::InteropServices;
       const char* chars = (const char*)   (Marshal::StringToHGlobalAnsi(s)).ToPointer();
       return chars;
    }

    tcp::endpoint Utils::MarshalEndPoint( System::Net::IPEndPoint ^endpoint )
    {
       return tcp::endpoint(Utils::MarshalAddress(endpoint->Address), endpoint->Port);
    }

    boost::filesystem::path Utils::MarshalFileInfo(System::String ^fullPath)
    {
       return boost::filesystem::path(Utils::MarshalString(fullPath));
    }

    System::Collections::Generic::List<float>^ Utils::MarshalFloatVector(std::vector<float>& data)
    {
       System::Collections::Generic::List<float>^ items = gcnew System::Collections::Generic::List<float>;
       for(int i = 0; i < data.size(); i++)
          items->Add(data[i]);
       return items;
    }

  • I think you're being a bit myopic. Developers should have considerably fewer headaches as a result of all the technologies she talked about. Certainly the updated control library, in particular, will be welcomed.

    I thought it was a good interview myself. Additionally, I have to say she has some of the nicest whiteboard handwriting I've seen.

    Smiley
  • CharlesCharles Welcome Change
    BryanF wrote:
    I think you're being a bit myopic. Developers should have considerably fewer headaches as a result of all the technologies she talked about. Certainly the updated control library, in particular, will be welcomed.

    I thought it was a good interview myself. Additionally, I have to say she has some of the nicest whiteboard handwriting I've seen.

    Smiley


    Agreed and agreed. To the first point: nothing is stopping developers from extending the default functionality of the Marshaling lib. Fact is, strings are very commony-used types in managed/unmanged applications, typically... It makes perfect sense, therefore, that the string interop marshaling problem is tackled first by the Marshaling lib team. As Sarita says in the interview, this library will evolve to support many more common types that need to cross runtime boundaries...

    C
  • Yes yes...  I never said the interview was bad or even that the idea was bad.  I was just pointing out that the library does not exist yet.  Sort of like counting your chickens before they hatch, something we all know can cause quite a bit of shoot-self-in-foot action.

    My whole intention was to put my code out there and ask what the difference is between their interop and mine, if any.  I was a bit excited to see that there will be some new marshaling classes but was let down when they said "only strings are supported" since that's probably the most trivial aspect.

    I really look forward to having a marshaling library that allows for fast marshaling between my native and managed types, without having to focus on it too much.

    Good interview and nice handwriting too.

    Thanks!

    BryanF wrote:
    I think you're being a bit myopic. Developers should have considerably fewer headaches as a result of all the technologies she talked about. Certainly the updated control library, in particular, will be welcomed.

    I thought it was a good interview myself. Additionally, I have to say she has some of the nicest whiteboard handwriting I've seen.

    Smiley
  • CharlesCharles Welcome Change

    Kosher,

    The Marshaling lib is available in the "Orcas" March CTP.
    C

  • Nice video.  Great to see 'high quality' graphics finally supported.  Does this include > 16 color toolbars by default?

    I haven't installed the CTP, but I'm wondering if the performance of the C++ compiler has improved.  The C++ compiler in VC++2005 is quite slow compared to the VC++6.0 compiler.
  • Steve Teixeirastevetei Parallel Computing Platform
    gsuing wrote:
    I haven't installed the CTP, but I'm wondering if the performance of the C++ compiler has improved.  The C++ compiler in VC++2005 is quite slow compared to the VC++6.0 compiler.


    The reduced build throughput between VC6 and VC2005 is primarly a result of vastly increased correctness and standards conformance.  In Orcas, we have increased throughput by supporting compilation of multiple translation units in parallel.  We have also done some work to optimize dependency checking for managed/mixed projects.  We blogged about this recently on the VC++ team blog: http://blogs.msdn.com/vcblog/archive/2007/03/12/multi-processor-builds-in-orcas.aspx.
  • Kosher wrote:
    Only support for strings?  Uhm, that's like saying "Hey, we have this great marshaling library but it only supports strings". 


    The primary goal of the first version of this library was to design a marshaling framework that could be easily understood, commonly applied and easily extended by users. The second goal was to provide marshaling support for a small and important set of data types. Based on customer feedback we know that strings are the most commonly marshaled set of data types and hence it is important to at least have support for them in the first version. Also, as the library has an extensible model, it can be easily extended by customers with marshaling conversions not currently supported by the library. With future versions of VC we definitely intend to support more marshaling conversions.

    I wonder what you think of the design whereby many data types could be marshaled via a single API, marshal_as<to_type>(from), as opposed to calling a different API for every conversion pair. Is the use of template syntax intuitive and natural for C++ programmers? Your opinions greatly appreciated!

    Thanks Sarita

    PS: In your sample code in MarshalString (String ^ s ) function you could potentially be leaking memory. The IntPtr returned from StringToHGlobalAnsi must be explicitly released using FreeHGlobal or a memory leak results.

  • Can we have the sample apps available for download? I'm having some problems creating split buttons and looking inside your demo app should help.

    Thank you,
    Marius Bancila,
    Microsoft MVP VC++
  • We are in the process of getting our samples out. When you create a Split Button, are you seeing an error like this “error RC2104 : undefined keyword or key name: BS_DEFSPLITBUTTON”. If yes this is a known error as the Windows SDK does not have the latest commctrl.rh in the March CTP. It is missing the definitions of all the new button styles. As a temporary workaround for now, you can manually add these styles in your targetver.h for each of the affected projects.

     

    // BUTTON STYLES

    #ifndef BS_SPLITBUTTON

    #define BS_SPLITBUTTON          0x0000000CL

    #endif

     

    #ifndef BS_DEFSPLITBUTTON

    #define BS_DEFSPLITBUTTON       0x0000000DL

    #endif

     

    #ifndef BS_COMMANDLINK  

    #define BS_COMMANDLINK          0x0000000EL

    #endif

     

    #ifndef BS_DEFCOMMANDLINK

    #define BS_DEFCOMMANDLINK       0x0000000FL

    #endif

     

    After including these, you should not have a problem creating Split Button or Command Button.

    Please let me know if there are other issues that are blocking you while using Split Button.

     

    Thanks Sarita

     

  • Haven't seen the video but:

    1. Thank you for improved standard conformance in VS.2005. I'd just like to point out that I'd never go back to VC6 from VS.2005 even though it compiles a tad slower. Also the error reportage from VS.2005 when dealing with templates has gone from hardly-useful (VC6) to really neat (VS.2005) (Except the occasional ICE),

    2. Yes, I would much prefer marshal_as<to_type>(from_type) instead of for instance marsh_as_string. Perhaps with some ability to inject custom marshalling for my used defined types? Also I prefer STL naming convention over the one used in MFC.

    3. Will Orcas support TR1?

    3. Regarding something completely different. GCC team is experimenting with template "varargs" ie a template class that can take arbitrary number of template parameters. That seems to be easy the certain meta-programming tasks alot. Something you're talking about? This isn't standard C++ I know but still.

    4. And since I'm on topic of non-standard C++. Is there hope for typeof in future Visual Studios?

    5. Lambda expressions?
  • Hey Marten, some responses for you:

    1. Thanks for the feedback!  I'll pass this onto the rest of the compiler team.  We're happy that our conformance efforts have helped you out.

    2. Thanks again for the feedback about the marshaling library.  We'll definitely consider that for a future release.

    3. Orcas will not contain TR1 although this is on our radar.  I recently visited the UK for ACCU 2007, and I received a lot of queries about TR1 and when we'll be including an implementation with our libraries.  We're currently looking several options to get TR1 out to you guys as soon as possible.

    3 [again? Smiley]. Variadic templates have (very) recently been added to the C++0x standard (proposal N2151).  While we don't have any plans to preemptively implement any new C++0x features, you can expect C++0x support in a future release.

    4. I'm not quite sure what you mean here.  If you are referring to a C# style typeof(type), then there exists an equivalent type::typeid for C++/CLI.  For native code, the typeid operator is the way you want to go, although I'd be curious to know if that meets your needs.

    5. Lambdas are C++0x proposal N1958.  I don't know the status on this proposal.  Like variadic templates, we wouldn't be implementing this feature (if it gets into the standard) until a future release when C++0x is ratified (and we figure out what that x stands for).  If it ends up not being in the standard, we may choose to implement if there is high customer demand for a scenario that lambdas would enable.

    I hope that helps!

    Peter-Michael Osera - PM, VC++ compiler team

  • Open in External Editor?!  gah! we need to edit icons and images within Visual Studio -- that functionality is sooooo overdue.
  • schroedl wrote:
    Open in External Editor?!  gah! we need to edit icons and images within Visual Studio -- that functionality is sooooo overdue.


    I'd like to clarify the reasoning behind the "open in external editor" functionality. Firstly, the Image Editor in Visual Studio 2008 supports icon editing; the experience has been significantly improved from VS2005 with the following features:
       - preview area for the multiple icon types inside an icon
       - icon type management for the new icon format (containing Vista compressed icon types)
       - viewing of 32bit images and Vista compressed icon types in an icon
       - updated RC support for these new file types
       - open in external editor for those who prefer their own editor instead of VS

    With that said, there are some scenarios that are still not supported in VS2008:
       - editing of 32bit images and PNGs
       - editing of the 32bit icon types and compressed icon types (Vista style) in an icon.
    Far from being ideal I agree, for these cases in particular we encourage customers to take advantage of the "Open in External Editor" option in the context menu.

    Marian Luparu
    Visual C++ IDE
  • Hi sarita

    I want to know about how to create split button in  VS2003.

    i searced in net where i got  CSplitButton class but it s work on VS2008.

    can u provide class for split button  which is suported by VS2003.

    I saw ur interview its really great and update comman control lib tat news for developer is soo cool.

    Abhishek
  • Hi Abhi,
    The  CSplitButton class will be avaliable only starting VS 2008 and we will not be providing it for VS 2003.
    Thanks Sarita 

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.