Building ActiveX Controls מרצה : דורון אמיר MCSD Doron Amir www.doronamir.com.

Slides:



Advertisements
Similar presentations
VISUAL BASIC Visual Basic is derived from the Basic language (Beginner’s All-Purpose Symbolic Instruction Code) Visual Basic uses an event-driven programming.
Advertisements

Data Base. Objective Become familiar with database terminology. Create a project to display data for a single database table. Use a DataGrid control.
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Object Oriented 33 MCSD DORON AMIR
ממיבחניםC שאלות ++.
מבוא לתכנות ב WINDOWS ד " ר אבי רוזנפלד ד " ר אריאלה ריכרדסון.
ActiveX Data Objects (ADO) מרצה : דורון אמיר MCSD Doron Amir
מאפייני שדה. לכל שדה יש מאפיינים הקובעים את תכונות השדה והתנהגותו. המאפיין החשוב ביותר הוא טיפוס הנתון. 2.
דוד שוורץ, עידן זק, נטע צור וחיה כהן. הפונקציונאליות : המשתמש יבחר קובץ שעליו הוא רוצה לבצע את האנליזה, וילחץ עליו עם כפתור ימני בעכבר. יפתח תפריט ובו.
1 מבוא למערכות מידע סמסטר ב', תש"ע נושא HTML בס"ד מרצה: מכון לב - ד"ר אבי רוזנפלד.
The Microsoft View: Module 1: Getting Started. Copyright Course 2559B, Introduction to Visual Basic®.NET Programming with Microsoft®.NET. Lecture 1 Microsoft.
The ADO Data Control. Universal Data Access Open Database Connectivity (ODBC) –standard for accessing data in databases OLE-DB –allows access to data.
Using Visual Basic 6.0 to Create Web-Based Database Applications
Slide 1 Forms v Parts of a form v Form: Program User Interface v Controls are contained inside forms v Control event handlers are contained inside forms.
Automating Tasks With Macros. 2 Design a switchboard and dialog box for a graphical user interface Database developers interact directly with Access.
נוצר ע " י ד " ר ארקדי שטיינבוק Visual Basic for Application VBA כדוגמה VBA ב - WORD.
תכנות מונחה עצמים Object Oriented Programming (OOP) אתגר מחזור ב' Templates תבניות.
Introduction to ADO.Net, VB.Net Database Tools and Data Binding ISYS 512.
Chapter 31 Visual Basic Controls A Form is a windows-style screen displayed by Visual Basic programs. In a form, a programmer can create objects in a form.
Text to speech In Mobile Phones איתי לוי. הקדמה שימוש בהודעות טקסט על המכשירים הסלולארים היא דרך תקשורת מאוד פופולארית בימינו אשר משתמשים בה למטרות רבות,
Chapter 2 –Visual Basic, Controls, and Events
Adding Controls to User Forms. Adding Controls A user form isn’t much use without some controls We’re going to add controls and write code for them Note.
Sep-05 Slide:1 ActiveX Controls in VB ActiveX Controls in VB6.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
CHAPTER 9 DATABASE MANAGEMENT © Prepared By: Razif Razali.
Programming with Visual Basic.NET An Object-Oriented Approach  Chapter 8 Introduction to Database Processing.
CIS 338: Creating ActiveX Controls Dr. Ralph D. Westfall March, 2003.
Using Visual Basic 6.0 to Create Web-Based Database Applications
An Introduction to Visual Basic
IE 411/511: Visual Programming for Industrial Applications
McGraw-Hill/Irwin Programming in Visual Basic 6.0 © 2002 The McGraw-Hill Companies, Inc. All rights reserved. Update Edition Chapter 11 Accessing Database.
‘Tirgul’ # 7 Enterprise Development Using Visual Basic 6.0 Autumn 2002 Tirgul #7.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
Basic Controls & Properties Chapter 2. Overview u VB-IDE u Basic Controls  Command Button  Label  Text Box  Picture Box u Program Editor  Setting.
Introduction to the Visual Studio.NET IDE (LAB 1 )
Irwin/McGraw-Hill Copyright© 2000 by the McGraw-Hill Companies, Inc. PowerPoint® Presentation to accompany prepared by James T. Perry University of San.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
Microsoft Visual Basic 2010 CHAPTER THREE Program Design and Coding.
מבוא ל ASP.NET שיעור 4 : מבוא ל ASP.NET שיעור 4 : מבוא ל ASP.NET מצגת מס ' 4 MCSD DORON AMIR.
CHAPTER TWO INTRODUCTION TO VISUAL BASIC © Prepared By: Razif Razali 1.
Chapter 3: Creating ActiveX Controls By Noppadon Kamolvilassatian Dept. of Computer Engineering, Prince of Songkla University Source: Mastering Visual.
INSERT BOOK COVER 1Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall. Exploring Getting Started with VBA for Microsoft Office 2010 by.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Introduction to ADO.Net and VS Database Tools and Data Binding ISYS 350.
XP New Perspectives on Microsoft Office Access 2003 Tutorial 10 1 Microsoft Office Access 2003 Tutorial 10 – Automating Tasks With Macros.
Visual Basic for Application - Microsoft Access 2003 Programming applications using Objects.
1 Visual Basic Part I - A tool for customizing your program Principles of GIS
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 12 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 12 Accessing.
1 Chapter 10 – Database Management 10.1 An Introduction to Databases 10.2 Editing and Designing Databases.
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.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
TOOLBOX. The Toolbox Intrinsic Controls - always included in the Toolbox ActiveX Controls - separate files with ocx file extension Insertable Objects.
DATABASE SYSTEM VB LINK TO MS-SQL. 2 Visual ProgrammingChapter 6 Select Project -> Component.
ActiveX DLL Create Class in Dll File & Client Application MCSD Doron Amir
Combo Box שלושה סוגים של Combo Box: Style 0 (default) - drop-down combo box המשתמש יכול להוסיף אפשרויות לרשימה או ללחוץ על החץ לבחירה מרשימת האפשרויות.
Chapter 1: An Introduction to Visual Basic .NET
1. Introduction to Visual Basic
XML מבוא כללי MCSD Doron Amir
VB.NET Using Database.
Web Services ASP.NET כתב: אקת'ם חאג' יחיא ליווי מקצועי : ארז קלר
XML מבוא כללי פרק ג' MCSD Doron Amir
מבוא ל ASP.NET שיעור 2 : מבוא ל ASP.NET מצגת מס' 2
עבודה עם נתונים באמצעות ADO.NET
מבוא לתכנות בWINDOWS ב#C
תזכורת על מה דיברנו שיעור שעבר? בנינו אתר אינטרנט עם כותרות
Lecture Set 11 Creating and Using Classes
Chapter 10 Accessing Database Files
Visual Basic CSC
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
Custom Forms with VBA in Excel In-Class Exercise #11
Presentation transcript:

Building ActiveX Controls מרצה : דורון אמיר MCSD Doron Amir

Building ActiveX Controls An ActiveX Control Exposing Properties,Methods,Events Testing a control Creating Properties pages Creating a data bound control Creating a data source control Written by: MCSD Doron Amir

ActiveX Controls יישומי VB שונים עבור דפי WEB וצפייה ע"י IE מסמכי Office Written by: MCSD Doron Amir אובייקט שניתן לשיבוץ בטופס או בפקד מכולה

Controls אובייקט לשימוש חוזר המכיל קוד וממשק וויזואלי שימוש ב Controls מקל על המפתח ב VB יש פקדים מוכנים ב ToolBox ניתן ליצור פקד ולהוסיפו לתיבת הכלים ToolBox ActiveX Controls חייבים מכולה Written by: MCSD Doron Amir

Control Classes כאשר יוצרים פקד אנו יוצרים מחלקה עבור אותו פקד מחלקה ליצירת פקדים מיוצגת בקובץ OCX כאשר מציבים פקד על הטופס נוצר design-time instance כאשר מריצים את היישום נוצר run-time instance Control.ocx Design – time control run – time control Form1 Written by: MCSD Doron Amir

OCX File Source Code Property Values Control Class.ctl TextFile Graphical elements.ctx Like.frx file for forms Control.OCX Control Class מכיל קובץ טקסט עבור הקוד וערכי המאפיינים (ctl) וקובץ ctx עבור אלמנטים גרפיים Written by: MCSD Doron Amir

OCX File C1.ctl C2.ctl C3.ctl MyControl.OCX ביצירת ActiveX Control ניתן להשתמש בכמה קבצי ctl אך לאחר ההידור כל הקבצים יתאחדו לקובץ OCX אחד

The UserControl Object Written by: MCSD Doron Amir UserControl מכיל קוד + ממשק עיצוב ממשק עיצוב Code

Add constituent controls to a UserControl Written by: MCSD Doron Amir פקד ה usercontrol יכול להכיל פקדים רגילים מה- ToolBox

Timer

Using Ambient Properties Written by: MCSD Doron Amir ה - Containers מספקים רשימת מאפיינים אשר יכולים להשפיע ישירות על פקד ה ActiveX שנמצא בו. BackColor הוא מאפיין Ambient. AmbientChanged אירוע זה מופעל כאשר יש שינוי במאפיין מסוג Ambient Ambient Object מאפשר לקרוא ערך מאפיין Ambient Private Sub UserControl_AmbientChanged(PropertyName As String) If PropertyName = "BackColor“ Then UserControl.BackColor = Ambient.BackColor End If End Sub כאשר צבע הרקע של ה Container ישתנה גם רקע הפקד ישתנה

Ambient Properties Written by: MCSD Doron Amir רקע הפקד משנה צבע כאשר משנים את צבע הרקע של הטופס רקע הפקד אינו משנה צבע כאשר משנים את צבע הרקע של הטופס UserControl_AmbientChanged

UserControl_Resize() Written by: MCSD Doron Amir Private Sub UserControl_Resize() Text1.Width = (UserControl.ScaleWidth - 240) End Sub האירוע מופעל בעת שינוי גודל הפקד הקוד הנ"ל מאפשר לפקד הטקסט לשמור על פרופורציה בהתאם לרוחב מסגרת הפקד הפרש

Add About Box Private Sub Command1_Click() frmAbout.Show vbModal Unload frmAbout Set frmAbout = Nothing End Sub הוספת דף מידע עבור הפקד Written by: MCSD Doron Amir

ToolBox Bitmap בחירת תמונה עבור הפקד : bitmap חיפוש התמונה Written by: MCSD Doron Amir

The ActiveX Control Interface Wizard Written by: MCSD Doron Amir אשף העוזר לבנות ActiveX Control הגדרת מאפיינים שיטות אירועים

The ActiveX Control Interface Wizard Written by: MCSD Doron Amir

Create Control Written by: MCSD Doron Amir Private Sub Command1_Click() Text1.Text = "": Text2.Text = "": Text3.Text = "" End Sub המטרה : צור פקד המכיל 3 תיבות טקסט ופקד ניקוי עבור התיבות טקסט בעזרת האשף נגדיר מאפיינים שיאפשרו לגשת אל כל רכיבי הפקד בנפרד

תרגיל לבניית מאפיינים Private Sub Command1_Click() UserControl11.myColor1 = vbRed UserControl11.myColor2 = vbBlue UserControl11.myColor3 = vbGreen End Sub יצירת מאפיין בשם myColor עבור כל רכיב בנפרד

Select Available Property Written by: MCSD Doron Amir

My Custom Members Written by: MCSD Doron Amir בחר שמות למאפיינים ושיטות הפקד

התאמה בין המאפיינים החדשים לרכיבי הפקד Written by: MCSD Doron Amir הרכיב המאפיין כינוי

תרגיל לבניית שיטות stopTimer Method startTimer Method Private Sub Command1_Click() ctlClook1.StopTimer End Sub Private Sub Command3_Click() ctlClook1.StartTimer End Sub

My Custom Members Written by: MCSD Doron Amir

User Control Sub Written by: MCSD Doron Amir Public Sub StartTimer() Timer1.Enabled = True End Sub Public Sub StopTimer() Timer1.Enabled = False End Sub האשף הכין את השגרות יש לקודד את הפקודות הרצויות

Mapping a Property to Multiple Control Written by: MCSD Doron Amir יצירת מאפיין צבע עבור מספר פקדים לא ידוע שימוש בלולאת For Each…Next

Mapping a Property to Multiple Control Written by: MCSD Doron Amir Public Property Let MyColor(ByVal vNewValue As OLE_COLOR) Dim ctl As Object For Each ctl In Controls If (TypeOf ctl Is Label) Then ctl.BackColor = vNewValue End If Next End Property

Mapping a Property to Multiple Control Written by: MCSD Doron Amir Private Sub Command1_Click() UserControl11.MyColor = RGB(CInt(Text1), CInt(Text2), CInt(Text3)) End Sub המרה ל RGB

Available in the Properties window Written by: MCSD Doron Amir יצירת מאפיין בחלון המאפיינים עבור פקד ה ActiveX Control

Available in the Properties window Written by: MCSD Doron Amir Public Property Get MyCaption() As String MyCaption = Label1.Caption End Property Public Property Let MyCaption(ByVal NewCaption As String) Label1.Caption = NewCaption PropertyChanged "MyCaption" End Property PropertyChanged רושם את המאפיין בחלון המאפיינים GET = עבור קריאת המאפיין LET = עבור עריכת המאפיין

Storing & Retrieving Property Values Written by: MCSD Doron Amir המאפיין MyTextColor קיבל צבעים שונים בעת זמן עיצוב הטופס, ללא רישום+קריאת המאפיינים הצבעים הנבחרים היו משתחררים

Storing & Retrieving Property Values Written by: MCSD Doron Amir Public Property Get MyTextColor() As OLE_COLOR MyTextColor = Text1.BackColor PropertyChanged "MyTextColor" End Property Public Property Let MyTextColor(ByVal vNewValue As OLE_COLOR) Text1.BackColor = vNewValue PropertyChanged "MyTextColor" End Property יצירת מאפיין MyTextColor

Storing & Retrieving Property Values Written by: MCSD Doron Amir Private Sub UserControl_WriteProperties(PropBag As PropertyBag) PropBag.WriteProperty "MyTextColor", Text1.BackColor, &H F End Sub Private Sub UserControl_ReadProperties(PropBag As PropertyBag) Text1.BackColor = PropBag.ReadProperty("MyTextColor", &H F) End Sub רישום : שמירת ערך המאפיין MyTextColor קריאה : חשיפת ערך המאפיין MyTextColor

Raise Event יצירת אירוע בשם AtTime קריאה לאירוע הפעלת שיגרת האירוע

הגדרת האירוע Raise Event Event AtTime() Private Sub Timer1_Timer() RaiseEvent AtTime txtTime.Text = Format(Now, "HH:MM:SS") End Sub קריאה לאירוע בכל כניסה לפרוצדורת הטיימר

Private Sub ctlClock1_AtTime() כניסה אל שגרת הפקד ובחירת פרוצדורת AtTime Private Sub ctlClock1_AtTime() Print Now End Sub

Using the Property Page Wizard Create the user interface for the property page.

Add-In : vb6 Property Page Wizard

Select the Property Page

Select Properties for Display

Next..Next..Next

Compile For OCX עיצוב פקד מאפייני פרוייקט

Compile For OCX Written by: MCSD Doron Amir File  Make MyOCX.ocx שמירת הקובץ

רישום הפקד הידור הפקד הידור הפקד העתק לתיקיה System32 העתק לתיקיה System32 פרוייקט EXE חדש פרוייקט EXE חדש Components + Brows  Apply Components + Brows  Apply Written by: MCSD Doron Amir

Components

System32

Apply

Creating a data bound control Written by: MCSD Doron Amir SQL server

Creating a Control OCX Written by: MCSD Doron Amir txtFname txtLname txtEmpId Code :Let/Get + Read/Write Public Property Get EmpId() As String EmpId = txtEmpId.Text End Property Public Property Let EmpId(ByVal New_EmpId As String) txtEmpId.Text() = New_EmpId PropertyChanged "EmpId" End Property Private Sub UserControl_ReadProperties(PropBag As PropertyBag) ………. txtEmpId.Text = PropBag.ReadProperty("EmpId", "Text3") End Sub Make …OCX עריכת מאפיינים לכל פקד פנימי שמירת נתונים הידור הפקד Read/write Let/Get

Connecting DataBase הוספת סביבת נתונים (Data Environment) הוספת סביבת נתונים (Data Environment) בניית קישור (Connection) בניית קישור (Connection) בחירת ספק (Provider) בחירת ספק (Provider) בחירת (Server) בחירת (Server) בחירת מסד נתונים (DataBase) בחירת מסד נתונים (DataBase) Written by: MCSD Doron Amir התחברות למסד הנתונים Pubs

הוספת סביבת נתונים (Data Environment) Written by: MCSD Doron Amir 1.Right Click 2.Add 3.More ActiveX Designers 4.Data Environment

Written by: MCSD Doron Amir בניית קישור (Connection)

בחירת ספק (Provider) Written by: MCSD Doron Amir

בחירת + (Server) מסד נתונים (DataBase) Written by: MCSD Doron Amir

Add Command Written by: MCSD Doron Amir Right Click Properties

Edit Command Written by: MCSD Doron Amir 1.התאמת Command לקישור הנתונים 2.עריכת משפט בחירה SQL

Microsoft DataRepeater Control 6.0 הוספת פקד repeater Written by: MCSD Doron Amir

RepeaterControlName שיבוץ הפקד שיצרנו בפקד ה- Repeater Written by: MCSD Doron Amir

DataSource & DataMember התאמת מסד הנתונים + שליחת השאילתה Written by: MCSD Doron Amir

MCSD Doron Amir Building ActiveX Controls