Windows Develop Bookmark and Share   
 index > Windows Forms General > Status Bar in COM Interop
 

Status Bar in COM Interop

Right, so here's a nice complex question for you all...

I have a .NET implementation of a namespace extension framework that I've modified to return the IntPtr (handle) to the Explorer Status Bar control using IShellBrowser::GetControlWindow() with FCW_STATUS.

I retrieve the handle and it's not equivalent to IntPtr.Zero.

The problem lies in that I use the .NET StatusBar control and perform the following call:

Code Snippet

IntPtr statusBarHandle = this.GetStatusBarHandle(); //Does the GetControlWindow() call
StatusBar status = (StatusBar) StatusBar.FromHandle(statusBarHandle);



"status" is always null, but the handle is obviously valid as the MSDN documentation on GetControlWindow() states that if a control cannot be accessed that the handle returned will be NULL.

So what I'm essentially asking is this: How do I take the handle I receive back from GetControlWindow() and bind it to a .NET control which I can then manipulate?
Toadflakz  Thursday, July 19, 2007 8:04 AM
The only option you have is NativeWindow. Create a derived class from it and bind it to the shell control handle with the Attach() method. Override WndProc() to process the windows messages.
nobugz  Friday, July 20, 2007 12:31 PM
Control.FromHandle() can only return managed Control instances that were created with the "new" operator and were instantiated by their CreateHandle() method. Are you confusing a native shell taskbar with a .NET StatusBar control?
nobugz  Thursday, July 19, 2007 4:02 PM
I think I might be then... Is there anyway to bind that native shell control to a .NET control in order to manipulate it? Or am I going to have to write a COM ATL/MFC component to do that for me?
Toadflakz  Friday, July 20, 2007 7:35 AM
The only option you have is NativeWindow. Create a derived class from it and bind it to the shell control handle with the Attach() method. Override WndProc() to process the windows messages.
nobugz  Friday, July 20, 2007 12:31 PM

You can use google to search for other answers

Custom Search

More Threads

• Update
• New form stuck in loop?
• Check instance for simple desktop application??
• protection against date/time tempering
• Howto reduce long text to view region in the textbox with the finalize "..."
• How do I get the table to accept input into a form written via a program.
• using windows addressbook
• need help in form mouse event
• How to change the display text to a custom one on propertygrid control
• Register your own file types, but how to set the default Icon?