// This is a part of the Extraview ExtraClass C++ library.
// Copyright (C) 1997 Extraview Limited
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Extraview ExtraClass Class Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Extraview Class product.
//
//
// MfcAtlPropertyPage.h
// Template class that allows an MFC COlePropertyPage
// derived class to be used in an ATL server.
//
//
/*********************************************************
Steps to use CMfcAtlPropertyPage
0 - Once only
~~~~~~~~~
Import the resource file MfcAtlPropertyPage.rgs into
your project.
Give the resource an ID of IDR_MFCATLPPG
Ensure the correct path is given in the file view for
MfcAtlPropertyPage.rgs and change if neccessary.
1. Update your IDL/ODL file
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Add a coclass statement to your IDL/ODL file
for the new property page and support the interface IUnknown
Example
-------
[
uuid(E948B670-153F-11d1-8F2D-000000000000),
helpstring("MFC Property Page")
]
coclass PpgAnimal
{
interface IUnknown;
};
2. Create the property page class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Create a property page resource and COlePropertyPage
derived class as normal using the dialog editor and
ClassWizard
3. Create a new header file for the class definition
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Create an empty text file and add the following:
a) An include statement for MfcAtlPropertyPage.h
or Extraview.h
b) An include statement for your COlePropertyPage
derived class
c) A typedef statement for the CMfcAtlPropertyPage
template class using your property page.
This is required as the ATL OBJECT_ENTRY macro
does not accept template class declarations
Example
-------
// OlePpgAnimal.h - Declaration of COlePpgAnimal typedef
#include "MfcAtlPropertyPage.h"
// Definition of CPpgAnimal (COlePropertyPage derived) class
#include "PpgAnimal.h"
// typedef that stops OBJECT_ENTRY macro from crying
typedef Extraview::CMfcAtlPropertyPage<&CLSID_PpgAnimal, CPpgAnimal> COlePpgAnimal;
4. Update the server object map
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Open the main ATL server source file that contains
the server object map. This file typically has the
same name as your project, with the cpp extension.
Add your new include file to the list of includes.
Add your typedef class to the object map by
inserting a new OBJECT_ENTRY macro entry.
Example
-------
...
<Many #include statements>
...
#include "OlePpgAnimal.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_PpgAnimal, COlePpgAnimal)
...
<More OBJECT_ENTRY macro entries>
...
END_OBJECT_MAP()
ATL will now use your MFC COlePropertyPage derived class
as though it were part of ATL.
---------------------------------------------------------
Example using three property pages with the minimum of fuss
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1. IDL update
~~~~~~~~~~~~~
[
uuid(E948B670-153F-11d1-8F2D-000000000000),
helpstring("Arms Property Page")
]
coclass PpgArms
{
interface IUnknown;
};
[
uuid(E948B670-153F-11d1-8F2D-000000000000),
helpstring("Legs Property Page")
]
coclass PpgLegs
{
interface IUnknown;
};
[
uuid(E948B670-153F-11d1-8F2D-000000000000),
helpstring("Body Property Page")
]
coclass PpgBody
{
interface IUnknown;
};
2. dialog resource and class creation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Usual way for all three classes.
Assume classes are named CPpgArms, CPpgLegs, CPpgBody
in PpgArms.h, PpgLegs.h and PpgBody.h respectively
3. header file with typedefs
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// MFCPpg.h
// One header file for all object
#include "MfcAtlPropertyPage.h"
#include "PpgArms.h"
#include "PpgLegs.h"
#include "PpgBody.h"
typedef Extraview::CMfcAtlPropertyPage
<&CLSID_PpgArms, CPpgArms> COlePpgArms;
typedef Extraview::CMfcAtlPropertyPage
<&CLSID_PpgLegs, CPpgLegs> COlePpgLegs;
typedef Extraview::CMfcAtlPropertyPage
<&CLSID_PpgBody, CPpgBody> COlePpgBody;
4. Update the server object map
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Assume project is CoolControl so object
// map is in CoolControl.cpp by default
#include "MFCPpg.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_PpgArms, COlePpgArms)
OBJECT_ENTRY(CLSID_PpgLegs, COlePpgLegs)
OBJECT_ENTRY(CLSID_PpgBody, COlePpgBody)
<More OBJECT_ENTRY macro entries>
END_OBJECT_MAP()
Done!
---------------------------------------------------------
*********************************************************/
#ifndef __MFCATLPROPERTYPAGE_H_
#define __MFCATLPROPERTYPAGE_H_
namespace Extraview {
#pragma warning(disable:4786)
/////////////////////////////////////////////////////////////////////////////
// CMfcAtlPropertyPage
template <const CLSID * TpClsid, class TCOlePropertyPageDerived>
class ATL_NO_VTABLE CMfcAtlPropertyPage :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CMfcAtlPropertyPage<TpClsid, TCOlePropertyPageDerived>, TpClsid>,
public IUnknown
{
public:
CMfcAtlPropertyPage() :
m_pUnkPpg(NULL)
{
}
static HRESULT WINAPI UpdateRegistry(BOOL bRegister)
{
USES_CONVERSION;
_ATL_REGMAP_ENTRY m_regmapEntries[2];
OLECHAR ochBuffer[50];
StringFromGUID2(*TpClsid, ochBuffer, 50);
m_regmapEntries[0].szKey=L"CLSID";
m_regmapEntries[0].szData=ochBuffer;
m_regmapEntries[1].szKey=NULL;
return _Module.UpdateRegistryFromResourceD(
IDR_MFCATLPPG,
bRegister,
m_regmapEntries
);
}
BEGIN_COM_MAP(CMfcAtlPropertyPage)
COM_INTERFACE_ENTRY(IUnknown)
COM_INTERFACE_ENTRY_AGGREGATE(IID_IPropertyPage, m_pUnkPpg)
END_COM_MAP()
public:
HRESULT FinalConstruct();
void FinalRelease();
private:
LPUNKNOWN m_pUnkPpg;
};
template <const CLSID * TpClsid, class TCOlePropertyPageDerived>
HRESULT CMfcAtlPropertyPage<TpClsid, TCOlePropertyPageDerived>::FinalConstruct()
{ AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
TCOlePropertyPageDerived *pPpg= new TCOlePropertyPageDerived;
pPpg->EnableAutomation();
pPpg->EnableAggregation();
pPpg->m_pOuterUnknown=static_cast<LPUNKNOWN>(this);
LPDISPATCH _pDispatch=pPpg->GetIDispatch(FALSE);
m_pUnkPpg=reinterpret_cast<LPUNKNOWN>(&(pPpg->m_xInnerUnknown));
return NOERROR;
}
template <const CLSID * TpClsid, class TCOlePropertyPageDerived>
void CMfcAtlPropertyPage<TpClsid, TCOlePropertyPageDerived>::FinalRelease()
{
if (m_pUnkPpg)
m_pUnkPpg->Release();
}
} // namespace Extraview
#endif //__MFCATLPROPERTYPAGE_H_
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
mfc资源大全1.rar_MFC_MFC大全_MFC资源大全_mfc 源码_mfc所有资源 (137个子文件)
index.dat 3KB
index.dat 1KB
index.dat 1KB
msform.exe 123KB
axhost.exe 109KB
emboss.gif 18KB
pattern.gif 12KB
ebgfx_xray1.gif 10KB
adv_copypaste1.gif 10KB
ebgfx_rotozoom2.gif 10KB
stretched_round_button.gif 9KB
adv_copypaste2.gif 9KB
nonrectangle_button1.gif 6KB
mow2.gif 6KB
ebgfx_rotozoom1.gif 6KB
mow3.gif 4KB
invert_bitmap.gif 4KB
BitmapPicture.gif 4KB
round_buttons.gif 3KB
3d_text.gif 3KB
nonrectangle_button2.gif 3KB
ebgfx_otaku.gif 3KB
ebgfx_flare.gif 2KB
trick_button.gif 2KB
mow1.gif 2KB
ebgfx_colors.gif 421B
MfcAtlPropertyPage.h 7KB
dither_blt.jpg 169KB
ebgfx_effects.jpg 30KB
bitmap_text_button1.jpg 29KB
color_button2.jpg 20KB
color_button1.jpg 18KB
bitmap_text_button2.jpg 17KB
bitmap_text_button3.jpg 17KB
button_color_picker.jpg 14KB
button_color_picker2.jpg 5KB
MfcAtlPropertyPage.rgs 207B
index.shtml 30KB
rotate_bitmap.shtml 21KB
adv_copypaste.shtml 19KB
invert_bitmap_inplace.shtml 17KB
grayscale_fadein.shtml 16KB
fadein.shtml 15KB
submission_guide.shtml 15KB
ATLMFC_PropPage.shtml 14KB
activex_script_hosting.shtml 13KB
activex_script_hosting_2.shtml 13KB
ATLMFC_PropPage2.shtml 12KB
flat_button.shtml 12KB
dcom_timeout.shtml 11KB
logo_bitmap_in_client.shtml 11KB
bitmap_picture.shtml 11KB
emboss.shtml 10KB
emboss_pattern.shtml 9KB
draw_bitmap.shtml 9KB
copypaste_dragdrop.shtml 9KB
formview_background.shtml 8KB
ebgfx.shtml 8KB
bitmap_text_button.shtml 8KB
nonrectangle_button.shtml 8KB
transparent_bitmap.shtml 8KB
3d_text.shtml 7KB
flat_button2.shtml 7KB
256color_bitmap.shtml 7KB
bitmap_from_bmp.shtml 7KB
ddb_to_dib.shtml 6KB
atl_Conexe.shtml 6KB
draw_bmp.shtml 6KB
dither_blt.shtml 6KB
color_button.shtml 6KB
rtf_clipboard.shtml 6KB
atl_icmpcom.shtml 5KB
invert_bitmap.shtml 5KB
button_color_picker.shtml 5KB
shade_image.shtml 5KB
trick_button.shtml 5KB
grayscale.shtml 5KB
btn_circular_button.shtml 5KB
windowless.shtml 4KB
dib_to_ddb.shtml 4KB
bitmap_toc.shtml 4KB
img2dib.shtml 4KB
copy_to_clipboard.shtml 4KB
button_color_picker2.shtml 4KB
window_to_file.shtml 4KB
dibsection_from_bmp.shtml 4KB
stretch_round_button.shtml 4KB
round_buttons.shtml 3KB
about.shtml 3KB
bmp_in_mdiclient2.shtml 3KB
bitmap_to_file.shtml 3KB
buttonctrl_toc.shtml 2KB
ATL_CodeHelper.shtml 2KB
bitmap_to_clipboard.shtml 2KB
classview_system_interfaces.shtml 2KB
copy_graphics.shtml 2KB
animated_button.shtml 2KB
dimensions.shtml 2KB
emf_to_clipboard.shtml 2KB
atl_toc.shtml 2KB
共 137 条
- 1
- 2
钱亚锋
- 粉丝: 86
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0