ActiveX control Some experiences permanently

xiaoxiao2021-03-06  18

Recently, the ActiveX control that can display dynamic expressions like QQ is completed. The effect is not bad. Compared with QQ control, it can be inserted into the richedit, and it does not flash (QQ will flash), efficiency is more efficient than QQ high. Take QQ that tears, the same picture, on my computer, my control can insert 49 in Richedit, and QQ inserted into 30 CPU usage to 100%. I was very happy, but there is still enough, QQ control can realize copy paste in Richedit, I can't do it, what should I do, is it to implement the IdataObject interface of the control, oh, not necessarily, by achieving a permanent interface What is the reason? Sorry, I don't understand, I don't guess myself, maybe it's going to see me, I will help me.

What is the implementation of permanence? Simply put, it is to save the status of the control. When you use it next time, you will be regenerated into a control and read the status of the control from the original inventory and restore it. What is the status of the control, basically some attributes, of course, this attribute is a broad property, including the inherent attributes specified by the COM library, and the property of the COM developer's own definition, and the user is added Member variables affecting the status of the control. From the above, it can be seen that the permanent control of the control includes at least two parts, one is saved, and the other is reading, which is what we usually say Save and Load. Below will be simply mentioned.

First of all, Save, Save, we have to decide what to save, nothing. Some COM inherent attributes are to be saved, such as version, control application status (m_sizeextent), enabled attribute (enable), these inherently said, directly Write is going out. Often affect our control status is the property defined by the COM component developer. For example, a control uses a picture to make a background, the path to the file is to be saved, and if your control has an array, then The array element is of course saved. However, what should I do if there is a pointer in the control member variable? Don't worry, the pointer does not need it, because the pointer is just an address, and this address is just a relative address in the process, closely related to the process. If you save this address, and the control is destroyed, when you run the program next time, then the address represented by the saved pointer will be wrong, because this address is for this new process, this It may not be, it is a wild pointer, and the wild pointer is not casual, hehe. Since the pointer does not save, we have to use it, what should I do? Oh, it's very simple, then new is coming out, when New, it is LOAD.

Now, LOAD is very simple. Load is just the status load that save out, for pointer variables, we will come out, so in this unit.

Pay attention, now it is precautions, when LOAD, our variable load is the same as Save's order, that is, which property we first save first, which property should be load, can not be chaotic.

转载请注明原文地址:https://www.9cbs.com/read-42150.html

New Post(0)