(This code is from a foreign website and can be used as a reference for "Magic Kobe)
Code:
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, SHDocVw, MSHTML, ActiveX, StdCtrls; type TObjectProcedure = procedure of object; TEventObject = class(TInterfacedObject, IDispatch) private FOnEvent: TObjectProcedure; protected function GetTypeInfoCount(out Count: Integer): HRe
-dimensional position, based on these can be achieved posture recognition.This body area, known as "skeleton" in the Kinect SDK V1, is renamed "body" in the Kinect SDK v2 preview. This section introduces the method of getting the body. The sample program uses the Kinect SDK v2 preview to get a sample program showing the body and color images overlay as "(dots)." Also, based on the body data, Hand State (the status of the hand) has also been shown. The 2nd section introduces the stage excerpt n
For beginner COM, a complete example is still quite troublesome. Recently I have been studying and learned the basic principles through my own exploration. Here we will explain a simple string example step by step.
Source code download
1. Create a project
First, use vs2010 to create a project. Select an empty project and name it mycom.
2. Create an Interface Class
#ifndef IString_h__#define IString_h__#include
3. Create component classes
#ifndef String_h__#define String_h__#include "IStri
To be honest, the final solution is to implement the idochostuihandler interface and solve it in the gethostinfo method. However, the "Implementation interface" means that the QueryInterface, addref, and release methods must be implemented, so the relevant code is:Class cmywebbrowser: Public idochostuihandler{Public:Cmywebbrowser () {m_cref = 0 ;}Virtual ~ Cmywebbrowser (){}Long m_cref;PRIVATE:Hresult stdmethodcalltype QueryInterface (refiid riid, void ** ppvobject){
Classes are not encapsulated, but some functions are concentrated in a file.
One is the function declaration file dshowutilities. h, and the other is the function definition file dshowutilities. cpp.
The functions mentioned here are all copied from the source code or help document provided by Microsoft.
First, dshowutilities. h file
# Ifndef dshowutilities_h _# Define dshowutilities_h _
# Include
# Pragma comment (Lib, "strmiids. lib ")
// This is just a small function, but it will be used in s
represent its structure.
We can see that any structured storage file has a root istorage. This interface can contain multiple level-1 sub-istorage. level-1 sub-istorage can contain multiple level-2 sub-istorage, the hierarchy and tree structure of Structured Storage files are formed in sequence, and each istorage can contain any istream, which is equivalent to a single file in the file system.
The main functions of istorage include:
1.1 stgcreatedocfile
This function creates a structured stora
reading this article, you will be able to learn how to use the built-in components in the Windows operating system and the COM objects provided by third parties.This document assumes that you are proficient in the C ++ language. In the example code, we use a bit of MFC and ATL. If you are not familiar with MFC and ATL, this article will thoroughly explain these codes.This article includes the following parts:Com -- what is it? -- The key points of the COM standard. What problems is it designed
definitions. Some interface definitions to be used are excerpted below:
......Extern_c const IID iid_ishelldispatch;# If defined (_ cplusplus )! Defined (cinterface)Interface declspec_uuid ("D8F015C0-C278-11CE-A49E-444553540000 ")Ishelldispatch: Public idispatch{Public:......Virtual hresult stdmethodcalltype minimizeall (void) = 0;Virtual hresult stdmethodcalltype undominimizeall (void) = 0;Virtua
automatically compressed. These new features are implemented through COM modules and invoked as Plug-ins in the cleanup tool. Earlier versions were invoked through the Iemptyvolumecache interface, and in later versions of Windows 2000, the IEmptyVolumeCache2 interface was added, adding smaller updates.
The Iemptyvolumecache interface consists of five functions, according to the order of the call, respectively:
Virtual/* [local]/HRESULT
:
Basic
Com member functions
QueryInterfaceAddrefRelease
Take over the drag-and-drop event member function:
DragenterDragoverDragleaveDrop
That is to say, to achieve the above in the customer Program
The entity of the Seven functions.
The system will call
The corresponding function of the idroptarget interface, checks the flag returned by the user in these functions, and determines the appearance of the mouse and the drag-and-drop results.
Implementation
Idroptarget Inte
, sample grabber, and default Renderer Filter.
Step 3: Configure sample grabber to capture data.
Implementation of CCaptureVideo for video capturing
// CCaptureVideo video capture Class header file//////////////////////////////////////// /////////////////////////////# If! Defined (afx_capturevideo_h1_f5345aa4_a39f_4b07_b843_3d87c4287aa01_encoded _)# Define afx_capturevideo_h1_f5345aa4_a39f_4b07_b843_3d87c4287aa01_encoded _//////////////////////////////////////// ////////////////////////
Add # pragma once in the next line of the xxxctrl. H (XXX is the project name) header file
// ------- Add ---------------// Cancel IE Security Prompt# Include "objsafe. H"// --------- Add ----------------------------
And declare part of the declaration in the header file class (same as the cxxxctrl () constructor)
// ---------- Added the Security Prompt for canceling ie ----- = ---- declare_interface_map () begin_interface_part (objsafe, IObjectSafety) stdmethod _ (
. DLL, which is the legendary Shim. It will load the common language runtime and find the real. NET Component ----. DLL.
With the above two steps, we can use the. NET Component in the com application. Writing COM components is beyond the scope of this article. If you are interested, refer to the comments in the code.
CL client. CS
// Client. CS
# DEFINE _ win32_com
# Include
# Include
# Import "A. TLB" no_namespace named_guids raw_interfaces_only
// A. TLB is exported in step 2
In
the results in the example program on the console. Features of audio(Audiobeam,Speech Recognition)The data acquisition processIn"sensor"~"source" This piece with the previousImage(Color,Depth,Bodyindex,Body) of the acquisition processThe same. But after that, please note thataudio feature-specific section, here is the main introduction andthe same data acquisition process as Image. The full contents of this sample program,It's all public on the following GitHub. Https://github.com/UnaNancyOwen/
In Arcengine, many components send information in event mode. For example, in Mapcontrol, there are events such as mouse press events, mouse movements and so on, Iworkspaceedit also have the beginning edit, end edit and so on. Sometimes we need to be aware of these events in order to process the necessary information when they occur. So, how do you listen to events for components? The following is an example of a listener editing event to illustrate how listening is handled. To turn on help, we'
the event source interface definition. The first is to share a common header file, as shown below. The second is to use the #import in conjunction with the Embedded_idl import qualifier so that the event source type library is written to the. tlh file that retains the code generated by the attribute.Firing eventsTo fire an event, simply call the method in the interface that is declared using the __event keyword in the event source class. If the handler is hooked to an event, the handler is invo
a COM object in the same way. In the COM object wizard window, remove the check box included Type Library. Enter iehelper in class name and idispatch and iobjectwithsite in implemented interface. Click OK to create a COM component.Save the project, save it as iehelper. DPR, and save unit1 as iehelperunit. Pas. The code for iehelperunit. PAS is as follows:
Unit iehelperunit;
Interface
UsesWindows, comobj, ActiveX, shdocvw, mshtml, dialogs;
Type
Tiehelperfactory = Class (tcomobjectfactory)Private
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.