Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / MFC
Article

Using System Dialogs and link labels

Rate me:
Please Sign up or sign in to vote.
1.82/5 (7 votes)
8 Aug 2002 71.2K   602   18   2
This article describes the use of fontdialog and colordialog controls and illustrates the use of linklabel and helpprovider.

Sample Image - SystemDlg.jpg

Introduction

The purpose of the article is to illustrate the use of colordialog, fontdialog, linklabel and helpprovider. This is a simple demo of how they work.

This article illustrates one of my first C# code. I wanted to use MDI control and try out the linklabel control and the helpprovider control.

I had problems creating an About dialog box and hence I coded an application that uses system dialog to change the font and color of a text and the help provider opens the help HTML file, which displays the help message.

The name of the class is MainDlg, which comprises of a Label, colordialog, fontdialog and a helpprovider.

C#
private void menuItem2_Click(object sender, System.EventArgs e)
{
    fontDialog1.ShowDialog();
    label2.Font = fontDialog1.Font;
}

private void menuItem3_Click(object sender, System.EventArgs e)
{
    colorDialog1.ShowDialog();
    label2.ForeColor = colorDialog1.Color;
}

private void menuItem6_Click(object sender, System.EventArgs e)
{
    AboutDlg ne = new AboutDlg();
    ne.ShowDialog();
}

private void menuItem9_Click(object sender, System.EventArgs e)
{
    Help.ShowHelp(new MainDlg() ,"help.htm");
}

There is another class which is an inherited class called AboutDlg, this comprises of a linklabel , which carries an email ID.

By using the following code, the mail recipient is invoked.

C#
private void linkLabel1_LinkClicked_1(object sender, 
     System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
{
    linkLabel1.LinkVisited = true;
    System.Diagnostics.Process.Start("mailto:ragava@fastmail.ca");
}

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
Ragavendran was born in South India. He holds a Bacnelor of Computer Science and Engineering. Currently he works as a Software Engineer. He is techno Savvy and All he wishes to do in life is to get to know a lotta things....
He is always intrigued about learning new things.

His skills include C,C++,Java ,.NET.He also experience working in Legacy Systems. He feels most comfortable with C++ and Java.
Computers are his first love and he likes reading books, music and trekking.

He is a voracious reader and loves reading books. A Leo by birth, he loves trekking and gardening. One of his main ambitions is to write his autobiography, though he is not sure who will read it.

Comments and Discussions

 
GeneralMy vote of 1 Pin
Hou Tianze25-Nov-09 22:08
Hou Tianze25-Nov-09 22:08 
QuestionLinkLabel BUG ?? Pin
KHK26-Feb-03 11:37
KHK26-Feb-03 11:37 
Hi ,
I was trying to use LinkLabel control in a windows Forms application. I get the following error when I try to click on the link


See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ComponentModel.Win32Exception: The requested section was not present in the activation context
at System.Diagnostics.Process.StartWithShellExecuteEx(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName)
at EyeWonder.MainScr.eyeLabel_LinkClicked(Object sender, LinkLabelLinkClickedEventArgs e) in d:\working\backpak\eyepackapp\mainscr.cs:line 244
at System.Windows.Forms.LinkLabel.OnLinkClicked(LinkLabelLinkClickedEventArgs e)
at System.Windows.Forms.LinkLabel.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.WndProc(Message& m)
at System.Windows.Forms.LinkLabel.WndProc(Message& msg)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.288
CodeBase: file:///c:/windows/microsoft.net/framework/v1.0.3705/mscorlib.dll
----------------------------------------
EyePackApp
Assembly Version: 1.0.1152.31749
Win32 Version: 1.0.1152.31749
CodeBase: file:///D:/Working/BackPak/bin/debug/EyePackApp.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.288
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.3300.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.288
CodeBase: file:///c:/windows/assembly/gac/system/1.0.3300.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.288
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.3300.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.3300.0
Win32 Version: 1.0.3705.288
CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.3300.0__b77a5c561934e089/system.xml.dll
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
<system.windows.forms jitdebugging="true">


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.



Any idea what's happening ??
Cheers,
KHK

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.