Non-virtual function polymorphism used in ATL/wtl
Template
This is a method that uses the template mechanism to implement polymorphism in C ++. It avoids the overhead of virtual function vtable and is the most basic principle for understanding ATL/wtl.
// Method 1
Cstring STR = _ T ("teststr ");
Uses_conversion;
Lpwstr pwstr = new wchar_t [Str. getlength () + 1];
Wcscpy (pwstr, T2W (lpctstr) Str ));
// Method 2Cstring STR = _ T ("teststr ");
Uses_conversion;
Lpwcstr pwcstr = a2cw (lpcstr) Str );
A2cw (lpcstr)-> (lpcwstr), user_conversion indicates that some intermediate variables are defined. This statement must be defined before the ATL conversion macro is used.
It is easier to convert the lpcws
1. Pass in the base class and inherit the implementationWhen designing a COM interface, we often encounter the following situation: design a base interface, and other interfaces inherit this interface. A typical example is the iunknown interface. All com interfaces must be inherited from the iunknown interface, and the implementations of these interfaces are the same. We cannot write an iunknown interface implementation for each COM interface. The implementation of the iunknown interface is comp
I recently made an online banking project in Niit.bangalore. This project is written almost in VB, and only a small part of it involves the ATL component, which only teaches us to write distributed applications. I wrote a middle-tier component that used ATL and ADO to query back-end (SQL Server) and some of the code was shown here.
I assume that the reader understands (at least) ATL's COM programming and V
Introduced
So far, we haven't discussed anything about assembly language. But if we really want to get to the bottom of the ATL, we can't avoid this, because ATL uses some low-level technology and some inline assembly language to make it smaller and faster. Here, I assume that the reader already has the basics of assembly language, so I'll just focus on my topic and not write another assembly language tuto
Atl_no_vtable does not allow the compiler to generate a vtable and does not set the vpointer value.Normally, when calling constructor and destructor, the compiler inserts the correspondingCode. This code can be omitted if atl_no_vtable is used. This is used in ATL because this class is an abstract class and vtable is not required. The real class is ccomobject
--------------------------------------------------------------
# Define atl_no_vtable _ d
Scene:1. Zoom the picture, needless to say, is the need for thumbnails and painting on the interface of this kind.2. Cut, needless to say, is to cut a portion of the picture used to draw the control background.3. The wximage of Wxwidget is a direct method of bringing these functions.gdiplus::bitmap* cutimage (gdiplus::image* source,int x,int y,int width,int height) { Gdiplus::rect zoomrect (0, 0, width,height); gdiplus::bitmap* Pimagescale_ = new Gdiplus::bitmap (zoomrect.width, zoomrect.height)
Scene:1. CStatic supports an indefinite length of string, can also support the picture background, and of course the parent control responds to the wm_ctlcolorstatic message.2. CStatic that can respond to a click event can be used as a simple button without the need for custom drawing operations.3. Normal created cstatic can not respond to click Time, need to add ss_notify style, note that Aa_static_click is a custom event ID.#ifndef __dh_static#define __dh_static#include "Window/common/dh_win_m
Understanding the atlnotable and template implementations in ATL without virtual function table Polymorphism
Wentao sun
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
# Include
Iostream
>
Using
Namespace
STD; Template Typename t > Class B1{ Public : Void Sayhi (){T * PT = Static_cast T *> ( This );PT -> Printclassname ();} VoidPrintclassname (){Cout"Th
Compile ActiveX control that does not bring up warnings in the browser
When we compile ActiveX controls, if we use them in a browser, a prompt indicating that the running scripts are not secure is often displayed. If we use them, this will cause great inconvenience.
According to the description of msdn, there are usually two methods: Implementing the iobjectsafe interface and modifying the registry. Generally, if you use ATL to develop ActiveX control
ATL is convenient and quick to create components, but the internal structure hierarchy is complex and many template classes are used. I simplified the analysis principles.
The component implements a specific interface. for creation, basic lifecycle management, and interface query, the macro or parent class should be processed as much as possible.
The internal object xobj of each component is used for creation.
You can create an MFC console program and
For components generated by ATL, it is easy to implement multiple interfaces (whether through methods that inherit multiple interfaces or through internal classes). How can this problem be achieved, the key is to manage the life cycle and creation of components, and support for multi-interface queries by components.
The following figure shows the simulated classes that implement multiple interface components for multiple inheritance and internal class
There are a large number of Macros in ATL. When you look at them, they are all big, but there are still rules to follow. The key is to grasp the two tables. The first is the object table, which is defined by the following macro group:
Begin_object_map
Object_entry
End_object_map
This group of macros defines the COM Object table. Through this table, com can easily create corresponding COM Objects Based on clsid.
The other table is an interface tab
# Include
Everyone may think that t2bstr, w2t, and other Macros in ATL are very convenient.But be careful, because:They allocate memory from the stack and call alloca internally. The function allocates the memory of the returned string from the stack, and the memory will not be released until the function is called to return.If such macros are repeatedly called for tens of thousands of times in a loop, you will inevitably generate stack overflow! Ho
Referenced from:The description of the image in HTML. Can the ATL parameter be displayed by branch?
Http://topic.csdn.net/t/20040904/21/3340893.html
IMG SRC
=
Img.jpg alt
=
"
1111111 bbbbbbbbbb
"
>
How can I disable the browser from displaying "X" when the SRC address of IMG is incorrect"
Http://topic.csdn.net/t/20060913/10/5018384.html
IMG ID
=
"
AA
"
SRC
=
"
Aa.jpg
"
Onerror
=
"
This.sr
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.