|
ActiveX :
All
Check whether a DLL is an COM self-registering server
Enable/Disable the WordWrap style of a RichTextBox control
Example:
Private Sub Check1_Click()
SetRichTextBoxWordWrap RichTextBox1, (Check1.Value = vbChecked)
End Sub
Get the name of the DLL or EXE that contains
the class whose CLSID is passed as an argument
Note: Remote servers aren't taken into account
Get the name of the DLL or EXE that contains
the class whose ProgID is passed as an argument
Remote servers aren't taken into account
NOTE: Requires GetRegistryValue
Return a collection with all hidden types of a type library
VB's Object Browser hides some types in a type library:
you can show these types by right clicking on the Object Browser and
activating the "Show hidden members" option. This option, however,
shows only types labelled as "hidden", ...
Returns a bit-coded value that specifies the type of
an object's member (property, method, event)
or zero if the member isn't there
Object is the object which you want to work
MemberName is the property, method or event name
the return value is one of the following
INVOKE_FUNC (method)
return a collection with names of all the class names
of a type library that implement a certain member.
MEMBERNAME is the name of the property or method
MEMBERTYPE is the type of the member (vbGet, vbLet, vbSet, vbMethod).
You can specify multiple types by ORing these constants
Example:
Return all classes of the type library specified in
TypeLibFile parameter that support a certain interface.
the interface can be specified as an Object or through its IID
Be sure that "TypeLib Information" type library (TlbInf32.tlb)
is referenced in your VB project.
Return a collection with all creatable classes of
the type library specified in TypeLibFile.
Set IncludeNotCreatableClasses = True to include not creatable classes
(that is, those with Instancing property set to PublicNotCreatable) too.
Be sure that "TypeLib Information" type library (TlbInf32.
Return the DispID of a procedure
ProcName must be set to a procedure name of the object
specified in the second parameter.
Be sure that "TypeLib Information" type library (TlbInf32.tlb)
is referenced in your VB project.
Return the GUID of the object specified in the first parameter
Be sure that "TypeLib Information" type library (TlbInf32.tlb)
is referenced in your VB project.
Convert a string representation of a CLSID, including the
surrounding brace brackets, into the corresponding ProgID.
Convert a ProgID (such as "Word.Application") into the
string representation of its CLSID
To save to file the graph generated by a MSChart control, you must use the control’s EditCopy method to copy the image into the clipboard, and then paste it into a PictureBox control. Then, just use the SavePicture function to save the PictureBox’s content to file. Here’s an example:
You can host the WebBroweser in a Windows Forms application, similarly to what you can do with any other ActiveX control. You just need to right-click on the control toolbox, select the Customize Toolbox menu command, select the Microsoft Web Browser control from the list of available controls, ...
There is quite a lot of misunderstanding among COM newbies about what really happens when a COM interface is passed as a method parameter. As in most of the cases, VB programmers are protected from a lot of details on the COM run-time, but you do have to know such details if you want to ...
When building an ActiveX control, you can set a default property or method using the Procedure Attributes dialog box, after clicking on the Advanced button. However, if your default property also happens to require another special attribute - as is the case with Caption and Text p
If a form contains a RichTextBox control and other controls that are capable to receive the input focus, when the focus is on the RichTextBox and the user presses the Tab key to add a space, the focus will be moved to the following control in the tab order, and the tab character won't be added. ...
You can't clear the contents of a MaskEdBox control by setting the Text property to a null string if the MaskEdBox's Mask property contains delimiter. In fact, you must include those separators in the value you assign to the Text property, otherwise you get Error 380 - Invalid property value.
Here's a simple method to programmatically insert an image into a RichTextBox control, by copying it into the clipboard and then pasting it into the control:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As ...
An ActiveX DLL doesn't have direct access to the environment of the calling EXE. For example, the App and Printer objects in the DLL don't correspond to the objects with the same name in the main application, therefore if you want to print something from the DLL using the same settings as the ...
You can easily create ActiveX controls that work as containers for other controls, by setting their ControlContainer property to True. However, VB doesn't offer any event for detecting when the programmer adds or remove controls to the ActiveX control, after placing it on a form's surface.
I've been trying to find a way to assign helpstrings for Enums in Visual Basic. The Class builder utility does that only for methods, events, and properties, but not for Enums.
The IDL source code that corresponds to an Enum in a type library looks something like follws, and you can run ...
Printing is one of the things that you can't do directly from withing ASP: to have a printout of your data from ASP you must instantiate a COM component - either a custom component, a WebClass, or a commercial COM server such as Microsoft Word or Excel - and print from there. However, even if ...
The left-most listbox in the first page in the ActiveX Control Interface Wizard includes all the properties exposed by the constituent controls currently on the UserControl's surface. Unfortunately, this list includes Extender properties, methods, and events, which should be never added ...
When working on an updated version of a COM component, you should always enforce Binary Compatibility in the Component tab of the Project Properties dialog box. When enforcing binary compatibility there are a number of common mistakes that you should stay clear of:
- Always use the ...
Under some circumstances, an ActiveX DLL can pass private objects to its client application, for example a reference to a control that belongs to a form in the DLL. While this approach can be useful, and can work under some circumstances, you should absolutely avoid avoid to do so, ...
ActiveX components written in VB can contain both SingleUse and MultiUse classes at the same time. It usually isn't a good idea to use both types of classes in the same project, however.
When a client creates an instance of a SingleUse class, COM always runs a new instance of the EXE file ...
If your application uses objects from external components, either third-party or your own libraries, a good rule of thumb is to include the complete servername.classname string in the Dim statement, as in:
Dim word As Word.Application
This syntax ensures that if you ...
By defining a Public Enum and using it as a parameter type to your
property or function, client applications are presented with a drop down list of values to use. Unfortunately, VB doesn't restrict the client from passing something other than one of your enumerated values, since all Enums are ...
If you try to use a DataList and some labels or text boxes linked to an ADO Data control, and you click on some items in the list, you'll notice that the data in the labels won't change, because the current record isn't changed.
To have the code work correctly, you have to write code in ...
If you use a DataList control linked to an ADO Data Control and if you want to add a record, you have to create a command button with this code:
Private Sub cmdAdd_Click()
On Error GoTo AddErr
datPrimaryRS.Recordset.AddNew
txtNew.SetFocus
Exit Sub
AddErr:
MsgBox Err.
Many VB developers know that they should specify a DLL Base Address value - in the Compile tab of the Project Properties dialog box - that is different from the base address of any other DLL or OCX used in the project.
When you are working with a compiled DLL or OCX for which you don't ...
All COM-oriented VB developers know how to register and unregister an ActiveX DLL, using the REGSVR32 utility. However, there is no such an utility to register and unregister a type library.
You can quickly build your own TLB Registration utility with a handful of statements, thanks to ...
You can easily download an HTML page by using the Internet Transfer Control (INet). Here's a reusable routine that uses this control to download the HTML page at the specified URL and optionally save it to a local file. In either case the routine returns the contents of the page as a string:
The CommonDialog control doesn't provide any direct way to decide where a common dialog appears on the screen. In all cases, in fact, the control tries to display the common dialog centered on its owner form. This behavior suggests a simple way to affect the approximate position of the common ...
Here's a quick way to retrieve the textual (that is, without any HTML tag) contents of a WebBrowser control:
Dim Text As String
Text = WebBrowser1.Document.Body.InnerText
Getting the HTML text is a tad less intuitive, though:
Dim Text As String
Text = WebBrowser1.
To programmatically copy text from the WebBrowser control you can use its ExecWB method, to which you must pass the OLECMDID_COPY constant as its first argument.
WebBrowser1.ExecWB OLECMDID_COPY, OLECMDEXECOPT_DODEFAULT
You can also select the entire WebBrowser's contents ...
The WebBrowser control doesn't expose any method to directly print its contents. You can achieve this effect through the ExecWB method, by passing the OLECMDID_PRINT constant in its first argument:
' display the Print dialog
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
When dynamically changing the bound ADORecordset for a DataCombo or DataList control, the order you follow when assigning the properties is important. This is the correct sequence of operations to perform to change the bound recordset for these controls:
' unbind the current ...
All ActiveX DLL or OCX export two functions: DllRegisterServer and DllUnregisterServer. They are used to register and unregister the ActiveX in the Windows registry, and are usually invoked from regsvr32.exe at registration time.
However, you can register and unregister these files ...
At times you may need to access the command line passed to the application from within an ActiveX DLL. Unfortunately, when inside a DLL the Command$ function returns a null string, so you have to resort to some API trickery:
Private Declare Function GetCommandLine Lib "kernel32" Alias ...
The stardard method to register and unregister ActiveX component is running the REGSVR32 utility, which forces you to bring up the Start|Run dialog and manually type the command line. A much better approach is to have the Register and Unregister commands right in the context menu that appears ...
The following routine quickly check that a string contains a valid GUID. Of course, it doesn't check that the GUID refers to a valid entity, but at least it lets you quickly reject invalid values:
Function CheckGUID(Value As String) As Boolean
Const PatternGUID = ...
When testing a component in the IDE, always perform a full compilation. This ensures that VB checks the syntax of all the code in the component, which in turn guarantees that no syntax error will break the program while it is serving another application.
You can activate the full ...
If you haven't switched to DCOM yet, and still use Remote OLE Automation, you must launch the Automation Manager program on the server machine, in order to let the server respond to requests coming from client workstations.
The Automation Manager displays a visible window at launch time, ...
The Tag property exposed by many Windows Common Controls (including TreeView's Node objects and ListView's ListItem objects) is more versatile than the ListBox and ComboBox controls' ItemData property, because it is of Variant type and can therefore accept values of most data types.
When you build your ActiveX controls and components, Visual Basic automatically creates all the GUIDs as necessary. The same also happens in other cases, without you even realizing it: for instance when you make a MDB database replicable, the Jet Engine adds new fields and uses GUIDs to mark ...
The Procedure Attributes dialog includes a Procedure ID combo box, that lets you associate a particular ID to a given member of the class. You usually use this combo to make a property or a method the default item of a class or an ActiveX control, but there are other uses as well. For instance, ...
Many VB programmers assume that Visual Basic 5.0 is not capable of creating stand-alone Type Libraries, because the documentation states that when an ActiveX component or control is created, the companion Type Library is embedded in the main executable file.
This is correct, but if you ...
If you're writing an ActiveX control, you can create properties that return an enumerated value, as in ...
|