Brief introduction
A few weeks ago, I desperately looked for an example of a C + + object that could be passed through a COM interface, but was not found. That's why I'm publishing this article.
Passing a C + + object parameter to an ATL DLL is not very difficult, but of course it can be a bit difficult and interesting.
Before starting a project, you have to be sure that both the client and server components are adaptable to C + + programs, and sec
features that cover VC 6, but as far as I know, all programs can be used on VC 7. Since I do not use VC 7, I am unable to provide help for those problems appearing in VC 7, but you can safely post your questions here, because other people may help you.A general introduction to this series of articles
WTL has two sides, indeed it is. It is not as powerful as the MFC interface (GUI) class library, but can produce very small executables. If you like me to use MFC for interface programming, you wil
Similar to the implementation of the previously described IDispatch, it is much easier to implement a connected object than the Mfc,atl, and it is done by using MIDL compilation to write IDL.Here we use ATL to implement a Speek component object that can be spoken through the Ispeek interface, according to the size of the decibel that is communicated to the client via a junction point.1. Implementing a Conne
This article describes the complete process of developing an ActiveX control using ATL.
1. Create a project
Click "new project…" on the start page ...", Select the "ATL Project" project under the "ATL" category. The project name is "Calculator ". In the Project Wizard that appears later, use the default configuration.
2. Add controls
Right-click the p
COM technology requires high isolation between the client and the server, which is implemented through the interface, but the problem is that the interface method only provides a limited number of parameter data types, if this interface is based on idispatch, the optional range of parameter types is more limited. Due to these limitations, the C ++ object can be passed only when the following conditions are met:
Both the client and server are written by VC ++.
They must share object definition
This ATL ActiveX framework is suitable for serving as the bearer container for Windows Media Player, Flash, and sliverlight animations. The entire framework is distributed in the windowless folder, with 6 files in total. Architecture:
UseAdobe Flash PlayerAs a child Control
MainCodeAs follows: Class cmaindlg: Public caxwindowlesshost
Lresult cmaindlg: oninitdialog (uint/* umsg */, wparam/* wparam */, lparam/* lparam */, bool /* bhandled *
Because the entire cvvimage class is deleted in opencv2.2, it is inconvenient to use it in MFC, you can solve this problem by using the code in opencv2.1 in advance (get an hfile and a CPP file, and then compile it together in your project ).
However, in s2010, the error c2039: "drawtohdc": Not a member of "ATL: cimage" will occur.
This is mainly because of naming conflicts, which can be solved by introducing namespaces.
Change the last sentence of c
previous two functions can be called because they have registered the DLL for their unique ID through the registry in the system. Therefore, these two functions are called, obtain the corresponding DLL from the system. Finally, it is a method that does not register DLL. The implementation is as follows:
// Load the generated file and the c file. # Include "atlproject1_ I .h" # include "atlproject1_ I .c" int _ tmain (INT argc, _ tchar * argv []) {// define such a function pointer typedef hres
Write an ATL component, add a simple class, and add BEGIN_CATEGORY_MAP (CAirlineInfo) to the Class header file)IMPLEMENTED_CATEGORY (CATID_SafeForScripting)IMPLEMENTED_CATEGORY (CATID_SafeForInitializing)END_CATEGORY_MAP ()Then introduce the header file (# include To publish a file online, you need to package the dependent file as. cab, including the dll of the component, the library that the dll depends on, and an inf file. In my example, the content
#include The code is as follows: // W2A and a2w macros using ATL must use the uses_conversion uses_conversion;//unicodestringwchar_t* wsztext=L"1.Unicode convert characters toANSI; ";printf("%s\n",W2A(Wsztext));//withwprintfoutput non-English characters,need to set current geo-informationsetlocale(Lc_all,"CHS");//ansistring(Ansi:american National standards Institute)//Chinese Inner CodeMBCS:multi-byte Character sets,English Internal CodeSBCS:sing
First, an ATL control must be added to generate the corresponding class.1. contains header files.# Include 2. Define the resource ID# Define idc_btn_play 60003. Define members in the class declaration.Cbutton m_btnplay;4. In the wm_create messageRect RC1;Rc1.left = 60;Rc1.top = 0;Rc1.bottom = rc1.top + 18;Rc1.right = rc1.left + 50;M_btnplaycreate (m_hwnd, RC1, _ T ("stop"), ws_child | ws_visible, 0, idc_btn_play );5. Define Click Event and message in
8. Add a response event for the button I just added:
ATL provides two template classes for the idispatch interface of the COM Object: idispeventimpl
Class atl_no_vtable caddin:Public ccomobjectrootex .....
Public idispeventsimpleimpl __ Uuidof (Office: _ commandbarbuttonevents>The callback function of the event when the declaration button is clicked:
Void _ stdcall onclickbutton (idispatch */* Office: _ commandbarbutton **/Ctrl, variant_bo
1. Error c2370: 'libid _ atllib ': redefinition; Different Storage ClassC: \ Program Files \ Microsoft Visual Studio \ vc98 \ ATL \ include \ atlbase. H (79): See Declaration of 'libid _ atllib'
Check if both. H and. file C, which is generated under vc6. H and. the C file also defines the Type Library libid_atllib. You can use Conditional compilation to include only one of them. This problem is not found in the compiler of the higher version.
2. E
The first chapter can not exception "Hello, world!"
In this chapter, like all entry-level tutorials, I will not be able to exception a "Hello, world!" Program to start my tutorial. Then I'll go deep and introduce you to all the necessary information in this ATL version of the program. In addition, I will introduce some of the Win32 you may not know, including WinMain _t compatibility and how to add your own icon in MessageBox, and so on.
Be close to
simulation environment, that is, on the PC to achieve a Z-80 of the cross assembly and DEUBG debugging environment. Fortunately, due to the assembly level of simulation, it is not difficult, as long as the simple syntax analysis and lexical analysis, and then look up the table to the compilation of binary machine code, the task is completed. In the process of this task, accumulated some experience of grammar, lexical analysis, so I began to really create computer language work, and finally comp
Introduction
It is bit tricky to use msflexgrid control in ATL projects (I struggled lot with msdn and net) because:
Msflexgrid control is a visual basic control
Msflexgrid control requires runtime control license.
To check the problem you can do the following:
Create ATL Server DLL
Add ATL Composite Control
Right click and insert msflexgrid Control
Add
MFC ATL STL
Mfc atl stl classification: solves the problem
MFC ----- Application FrameworkATL ----- powerful tool for writing comSTL ----- used to write the logical part
MFC: the goal of MFC is desktop applications. Of course there are some network components, but they are not adequate. MFC is a set of App Wizard. In this regard, it has been very successful, but now the network is becoming more and more
When using ATL to develop COM components, there are several problems that may occur frequently. If you do not know, it is difficult to find a solution. I have seen that some people have also asked the same questions on csdn, but few have provided satisfactory answers. Therefore, I will write These FAQs below to avoid repeated efforts by others.
I. Q: When calling a widget on a webpage, the IE browser always prompts: "The Interaction Between ActiveX co
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.