Outlook 2003 Style Navigation Pane


This control has been developed according to Microsoft Office 2003 controls. Most of the properties are included. However, there is no support yet for the "Design Time" property. This control contains five sub-controls:

  1. Title: This section is at the top of the control. The property describes the control and is also the visible control indicated on the button.
  2. Title explanation: This section is under the title info, which should hold long info rather than the title info. If the title was not defined, this control uses the title. Visible control is indicated on the button.
  3. Related control: This control shows when the button is selected and is not moveable. This property has to indicate on the control when the control is added. Furthermore, this control is shown on the button. If this control was not added on the button, the control will shown only a panel.
  4. Buttons: This object is dependent on the control. Almost all properties are contained in this control.
  5. Carrying panel: The buttons can add onto the carrying panel. If this situation is not possible, the buttons will be added on the menu.Screenshot - Outlook_Navigation_Pane.JPG

NavigateBar Control

This navigate bar must be used in a carrier panel. It will be deployed on the included control. All of the controls specified above come up within this control. Briefly:

Properties

  • NavigateBarButtons: Collection that carries NavigateBarButton controls. New button can be added here.
  • NavigateBarButtonHeight: Every new button uses this value for height info.
  • NavigateBarDisplayedButtonCount: Maximum number of buttons can be added on the panel. Default is all buttons if it is not set.
  • SelectedButton: Holds selected or picked-out button info.
  • NavigateBarColorTable: Contains color settings for Panel and Sub-controls. System defaults valid when undefined. It is possible to customize.
  • SaveAndRestoreSettings: Each application saving a different location. For save and restore, you must setNavigateBarButton.KEY values. Default settings result in file saves in XML file format in the %APPDATA%\AppExeFileName folder. You can set any disk location and file name.
  • IsCollapsible: Is it a collapsible pane? Default is true.
  • IsShowCollapseButton: Show collapse button on the caption band.
  • IsCollapsedMode: Get collapsible mode state.
  • IsShowCollapsibleScreen: If pane width is smaller than minimum size, is it displayed as a collapsible screen?
  • IsUseRTLforButtons: Use RightToLeft for buttons.
  • IsUseRTLforMenus: Use RightToLeft for context menus.
  • IsCollapsibleScreenShowNow: Is it displayed as a collapsible screen?
  • IsCollapseScreenShowOnButtonSelect: Is it shown as a collapsible screen when button is clicked?
  • CollapsibleScreenWidth: Collapsible screen width.
  • CollapsibleWidth: Required panel width for collapsible mode.
  • RelatedControl: If Button.RelatedControl is empty, then display this control.
  • OverFlowPanelHeight: Get or Set overflow panel height.
  • DisplayedButtonCount: Get or Set displayed button count in panel.
  • AlwaysUseSystemColors: Get or Set; if always use system colors, set as true.

Methods

  • ChangeCollapseMode: If collapsible, then changes the collapse mode.
  • ChangeButtonPosition: Sets new position in panel and collection for button.
  • ShowCollapseScreen: If collapsed mode, then shows collapse screen.
  • HideCollapseScreen: If collapsed mode, then hides collapse screen.
  • RunMenuOptionsDialog: Open Navigatebar "Menu Option" form.

Events

  • OnNavigateBarButtonHeightChanged: Triggers when button height is changed. Displays old and new values.
  • OnNavigateBarButtonAdded: Triggers when new button is added. Displays new button's info.
  • OnNavigateBarButtonRemoved: Triggers when existing button is removed. Displays removed button's info.
  • OnNavigateBarButtonSelecting: Triggers when a button is selecting.
  • OnNavigateBarButtonSelected: Triggers when a button is selected. Displays selected button's info.
  • OnNavigateBarDisplayedButtonCountChanged: Triggers when displayed button count is changed.
  • OnNavigateBarCollapseModeChanged: Triggers when collapse mode is changed.
  • OnNavigateBarColorChanged: Triggers when the color table is changed.

NavigateBarButton Control

This contains the button info that is added into the panel. The button is the main object of control and almost all properties are saved on it. Briefly:

Properties

  • Caption: This is the text info on the button and also its panel title. It will also be used for ToolTipText if ToolTipText has not been set.
  • CaptionDescription: Description of the panel title.
  • RelatedControl: The control that displays on the panel when the button is selected. Panel with notification message will display when it is undefined.
  • Key: Each one is a unique value in the collection. This value is used for save and restore.
  • Image: Holds picture info. 24x24 size is recommended. This picture will be used when it is disabled. It is an alternative to use. When this picture does not exist, one default picture will be added in OverFlowPanel.
  • MouseOverImage: Picture info when mouse points on it. Image info will be used when it is undefined.
  • SelectedImage: Picture info when it is selected. Image info will be used when it is undefined.
  • IsSelected: Saves if button is selected or not.
  • IsDisplayed: Saves if button display is in the panel or not.
  • IsAlwaysDisplayed: Don't change the IsDisplayed state. Always shows NavigateBarButton.
  • IsShowCaption: Saves display of title on panel or not when the button selected.
  • IsShowCaptionDescription: Sets display of panel description when the button is selected.
  • Font: Button's font info.
  • ForeColor: Button's font color info.
  • ToolTipText: The text info that is shown when button and overflow panel are not big enough.
  • DefaultButtonHeight: Button's default height info. Defined as static.
  • MinimumButtonHeight: Minimum height info that the button can have. Defined as static.
  • CollapsedScreenWidth: Collapse screen width for this button.
  • IsShowCollapseScreenCaption: Show caption band on collapse screen.

Methods

  • PerformClick: Run button's selected event manually.

Events

  • OnNavigateBarButtonSelected: Triggers when a button is selected. First, it kicks off here and then kicks off the part in the mainNavigationBar.
  • OnNavigateBarButtonCaptionChanged: Triggers when the button title info is changed. Displays old and new values.
  • OnNavigateBarButtonCaptionDescriptionChanged: Triggers when the button title description info is changed. Displays old and new values.
  • OnNavigateBarButtonDisplayChanged: Triggers when the button's display settings info in the panel is changed. Displays old and new values.

Using the Code


History

  • 11.07.2007: Version 2.6.4
    • Added: If deactivate or change application, close collapse screen.
    • Improved: Collapse screen show method.
    • Fixed: Splitter resize problem.
  • 08.31.2007: Version 2.6.3
    • Improved: Collapse button click.
    • Removed: Unused methods from NavigateBarHelpers.cs.
    • Fixed: If unsave setting, then changing button position.
    • Fixed: Button's right click menu closing, then paint.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

->Read More...

Hot Control panel Pro C# Source


Sample Image - untitled1.gif

A quick peak at the Applet Viewer Window displaying the applets in large icon mode.

Sample screenshot

Now viewing in details view. Notice the name and description displayed for each applet.

Sample screenshot

And finally notice an applet that has just been launched by double clicking its icon. This demonstrates the applets are really being hosted by the applet engine.

Assumptions

This article assumes a basic understanding of writing unmanaged C/C++ dynamic link libraries and exporting functions from those libraries. Also basic understanding of using P/Invoke to access unmanaged libraries will benefit the reader, but I will attempt to explain as much as possible.

Abstract

The purpose of this article is to discuss several problems a developer might face when attempting to mix unmanaged and managed code. A problem that is all too often encountered when attempting to interact with the current Windows API from a managed language such as C# or VB.NET. In this article, I will discuss the problems I faced and how I solved the problems using a combination of managed and unmanaged code, C# and VC++ respectively. Here is a brief overview of what you can learn by reading this article:

  • Calling unmanaged function pointers
  • Dynamically loading unmanaged libraries at runtime
  • Acquiring function pointers to unmanaged functions
  • Translating C/C++ structures and data types to CLR compliant code
  • Finding alternatives to unsafe code for the purposes of using sizeof
  • Allocating/deallocating memory on the stack
  • Understanding how applets can be manipulated programmatically
  • Extracting strings and icons from embedded resources located in external unmanaged libraries.

Background

So let’s begin by discussing why I decided to write this article and code. Being the curious coder I am, I am always intrigued by the underlying implementation of features in the Windows operating system. Control panel applets have always been a somewhat uncovered topic for some reason, yeah there is documentation on them in the MSDN library, but rarely any good working examples. Let along how they actually work. Before I set out to write this article, I already had a pretty good understanding of how applets are written, having written several as a professional developer in the past. However, it wasn’t until I stepped into shell development that I became completely curious just how Windows pulled off these wonderfully useful creatures.

As days went by developing my shell, I came across many methods for actually launching control panel applets from code. Most of the implementations involved hard coding references to rundll32.exe to call the Control_RunDLL function with various arguments to launch off control panel applets. This always bothered me, because this was far from dynamic, you had to know about the applets ahead of time, at least somewhat to figure out how to launch them. I decided I wanted a means to enumerate and host the applets just like Windows.

So having said the why, let’s discuss what an applet actually is. By the way, all of the information presented here is my personal dissection of the documentation found in the MSDN library. Control panel applets are nothing special, simply .dlls built with a special extension, .cpl, and placed into the Windows system directory. If you were to attempt to write one, you would have to choose a language that creates unmanaged DLLs and allows for exporting of unmanaged functions. Something that C# and VB just don’t do, so look to C++ or Delphi to pull this off. It’s not all that hard, but it’s beyond the scope of the article.

