Click here to Skip to main content
Licence 
First Posted 4 Jun 2007
Views 12,000
Downloads 195
Bookmarked 23 times

Titled Window Form

By | 8 Jun 2007 | Article
An article on a form that looks like a Windows Installer form

Screenshot - FormExample.png

Introduction

This article describes how to use the TitledForm class form with a nice view. The main idea in this project is to use simple .NET GDI to paint the necessary elements of a window -- such as lines, for example -- as well as to emulate text shadow.

Using the code

The first step is to create a new form; then you need to inherit from TitledForm. In order to do this, you have to add the TitledForm source file to your project, as outlined in the following code:

namespace TitledWindowTest
{
    public partial class Form1 : Chelindbank.Tools.WinForms.TitledForm
    {
        ///.......
    }
}

After this step, Form1 will have the parameters outlined below, which you can find in the Form Designer Properties window under the Titles section:

  • MainTitle - This is used to set the MainTitle label text in a caption at the top of the form.
  • Description - This is used to set the Description label text in a caption at the top of the form.
  • SubTitle - This is used to set the SubTitle label text at the bottom of the form.

Screenshot - ClearTitledForm.png

As a final step, you can set the parameters as follows:

void Form_Load(object sender, EventArgs e)
{
    this.Description = "Make your choise";
    this.MainTitle = "My application name";
    this.SubTitle = "The super app";
}

Changes

The latest update includes processing maximization and restoring of form state events. When the SubTitle label location is changed, we catch it and check if its state of form is Maximized. If it is, we invalidate the new region of the bottom line and invalidate the previous region of the line to clear it. To store the latest position of SubTitle and its line, we store its location after each resize.

private void TitledForm_ResizeEnd(object sender, EventArgs e)
{
    // .........<skipped>.........
    TitledForm_ResizeBegin(sender, e);
}
        
private void lblSubTitle_LocationChanged(object sender, EventArgs e) 
{ 
    /// Form is needed to be recalculated 
    if (WindowState == FormWindowState.Maximized) 
    { 
        IsMaximized = true; 
        TitledForm_ResizeEnd(sender, e); 
    } 
    else 
    /// Is needed to be recalculated again 
    if (WindowState == FormWindowState.Normal && IsMaximized) 
    { 
        IsMaximized = false; 
        TitledForm_ResizeEnd(sender, e); 
    } 
}

History

  • 4 June, 2007 -- Original version was posted to the main CodeProject.com article base
  • 8 June, 2007 -- Article and downloads updated (see Changes section)

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

About the Author

dr.TyGER (Konstantin)

Software Developer

Russian Federation Russian Federation

Member

I finished university few years ago - South-Ural State University (SUSU).
Now I'm working as a programmer in bank...
And I'm trying to specialize in several sphere:
 
Programming: .NET, C++, Java;
Technology: J2EE (Oracle Application Server);
DataBases: Oracle, MSSQL, Microsoft JET;
Web: ASP, JavaScript, XML+XSLT, HTML making-up;
Using cryptography...

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionTitledForm or UserControl? Pinmemberbocca0111:25 8 Nov '09  
AnswerRe: TitledForm or UserControl? Pinmemberdr.TyGER (Konstantin)23:21 8 Nov '09  
Generalerror when maximzed form Pinmemberadamsdigiark19:43 4 Jun '07  
GeneralRe: error when maximzed form Pinmemberdr.TyGER21:07 4 Jun '07  

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

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

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 8 Jun 2007
Article Copyright 2007 by dr.TyGER (Konstantin)
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid