Advanced Visual Basic - PowerPoint PPT Presentation

1 / 14
About This Presentation
Title:

Advanced Visual Basic

Description:

When run as a server, runs out of process. ActiveX DLL. Can only run as a server. ... Testing an ActiveX EXE. Compile the ActiveX EXE. Set Project compatibility ... – PowerPoint PPT presentation

Number of Views:155
Avg rating:3.0/5.0
Slides: 15
Provided by: Rich93
Category:

less

Transcript and Presenter's Notes

Title: Advanced Visual Basic


1
Advanced Visual Basic
  • ActiveX Components

2
Types of ActiveX Components
  • ActiveX EXE
  • Can be run standalone or as a server. When run
    as a server, runs out of process.
  • ActiveX DLL
  • Can only run as a server. Runs in process.
  • ActiveX OCX
  • Must be run from an ActiveX container like a form
    or a web page.

3
Component Communication
  • ActiveX components communicate by public
    properties, methods, enums and events.
  • To establish ActiveX communication
  • Set project reference
  • Dim variable as class
  • Set variable new class
  • Reference variable.(property, method, enum)
  • Handle variable_event

4
Exposure
  • Private
  • A private variable, property, or method is only
    available to the class from which it is called.
  • Friend
  • A friend property or method is available to any
    classes within the ActiveX component. Variables
    cannot be declared as friend.
  • Public
  • A public property or method is available to
    whatever object instantiated it.

5
Hierarchy Review
  • Application
  • ActiveX Component (EXE, DLL, OCX)
  • Collections (Optional)
  • Class
  • Properties
  • Methods
  • Enums
  • Events

6
Marshalling
  • Marshalling refers to the cross process
    communication between two components.
  • Occurs when an out of process (EXE) component is
    used by another component.
  • Marshalling is much slower than in process
    communication.

7
Marshalling Optimized
  • Dont pass an object when a property will do
  • An object requires much more overhead than a
    property.
  • If you do pass an object, do it ByVal
  • A one-way communication.
  • Use parameters instead of setting properties.
  • Causes only one communication to occur.

8
Class Properties
  • Instancing
  • Can a client application create instances of the
    class?
  • If so, how?
  • MTS Transaction Mode
  • How class reacts when using Microsoft Transaction
    Server
  • Only available to DLLs.
  • Persistable
  • Whether on not object can be saved

9
Project Properties General Tab
  • Project Type - Set to ActiveX DLL or ActiveX EXE
    for ActiveX components
  • Startup Object
  • None - no startup code required
  • Sub Main - start using the Sub Main procedure  
  • Project Name - Identifies ActiveX component
  • Project Description - Appears in the Object
    Browser 
  • Unattended execution - Run without user
    interaction - useful on remote systems
  • Threading Model - By default, an application has
    a single thread of execution
  • One Thread per object - objects are independent
  • Thread Pool - fewer objects than threads each
    object has its own thread. Otherwise, objects
    share threads.

10
Project Properties Version Compatibility
  • No Compatibility Choose this if making a change
    to a component to sever ties with previous
    component class IDs
  • Project Compatibility Choose this during
    testing to assure that when you close a project
    and reopen it, class IDs are maintained
  • For all ActiveX project types, Project
    Compatibility is checked by default
  • Binary Compatibility Necessary for maintaining
    compatibility among projects that have been
    compiled using your component.

11
Testing and ActiveX Component
  • Project group
  • This is a good idea when you're testing an
    ActiveX DLL or OCX. This allows you to step
    through the code of your component
  • Client Project using ActiveX Start Mode
  • You can't use a project group to test an ActiveX
    EXE, you have to run the ActiveX EXE in one copy
    of VB and the client in another copy of VB

12
Testing an ActiveX EXE
  • Compile the ActiveX EXE
  • Set Project compatibility to the ActiveX EXE
  • Set Start Mode of component to ActiveX Component
  • Run the ActiveX EXE
  • Open the client application in a separate VB
    window
  • Be sure to set References (from Project menu) to
    the compiled EXE
  • Run the client

13
Compiling the Component
  • Choosing Make from the File Menu
  • Compiles the component
  • Creates a Windows registry entry
  • Creates a type library (provides a description of
    the interfaces)
  •  
  • Every compile creates a set of Globally Unique
    Ids (GUIDs) for all classes and interfaces in the
    component. If Version Compatibility is set,
    GUIDs are not generated

14
Distributing Your Application
  • When you distribute an application, there are two
    steps you must go through
  • Packaging you must package your application
    files into one or more .cab files that can be
    deployed to the location you choose, and you must
    create setup programs for certain types of
    packages.
  • Deployment you must move your packaged
    application to the location users can install it
    from.
  • The Package and Deployment Wizard is the easiest
    way to create your application package.
Write a Comment
User Comments (0)
About PowerShow.com