Ray Konopka Developing Custom VCL and VCL.NET Component Designers DevCon 2005 -- Course No: 3146.

Slides:



Advertisements
Similar presentations
15 Copyright © 2005, Oracle. All rights reserved. Adding User Interface Components and Event Handling.
Advertisements

JustinMind: Dynamic Panels
Using Macros and Visual Basic for Applications (VBA) with Excel
110-H1 More VB Tools Creating a Menu: What is a menu? a group of (related) commands displayed at at the top of an application Top level menu Disabled command.
Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures Copyright © 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Chapter 13: Advanced GUI and Graphics
Introduction To Form Builder
Creating Menu. Objectives Create a menu system for a form –Create a menu –Create a menu titles –Create a menu items –Create a submenu –Modify menu –Edit.
6 th Annual Focus Users’ Conference Application Editor and Form Builder Presented by: Mike Morris.
Education Google Calendar (GCal) English. Education Upon completion of this course, you will be able to:  Navigate the GCal interface  Search your calendar.
Lesley Bross, August 25, 2010 ArcGIS 10 Add-In Components and Controls.
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
Chapter 8: String Manipulation
Programming with Microsoft Visual Basic th Edition
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
1 Graphical User Interfaces Part 2 Outline Multiple Document Interface (MDI) Windows Visual Inheritance User-Defined Controls.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Microsoft Visual Basic 2012 Using Procedures and Exception Handling CHAPTER SEVEN.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
1. Chapter 18 Managing Lists 3 Working with Lists and Symbols Set off important information by formatting it as a bulleted or numbered list. Customize.
5-1 aslkjdhfalskhjfgalsdkfhalskdhjfglaskdhjflaskdhjfglaksjdhflakshflaksdhjfglaksjhflaksjhf.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Chapter 8: Writing Graphical User Interfaces
McGraw-Hill © 2009 The McGraw-Hill Companies, Inc. All rights reserved. Chapter 5 Menus, Common Dialog Boxes, Sub Procedures, and Function Procedures.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Typing Application Introducing Keyboard Events, Menus, Dialogs and the Dictionary.
Automating Database Processing Chapter 6. Chapter Introduction Design and implement user-friendly menu – Called navigation form Macros – Automate repetitive.
Chapter 5 Menus, Common Dialog Boxes, and Methods Programming in C#.NET © 2003 by The McGraw-Hill Companies, Inc. All rights reserved.
Workbench Overview Dwight Deugo Nesa Matic
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Ray Konopka Developing Custom.NET Component Designers DevCon Course No: 4106.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
1 Extend is a simulation tool to create models quickly, with all the blocks you need and without even having to type an equation. You can use a series.
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
1 אירוע אמאזון. 2 שלבי הפיתוח עם דיאגרמות UML 3 אמאזון תרשים תוכן.
Lection №5 Modern integrated development environment.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Graphical Enablement In this presentation… –What is graphical enablement? –Introduction to newlook dialogs and tools used to graphical enable System i.
Copyright © Curt Hill More Components Varying the input of Dev-C++ Windows Programs.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Microsoft Visual Basic 2012 CHAPTER ELEVEN Multiple Classes and Inheritance.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Slide 1 Using Menu Bar & Common Dialog Boxes. Slide 2 Setting Up the Main Items v First open the form on which you want the menu located v Then start.
Programming with Microsoft Visual Basic 2008 Fourth Edition Chapter Eight String Manipulation.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
Basics of Windows 95/98/NT. Versions of Windows Windows 95 and 98 used mainly on standalone computers Windows NT used on networked computers (as in our.
14 Copyright © 2004, Oracle. All rights reserved. Enhancing the User Interface.
TIU Note Templates. Learning Objectives Discuss Human Factor Internationals (HFIs) recommendations for Text Integration Utility (TIU) Templates Become.
Creating Menus Menu Bar – behaves like standard Windows menus Can be used in place of or in addition to buttons to execute a procedure Menu items are controls.
Copyright (c) 2003 by Prentice Hall Provided By: Qasim Al-ajmi Chapter 2 Introduction to Visual Basic Programming Visual Basic.NET.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Object-Oriented Application Development Using VB.NET 1 Chapter 11 Using Multiple Forms with Problem Domain Classes.
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
Visual Basic.NET BASICS Lesson 14 Menus and Printing.
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
LC++ programming in Windows environment Department of Information Engineering INFORMATION TECHNOLOGY dr. László Dudás 10./0. lThe Visual Component Library.
Chapter 7 Multiple Forms, Modules, and Menus. Section 7.2 MODULES A module contains code—declarations and procedures—that are used by other files in a.
Multiple Classes and Inheritance
Using Procedures and Exception Handling
Using Cascading Style Sheets (CSS)
Courses Tab Press the Courses tab
Presentation transcript:

Ray Konopka Developing Custom VCL and VCL.NET Component Designers DevCon Course No: 3146

2 Agenda The Delphi design-time environment Property Editors TAlign property editor Integer property editor Component Editors TButton component editor TListBox component editor TRadioGroup component editor The Delphi design-time environment Property Editors TAlign property editor Integer property editor Component Editors TButton component editor TListBox component editor TRadioGroup component editor

3 The Design-Time Environment Object Inspector uses property editors to Display individual property values Edit individual property values Form Designer uses component editors to Edit component as a whole Add items to context menu Respond to double clicks Object Inspector uses property editors to Display individual property values Edit individual property values Form Designer uses component editors to Edit component as a whole Add items to context menu Respond to double clicks

4 Important Points Design editors work seamlessly within the design environment Properties and components are not aware of the editors Delphi uses It is possible to replace an existing editor. Design editors work seamlessly within the design environment Properties and components are not aware of the editors Delphi uses It is possible to replace an existing editor.

5 Property Editors Why create custom property editors? Provide an alternate way of editing a property Supply a drop-down list with predefined values Display a custom dialog to modify the property visually Support a non-standard custom property Why create custom property editors? Provide an alternate way of editing a property Supply a drop-down list with predefined values Display a custom dialog to modify the property visually Support a non-standard custom property

6 Property Editor Tasks Convert property value Native Format  string Define how the property can be edited Inline - within the Object Inspector Dialog - using a separate dialog box. Convert property value Native Format  string Define how the property can be edited Inline - within the Object Inspector Dialog - using a separate dialog box.

7 Standard Property Editors All property editors descend from TPropertyEditor Defined in the following units DesignIntf DesignEditors VclEditors DesignMenus For VCL.NET, must prefix namespace Borland.Vcl.Design.DesignIntf Borland.Vcl.Design.DesignEditors Borland.Vcl.Design.VCLEditors Borland.Vcl.Design.DesignMenus. All property editors descend from TPropertyEditor Defined in the following units DesignIntf DesignEditors VclEditors DesignMenus For VCL.NET, must prefix namespace Borland.Vcl.Design.DesignIntf Borland.Vcl.Design.DesignEditors Borland.Vcl.Design.VCLEditors Borland.Vcl.Design.DesignMenus.

8 TIntegerProperty TCharProperty TCursorProperty TPropertyEditor TEnumProperty TOrdinalProperty TColorProperty TClassProperty TFloatProperty TSetElementProperty TStringProperty TStringListProperty TCaptionProperty TFontProperty TMethodProperty TComponentProperty TSetProperty TFontNameProperty

9 Creating a New Property Editor Create a descendant of TPropertyEditor Usually descend from standard editor Ensure Value property works properly Not a concern if inheriting from standard editor Define the editing capabilities of the editor Implement appropriate interface methods Register the property editor. Create a descendant of TPropertyEditor Usually descend from standard editor Ensure Value property works properly Not a concern if inheriting from standard editor Define the editing capabilities of the editor Implement appropriate interface methods Register the property editor.

10 Implementing GetValue Use the following methods to get the value stored in the property GetFloatValue, GetInt64Value, GetOrdValue, GetStrValue, GetMethodValue, GetVarValue For object references GetOrdValue in VCL GetObjValue in VCL.NET Use the following methods to get the value stored in the property GetFloatValue, GetInt64Value, GetOrdValue, GetStrValue, GetMethodValue, GetVarValue For object references GetOrdValue in VCL GetObjValue in VCL.NET function TIntegerProperty.GetValue: string; begin Result := IntToStr( GetOrdValue ); end; function TIntegerProperty.GetValue: string; begin Result := IntToStr( GetOrdValue ); end;

11 Implementing SetValue Use the following methods to set the property value SetFloatValue, SetInt64Value, SetOrdValue, SetStrValue, SetMethodValue, SetVarValue For object references SetOrdValue in VCL SetObjValue in VCL.NET Use the following methods to set the property value SetFloatValue, SetInt64Value, SetOrdValue, SetStrValue, SetMethodValue, SetVarValue For object references SetOrdValue in VCL SetObjValue in VCL.NET function TFloatProperty.SetValue( const Value: string ); begin SetFloatValue( StrToFloat( Value ) ); end; function TFloatProperty.SetValue( const Value: string ); begin SetFloatValue( StrToFloat( Value ) ); end;

12 Overriding GetAttributes Determines how editor appears in the Object Inspector Returns a set of attributes Common attributes paValueList paSortList paDialog paMultiSelect paAutoUpdate Determines how editor appears in the Object Inspector Returns a set of attributes Common attributes paValueList paSortList paDialog paMultiSelect paAutoUpdate

13 The GetValues Method Override when paValueList is specified Specify values to appear in drop down list Proc points to Add method of temp string list Override when paValueList is specified Specify values to appear in drop down list Proc points to Add method of temp string list procedure TFontNameProperty.GetValues( Proc: TGetStrProc ); var I: Integer; begin for I := 0 to Screen.Fonts.Count - 1 do Proc( Screen.Fonts[ I ] ); end; procedure TFontNameProperty.GetValues( Proc: TGetStrProc ); var I: Integer; begin for I := 0 to Screen.Fonts.Count - 1 do Proc( Screen.Fonts[ I ] ); end;

14 Owner-Draw Drop-Down Lists Customize the appearance of items in list Implement the following interfaces ICustomPropertyDrawing  ListMeasureHeight  ListMeasureWidth  ListDrawValue ICustomPropertyListDrawing  PropDrawName  PropDrawValue Customize the appearance of items in list Implement the following interfaces ICustomPropertyDrawing  ListMeasureHeight  ListMeasureWidth  ListDrawValue ICustomPropertyListDrawing  PropDrawName  PropDrawValue

15 The Edit Method Override Edit to perform action when ellipsis button is pressed or entry is double-clicked Typically used to display a custom dialog TFontProperty Not necessary to display a dialog box TMethodProperty generates an empty even handler Override Edit to perform action when ellipsis button is pressed or entry is double-clicked Typically used to display a custom dialog TFontProperty Not necessary to display a dialog box TMethodProperty generates an empty even handler

16 Registering a Property Editor Define a Register procedure Registration unit recommended Call RegisterPropertyEditor Parameters determine scope of editor Define a Register procedure Registration unit recommended Call RegisterPropertyEditor Parameters determine scope of editor // Edit all TStrings properties with TStringListProperty RegisterPropertyEditor( TypeInfo( TStrings ), nil, '', TStringListProperty ); // But edit the TQuery.SQL property with TRkSQLProperty RegisterPropertyEditor( TypeInfo( TStrings ), TQuery, 'SQL', TRkSQLProperty ); // Edit all TStrings properties with TStringListProperty RegisterPropertyEditor( TypeInfo( TStrings ), nil, '', TStringListProperty ); // But edit the TQuery.SQL property with TRkSQLProperty RegisterPropertyEditor( TypeInfo( TStrings ), TQuery, 'SQL', TRkSQLProperty );

17 Examples TRkAlignProperty Inline editor with owner draw drop-down list TRkIntegerProperty Dialog-based property editor TRkAlignProperty Inline editor with owner draw drop-down list TRkIntegerProperty Dialog-based property editor

18 Component Editors Why create custom component editors? Add menu items to context menu displayed by Form Designer Change double-click action Easier to create than property editors No need to worry about string representation. Why create custom component editors? Add menu items to context menu displayed by Form Designer Change double-click action Easier to create than property editors No need to worry about string representation.

19 Creating a Component Editor Derive a new class from TComponentEditor TDefaultEditor Define the editing capabilities of the editor Override appropriate methods Register the component editor. Derive a new class from TComponentEditor TDefaultEditor Define the editing capabilities of the editor Override appropriate methods Register the component editor.

20 TDefaultEditor Overrides the Edit method When component is double-clicked, Edit searches for the following events: OnCreate OnChange OnClick First defined event Generates (or navigates to) event handler Overrides the Edit method When component is double-clicked, Edit searches for the following events: OnCreate OnChange OnClick First defined event Generates (or navigates to) event handler

21 Context Menu Methods Override GetVerbCount Return number of menu items to add Override GetVerb Return string to display for corresponding menu item Override ExecuteVerb Implement functionality of new menu items Override GetVerbCount Return number of menu items to add Override GetVerb Return string to display for corresponding menu item Override ExecuteVerb Implement functionality of new menu items

22 The PrepareItem Method Provides access to menu item object for each menu item Actually an IMenuItem interface Allows menu items to be customized Enabled/Disabled Checked/Unchecked Create Sub-Menus Unfortunately, you cannot specify an ImageIndex or Glyph to be used for the menu Provides access to menu item object for each menu item Actually an IMenuItem interface Allows menu items to be customized Enabled/Disabled Checked/Unchecked Create Sub-Menus Unfortunately, you cannot specify an ImageIndex or Glyph to be used for the menu

23 The Edit Method Override to respond to double click The Edit method of TComponentEditor invokes ExecuteVerb( 0 ) if applicable Override to respond to double click The Edit method of TComponentEditor invokes ExecuteVerb( 0 ) if applicable

24 Registering a Component Editor Use the RegisterComponentEditor procedure Most recently registered editor will be used for editing the component This allows you to replace an existing editor Use the RegisterComponentEditor procedure Most recently registered editor will be used for editing the component This allows you to replace an existing editor RegisterComponentEditor( TRadioGroup, TRkRadioGroupEditor ); RegisterComponentEditor( TRadioGroup, TRkRadioGroupEditor );

25 Example TRkButtonEditor Add menu items Displays a custom dialog TRkListBoxEditor Add menu items and sub-menu items to context menu EditPropertyByName in RkDesignEditors unit TRkRadioGroupEditor Displays a custom dialog Dynamic cascading menus Registration Units TRkButtonEditor Add menu items Displays a custom dialog TRkListBoxEditor Add menu items and sub-menu items to context menu EditPropertyByName in RkDesignEditors unit TRkRadioGroupEditor Displays a custom dialog Dynamic cascading menus Registration Units

26 The Finish Line Contact Information Evaluation Forms Questions & Answers Contact Information Evaluation Forms Questions & Answers Ray Konopka Ray Konopka