More servicesWindows Live
HomeHotmailSpacesOneCare
 
MSN
Sign in
 
 
Spaces home  John Stewien's Road To S...ProfileFriendsFilesMore Tools Explore the Spaces community

Public folders

Folders shared with the world

John Stewien's Road To Somewhere Else

Programming in WPF (.NET 3.0) and moving to Taiwan
8/27/2008

John escapes from Perth in.....

I've put up a countdown for when I leave Perth here:

John escapes from Perth in

8/22/2008

Violet making Crazy Frog sounds

Hey does this remind anyone of the Crazy Frog?

 

Nearly Walking

By the time I get back to Taiwan Violet will be walking I think:

DSC03154

8/12/2008

Different ways of showing a C# dialog from Managed C++ or C++/CLI

Here are 3 different behaviours for showing a C# dialog from a C++ application:

  • Modal
  • Non-modal clipped by parent
  • Non-model not clipped by parent

Code examples are below to show how to use each. Note that for the non-modal non-clipped call to SetWindowLongPtr the flag GWLP_HWNDPARENT doesn’t appear in the documentation for SetWindowLongPtr. That’s because the owner for a window can’t be changed after it is created, however  GWLP_HWNDPARENT is the offset flag for reading the owner as seen in the GetWindowLongPtr documentation, so it can be written to before the window is shown and be used to set the owner.

 

// Wrapper for a HWND
public
__gc class WindowWrapper : public IWin32Window { // Managed C++ (VS2003)
public ref class WindowWrapper : public IWin32Window { // C++/CLI (VS2005+)
private:
      IntPtr _hwnd;
public:
      WindowWrapper(IntPtr handle){
            _hwnd = handle;
      }
 
      IntPtr get_Handle(){
            return _hwnd;
      }
};

void OpenDialog(HWND hwnd){ // hwnd is the main window
      // use one of the following depending on which version of .NET you are using
      TestDialog __gc* dialog = new TestDialog(); // Managed C++ (VS2003)
      TestDialog^ dialog = gcnew TestDialog(); // C++/CLI (VS2005+)

      // Note that the following code snippets are mutually exclusive, only use 1
     
// Show modal
      dialog->ShowDialog(new  WindowWrapper(hwnd));

 
      // Show non-modal with parent clipping child
      SetParent((HWND)dialog->get_Handle().ToPointer(),hwnd);
      dialog->Show();

 
      // Show non-modal without parent clipping child
      SetWindowLongPtr((HWND)overlay->get_Handle().ToPointer(), GWLP_HWNDPARENT, (LONG_PTR)hwnd);
      dialog->Show();
}

 

 

8/11/2008

Visual Studio Command Prompt Explorer Context Menu

I keep on reinventing the wheel every time I'm at a new place of work and want a Visual Studio Command Prompt Explorer Context Menu, so I'm going to put the contents of a reg file here so that I can find it easily in the future when I need it. Here's the entry for a Visual Studio 2003 command prompt, but something similar would also apply for Visual Studio 2005 and 2008:

Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\Folder\shell\VS2003 Command Prompt\command]
@="cmd.exe /k pushd %1&\"C:\\Program Files\\Microsoft Visual Studio .NET 2003\\Common7\\Tools\\vsvars32.bat\""

View more entries
 
View space
(no name)
View space
Boris
View space
Jasmine