⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 active template library (atl) frequently asked questions.txt

📁 c_c++技巧集
💻 TXT
📖 第 1 页 / 共 2 页
字号:
 
 - Open the Project Settings dialog box, select the Link tab, and click Input in
  the Category box. Type LIBCMT.LIB in the Ignore libraries text box. Now do a
  build. You will get a list of unresolved externals. This list contains the
  CRT routines you are using. Look for the routines that you think may require
  the startup code.
 
 - Turn on the /VERBOSE linker option. From the resulting linker output, you can
  find a list of routines that require the CRT startup code.
 
If you need the startup code, then remove the _ATL_MIN_CRT definition from the
Project Settings. You can also dynamically link to CRT. This reduces your image
size but requires Msvcrt.dll.
 
When building as Release, the default option is to statically link to CRT and use
_ATL_MIN_CRT. This gives a smaller image size than dynamically linking to CRT,
at least when the startup code is avoided and the CRT APIs used by AppWizard are
used.
 
---------------------------------------------------------------------------
 
Q. How do I update the CLSID registry key under a version-independent ProgID? Or,
why is CLSIDFromProgID failing when passing a version independent ProgID?
 
This problem was fixed in ATL version 3.0.
 
A. Using the CLSIDFromProgID function fails when you pass a version independent
ProgID with only a CurVer key. To make it work, you need to add the CLSID key
under the version-independent ProgID.
 
If in your .RGS file, you have:
 
      TriBrowseObj.TriBrowseObj.1 = s 'TriBrowseObj Class'
     {
           CLSID = s '{3452E30B-8B87-11D0-A671-00A0C903977C}'
     }
     TriBrowseObj.TriBrowseObj = s 'TriBrowseObj Class'
     {
           CurVer = s 'TriBrowseObj.TriBrowseObj.1'
     }
 
   you must change it to:
 
      TriBrowseObj.TriBrowseObj.1 = s 'TriBrowseObj Class'
     {
             CLSID = s '{3452E30B-8B87-11D0-A671-00A0C903977C}'
     }
     TriBrowseObj.TriBrowseObj = s 'TriBrowseObj Class'
     {
             CLSID = s '{3452E30B-8B87-11D0-A671-00A0C903977C}'
             CurVer = s 'TriBrowseObj.TriBrowseObj.1'
     }
 
To fix this problem for the future, modify the wizard template (.rgs) in the
following directory:
 
 - For Visual C++ 4.x: \Msdev\Template\Atl
 
 - For Visual C++ 5.0: \Devstudio\Sharedide\Template\Atl
 
Change the Control.rgs file and any other .rgs files that are wrong. The
following statements:
 
     [!ProgID] = s '[!TypeName]'
    {
     CLSID = s '{[!ObjectGUID]}'
  [!if=(InsertableEnabled, "TRUE")]
     'Insertable'
  [!endif]
    }
  [!VersionIndependentProgID] = s '[!TypeName]'
    {
     CurVer = s '[!ProgID]'
    }
 
   should be changed to:
 
      [!ProgID] = s '[!TypeName]'
     {
       CLSID = s '{[!ObjectGUID]}'
  [!if=(InsertableEnabled, "TRUE")]
      'Insertable'
  [!endif]
     }
     [!VersionIndependentProgID] = s '[!TypeName]'
     {
       CLSID = s '{[!ObjectGUID]}'
       CurVer = s '[!ProgID]'
     }
 
---------------------------------------------------------------------------
 
Q. What are the known problems with the ATL 2.0 Object Wizard?
 
A. The ATL 2.0 Object Wizard might not be present in the Component Gallery. The
ATL 2.0 Object Wizard is not installed by the main ATL 2.0 setup program
(Atlinst.exe). It requires a separate setup program. You need to download and
run the ATL 2.0 Object Wizard Technology Preview (Objinst.exe) from the ATL Web
page. There is a separate ZIP file for Windows NT 3.51.
 
The ATL 2.0 Object Wizard may crash if an older version of Oleaut32.dll is
installed on the system. Make sure the version of Oleaut32.dll is at least
2.20.4049. The latest version is available for download at the Internet Explorer
3.x Web site. If this does not fix the problem, then install Service Pack 2 for
Windows NT 4.0.
 
---------------------------------------------------------------------------
 
Q. What DLLs do I need to ship with my control?
 
The following also applies to ATL 3.0:
 
A. If you build your control with the MinDependency option, the resulting DLL (or
EXE) is completely self contained. The control relies only on standard system
DLLs such as Kernel32, User32, Gdi32, Ole32, Oleaut32, and Advapi32. You need to
distribute another DLL only when you build a proxy/stub DLL that is not a part
of your server DLL.
 
If you build with the MinSize option, you are required to ship only Atl.dll with
your control. You should statically link to the C Run-Time (CRT) Libraries. In
case you do not need the CRT startup code, and with minimal use of the CRT,
statically linking to the CRT produces a smaller image size than dynamically
linking.
 
---------------------------------------------------------------------------
 
Q. What changes does a control need to run in the Visual Basic 5.0 Control
Creation Edition?
 
This problem was fixed in the Visual Studio 97 Service Pack 1.
 
A. If your control supports connection points and the IQuickActivate interface,
then it must support the IPropertyNotifySink connection point for Visual Basic
5.0. To support the IPropertyNotifySink connection point, add the following to
the inheritance list:
 
      public IPropertyNotifySinkCP<CYourControlName>
 
And add the following to your connection point map:
 
      CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
 
---------------------------------------------------------------------------
 
Q. What changes does a control need to run in an MFC 4.2b container?
 
The following also applies to ATL 3.0:
 
A. There is a problem with MFC 4.2b in setting up the event sink when the
IQuickActivate interface is used. The workaround is to comment out the following
line in your interface map:
 
      COM_INTERFACE_ENTRY_IMPL(IQuickActivate)
 
You can also remove the following line from your inheritance list:
 
      public IQuickActivateImpl<CYourControlName>
 
---------------------------------------------------------------------------
 
Q. Why do I get exceptions when debugging my control? What do they mean?
 
The following also applies to ATL 3.0:
 
A. Running the debugger in an environment that supports Structured Exception
Handling (SEH), like Windows NT, may produce exceptions like the following:
 
   First-chance exception in MY.OCX (KERNEL32.DLL): 0xC0000005:
  Access Violation.
 
These exceptions occur at a lower level in the system than your control. For more
information, see the Microsoft Knowledge Base article: Q105675.
 
---------------------------------------------------------------------------
 
Q. Why doesn't the container use my connection point interface?
 
The following also applies to ATL 3.0:
 
A. Make sure your outgoing interface is not defined as a dual interface. If the
connection point specifies an outgoing interface as a dual interface, most
containers are not able to create a sink object to connect to that connection
point. Containers that provide connection sinks for COM objects have to
dynamically create those sinks. If you specify a dual interface, it would be
possible for events to be fired using the IDispatch part of the dual interface.
It is also possible that the COM object fires events through the custom or
v-table part of the dual interface that is not implemented by most containers.
Therefore, most containers protect against hooking up a connection to a dual interface. The alternative is to use a dispinterface. Containers such as Visual Basic 5.0 and Internet Explorer only allows a dispinterface to be connected.
 
If you implement both the sink and the source, then it is recommended that you use a dual interface for connection points. See the ATL Connect sample for moreinformation.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -