Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Best design approach...

Hi,

I have a Win Forms 2.0 client that has to show several URL links to the user. My first approach to this is to use the ToolstripLabel control, set its properties and code the click event. Now what I'm trying to do is wrap all the code in the toolstriplabel click event in a C# class library and call the class method from the click event. So, this is what I'm doing:

Instead of using Process.Start (need to hardcode the browser executable as the first parameter), I'm relying on ShellExecute Win32 API call. If this call returns a error code of <=32, I'm displaying a Message box that basically tells the user that there is no default browser set and when the user clicks OK in the Messsge box, I use GetOpenFileName Win32 API call to show the file open common dialog to enable the user to select the browser executable file that he/she wants to set it as the default browser. Once he selects the browser executable, I write to the HTTP\shell\open\command in the client machine registry and again call ShellExecute API.

I have couple of questions:

1. Can I show a message box from within a C# class library? Remember, the good old days that says that we should not display message boxes in a ActiveX DLL.

2. Can I use GetOpenFileName API from within the class library since this call also shows a modal file open dialog.

3. Is this a valid design (WinForms 2.0 calls a C# class library and the class library shows modal dialogs and also does the work of executing the URL set in the toolstriplabel control)?

4. Lastly, what is the difference between LinkLabel and ToolstripLabel control?

Alternatively, instead of displaying message box from the class library, can I return the error code from ShellExecute API as a enum return value and the WinForms developer will check for the return type and then call the file open common dialog by adding the file dialog control on the form and then call a second method to do rest of the work? The reason, I'm asking this is that the first technique makes only a single call to my method but my second technique involves 2 separate methods (first call to ShellExecute as method1 and next call method2 to do the work after the client has selected the file in the file common dialog.

Sorry for the long post.

Rgds.

vs2006
[2389 byte] By [vs2006] at [2007-11-11 9:42:33]