HOWTO: Web-like table w/ links (similar to solution list in VS.NET start page)
-
I'm trying to create something similar to the start page for my application. I'd ideally like to have a table with small icons that I can trap the OnClick event. The contents of the table are dynamic. One option is to make a webcontrol of sorts that I fill with HTML. Problem is how to trap those events. Prefer to do it without IE (just another control to check for on the install). I would like to stay away from the WinForm grid control and have something more along the lines that looks similar to the VS.NET start page or the Groove Welcome page (http://www.groove.net/products/popup/workspace/welcome.html). Any ideas? Andrew Connell, MCDBA IM on MSN andrew@aconnell.com
-
I'm trying to create something similar to the start page for my application. I'd ideally like to have a table with small icons that I can trap the OnClick event. The contents of the table are dynamic. One option is to make a webcontrol of sorts that I fill with HTML. Problem is how to trap those events. Prefer to do it without IE (just another control to check for on the install). I would like to stay away from the WinForm grid control and have something more along the lines that looks similar to the VS.NET start page or the Groove Welcome page (http://www.groove.net/products/popup/workspace/welcome.html). Any ideas? Andrew Connell, MCDBA IM on MSN andrew@aconnell.com
It is easy :-D Once your web page is designed (just steal the Start page code from VS.NET, right click / View source. Jeecool!), just add onclick events, and add window.external.myMethod calls. Now in your app hosting the web browser, you have a IDispatch interface exposing myMethod(), and this will get automatically called. I have to admit that you'll get more easily done with full C++ code, because of the IDocHostUIHandler/IDispatch declaration and implementation. For code sample, download the Driller sample from MSDN. Be warned that both the VS.NET Start page, and other html pages using window.external, and HTA applications require ActiveX scripting be enabled on the user's browser settings.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
-
It is easy :-D Once your web page is designed (just steal the Start page code from VS.NET, right click / View source. Jeecool!), just add onclick events, and add window.external.myMethod calls. Now in your app hosting the web browser, you have a IDispatch interface exposing myMethod(), and this will get automatically called. I have to admit that you'll get more easily done with full C++ code, because of the IDocHostUIHandler/IDispatch declaration and implementation. For code sample, download the Driller sample from MSDN. Be warned that both the VS.NET Start page, and other html pages using window.external, and HTA applications require ActiveX scripting be enabled on the user's browser settings.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
I took a look at the Driller, but it didn't help me as much as I had hoped. Lemme give it a shot... StephaneRodriguez wrote: add window.external.myMethod calls So.... the onclick event is easy... is the syntax just:

StephaneRodriguez wrote: Now in your app hosting the web browser, you have a IDispatch interface exposing myMethod(), and this will get automatically called. So... that code would look something like (in C#)...public void Button1Clicked(string p1, string p2) : IDispatch { MessageBox.Show("Dynomite!"); }
Sorry... this is greek to me... thanks for your first post :) Andrew Connell, MCDBA IM on MSN andrew@aconnell.com -
I took a look at the Driller, but it didn't help me as much as I had hoped. Lemme give it a shot... StephaneRodriguez wrote: add window.external.myMethod calls So.... the onclick event is easy... is the syntax just:

StephaneRodriguez wrote: Now in your app hosting the web browser, you have a IDispatch interface exposing myMethod(), and this will get automatically called. So... that code would look something like (in C#)...public void Button1Clicked(string p1, string p2) : IDispatch { MessageBox.Show("Dynomite!"); }
Sorry... this is greek to me... thanks for your first post :) Andrew Connell, MCDBA IM on MSN andrew@aconnell.comDrill has the plumbering you need, but it does it using C++. You obviously need it using C#. Let's see the key code, in the driller app, the class which implements and subscribes for the custom (window.)external handler is attached like this :
// driller.cpp
// Create a custom control manager class so we can override the site
CCustomOccManager *pMgr = new CCustomOccManager;// Create an IDispatch class for extending the Dynamic HTML Object Model
m_pDispOM = new CImpIDispatch;// Set our control containment up but using our control container
// management class instead of MFC's default
AfxEnableControlContainer(pMgr);So you need your hosting app implement a control site. Searching the .NET framework for the equivalent stuff, I found this[^] :
[C#]
protected virtual ISite CreateSite(
IComponent component,
string name
);The above method must be implemented by your code, and it will be called by the framework when the app is started. The implementation of this method must do what the C++ code does, ie provide implementation for the IDocHostUIHandler. In this implementation, that's
GetExternal
which attaches the site to a class of yours. This class implements IDispatch and implements any number of methods, among whichmyMethod
: the one that gets called with the javascript code. I know that's hard using C++ already, but trying to do it using C# is just harder. That's questionable.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
-
Drill has the plumbering you need, but it does it using C++. You obviously need it using C#. Let's see the key code, in the driller app, the class which implements and subscribes for the custom (window.)external handler is attached like this :
// driller.cpp
// Create a custom control manager class so we can override the site
CCustomOccManager *pMgr = new CCustomOccManager;// Create an IDispatch class for extending the Dynamic HTML Object Model
m_pDispOM = new CImpIDispatch;// Set our control containment up but using our control container
// management class instead of MFC's default
AfxEnableControlContainer(pMgr);So you need your hosting app implement a control site. Searching the .NET framework for the equivalent stuff, I found this[^] :
[C#]
protected virtual ISite CreateSite(
IComponent component,
string name
);The above method must be implemented by your code, and it will be called by the framework when the app is started. The implementation of this method must do what the C++ code does, ie provide implementation for the IDocHostUIHandler. In this implementation, that's
GetExternal
which attaches the site to a class of yours. This class implements IDispatch and implements any number of methods, among whichmyMethod
: the one that gets called with the javascript code. I know that's hard using C++ already, but trying to do it using C# is just harder. That's questionable.
MS quote (http://www.microsoft.com/ddk) : As of September 30, 2002, the Microsoft® Windows® 2000 DDK, the Microsoft Windows 98 DDK, and the Microsoft Windows NT® 4.0 DDK will no longer be available for purchase or download on this site.
StephaneRodriguez wrote: I know that's hard using C++ already, but trying to do it using C# is just harder. Thanks... looks like I need to keep looking because C++ is greek to me. You got me going in the right direction. Andrew Connell, MCDBA IM on MSN andrew@aconnell.com
-
StephaneRodriguez wrote: I know that's hard using C++ already, but trying to do it using C# is just harder. Thanks... looks like I need to keep looking because C++ is greek to me. You got me going in the right direction. Andrew Connell, MCDBA IM on MSN andrew@aconnell.com
I got a reply to my similar posting on GotDotNet[^] by an MS guy. He has a work around that seems VERY easy and not too hacky. :-D What he said he did is to use a 'fake' hyperlink and used the
BeforeNavigate2
event to find out what the hyperlink URL is. I'm going to try this as it seems like a good solution for me. My URL will be a flag like<a href="OpenCollection.1">
and I'll just have a switch statement inside myBeforeNavigate2
event handler method. -AC