Now that we know what an applet is, an unmanaged DLL compiled with a .cpl extension, let's look at how they work. Digging into the documentation, you will discover the CplApplet function. It is the sole function an applet must export from its library to interface with Windows. The function looks like this:

Collapse
LONG CPlApplet(HWND hWnd, UINT uMsg, LPARAM lParam1, LPARAM lParam2);

The function is very similar to the WndProc functions behind all windows. All communication to applets occurs through this function. You do not need to understand anything more about this function for now. If you are interested, do a search for CPlApplet in the MSDN library and you will have the pleasure of translating this wonderful function just as the rest of us were forced to do.

Ok, so let’s review what we know about applets. This will be the foundation of how we discover and communicate with all applets:

  • An unmanaged Windows dynamic link library
  • Uses the .cpl extension instead of the standard .dll extension
  • Exports a single function called CPlApplet
  • All applets should be located in the Windows System directory
  • http://www.codeproject.com/KB/cs/appletengine.aspx
->Read More...

Windows XP style Collapsible Panel Bar


Sample Image - CollapsiblePanelBar.gif

Introduction

In Windows Explorer under Windows XP, when you hide the Folder View, you get a rather snazy bar that contains a series of collapsible panels that provide shortcuts to common tasks based on the context of the current view. What I wanted was a control that emulates this functionality. What I came up with was an extended System.Windows.Forms.Panel class, CollapsiblePanel, that provides (as the name suggests) the collapsible panel functionality. CollapsiblePanel allows you to define a gradient fill for the background of the title bar, an image list for the expand/collapse button and an image to display on the left hand side (if you want). To try and make this hang together as a Windows XP-like bar, I also created the CollapsiblePanelBar. This is another extended System.Windows.Forms.Panel, but this one adds some useful design-time support. As you add CollapsiblePanels to the CollapsiblePanelBar, it's anchor properties are set to Left, Right and Top and it's position is set just below the previous panel. I'm currently developing on Windows NT, so properly rendering the panels with the current theme settings was irrelevant and so that feature remains on the TODO list.

Full-featured XP Style Collapsible Panel


Updates

Version 1.2 provides the ability to change the LinearGradientMode of the Caption and Panel gradients, and includes a few small bug fixes. The implementation now overrides DisplayRectangle which allows Docking and Anchoring of child controls to work as expected.

Version 1.1 provides two new layout controls and a small number of new features that simplify the creation of more sophisticated layouts and effects. The additions and changes for version 1.1 are listed at the end of the article.

Introduction

After reviewing quite a few of the collapsible panel style controls (both Open Source and commercial), I decided to write XPPanel to achieve a high quality, feature rich control that provided reasonably tight integration with the Visual Studio IDE.

The primary features I need from a Collapsible panel are:

  • Animated Expand/Collapse w/ Transparency
  • Gradient colors for both caption and panel
  • Customizable radius for caption rounded corners
  • Multi-line caption text
  • Support for images on both the left and right sides of the caption
  • Support for four image states (Normal, Highlight, Pressed, and Disabled)
  • Image transparency
  • Stand-alone panel (not part of a panel group)
  • A Panel Group to contain/manage individual panels
  • Fixed size and non-collapsible panels
  • Intelligent gray-scale rendering when disabled
  • Good integration with the Visual Studio IDE
  • Resource efficient
  • TextLayoutPanel and ItemLayoutPanel controls that dynamically resize based on content

Background

The real compelling reason for writing XPPanel was that I just needed to write some code. After weeks of writing software requirements, I was definitely having withdrawal. As I had spent a fair amount of time away from UI code, I thought it would be fun to get back into the swing of things by writing a new control. Unlike most of you, my experience with Windows XP has been limited, but by coincidence, I recently moved my primary development system from Windows 2000 Server to Windows XP Professional. Of course, I was bombarded with UI elements containing collapsible panels, and ergo, I figured why not?

Of course, I did my homework on the currently available implementations of collapsible panels, and I found two that were both high quality and had reasonable feature sets. I am happy to say that both projects are hosted on CodeProject and can be found at the following links:

Still, although I was impressed with various aspects of both, neither really fit the set of requirements that I wanted for my implementation. I actually thought about merging the two different projects to try and get a better control, but in the end, I decided to write my own implementation and borrow good techniques from those articles (as well as a few other CodeProject based articles!).

Even with good starting points for my control, I faced a bit of an uphill battle with getting the level of IDE designer support I desired, and although I struggled to get it all to work, in the end, I am moderately happy with the results.

Copy right http://www.codeproject.com/KB/miscctrl/TgXPPanel.aspx

->Read More...