Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!:ActiveX Components
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Programming Blue Book: The Most Complete, Hands-On Resource for Writing Programs with Microsoft Visual Basic 6!
(Publisher: The Coriolis Group)
Author(s): Peter G. Aitken
ISBN: 1576102815
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Click on the OK button to close the Project Properties dialog box. Next, use the Properties window to set the class properties. Only two of the properties concern us for this project; the settings and an explanation of each follow:
Instancing MultiUseThis setting permits other clients (outside the project) to create instances of the class, with multiple instances (if requested) supplied by a single running copy of the server. The other possible settings of this property set different restrictions on the class, but these do not concern us at present.
Name AXDEMOYou can use any descriptive name here. This property is used to identify the class. It is displayed in other applications Object Browser dialog boxes and is used in code (as well see later) to create an instance of the class.
Once the class modules properties are set, we can add the declarations of the variables that will be the classs properties. You accomplish this in the General Declarations section of the class module. Heres the code:
Option Explicit
Private pObjName As Variant
Private pDateCreated As Date
Private pNumber As Double
Private pSquareRoot As Double
Private pCubeRoot As Double
The Option Explicit statement should already be present, placed there automatically by Visual Basic. If not, you need to select Options from the Tools menu; on the Editor tab, turn on the Require Variable Declarations option. Lacking the Option Explicit statement in a module, Visual Basic does not require variables to be declareda definite invitation to errors.
If you examine these variable declarations, youll see that all of them are Private, meaning they are not accessible outside the ActiveX server. They can be used for purely internal uses by the class, or they can be exposed to clients as properties (for reading, writing, or both) by means of property procedures. When you expose a variable with a property procedure, it becomes one of the objects properties that can be accessed by clients.
We need to take a short detour from the demonstration project to explore property procedures. First, however, save the project. I used the default names suggested by Visual Basic: MyTestAXDLL for the project and AXDEMO for the class module (class modules are automatically given the .CLS extension).
Property Procedures
You had an introduction to property procedures in Chapter 6; now the time has come to learn more. Property procedures are a central part of ActiveX server programming. While you may be able to create very simple servers without using property procedures, youll find them essential for most of your projects. You can use a property procedure to create standard read/write properties that can be both read and set by clients. These procedures also permit you to create read-only properties, perform some action when the property is read or set, or assign a Help topic to the property.
Property procedures come in three varieties. Property Get and Property Let are usually used in tandem, permitting the client to read and set, respectively, the value of a property in the ActiveX object. Property Set is used in place of Property Let when the property in question contains a reference to an object. Because the demonstration server does not use object reference properties, Ill limit the discussion to Property Get and Property Let.
Lets assume we want the object to hav
Wyszukiwarka
Podobne podstrony:
SERWIS 2010 08 0208 02 KPGO Prognoza oośMegaDance Vol 18 (08 02 2015) Tracklistapdm? 2016 08 0208 02Pisemny egzamin pa pilota wycieczek 08 02 200708 0208 02 Remonty i usuwanie usterektechnik elektryk11[08] o3 02 nTI 02 05 08 T pl(1)TI 99 02 08 T B M pl(1)więcej podobnych podstron