ActiveX IE 패치.. 나만그런게 아니었나봅니다.

이올라스인지 삼올라스인지 그녀석 땜쉬롱 귀찮아지기 시작했는데..
여튼 열심히 작업을 하고있는 中
아주 엿(?)같은 상황이.. 발생;

이넘의 ActiveX에 테두리가 생겼다가(적용안됨)~ 안생겼다가(적용됨)~
끄응스러운 일이 발생했지 뭡니까..

MS에서 말해주는 방식대로 이렇게도 저렇게도 하는데..
훙훙..

Allblog검색중 저와 비슷한 문제점 발견..

그라드 님의 블로그

아웅.. 머리아포~~

머.. 될때 있는거보니. -_-;; 일단은 제공된 방식대로 +_+ =3

IE 6.0 ActiveX 설계번경 pre patch download

-0- 툭하면 경로 까묵기에…

kr

http://download.microsoft.com/download/8/3/d/83dcd69f-739d-4297-8258-8c5218e09fff/WindowsXP-KB912945-x86-KOR.exe

eng

http://download.microsoft.com/download/b/f/6/bf65fcfa-fe0f-490e-b84e-3de9e77c9f7c/WindowsXP-KB912945-x86-ENU.exe

IObjectSafety 인터페이스 구현


ActiveX 컨트롤을 맹글때 특별한 코드 추가 없이 위자드로 생성하면
위 그림처럼 “안전하지 않은 ActiveX 컨트롤을 사용하는것을 차단…”
이러한 메세지가 뜨게 된다.

이럴때 IObjectSafety 구현코드를 넣으면 되는데..
-.- 아직은 그 깊게 우케 돌아가는지 모른다..

역시나 ctrl + CV 신공으로~ 열심히 붙여넣으게 되면;;; 으흐흐..

일단 관련코드를 소개하겠다.

물론.. 순수 내 지식은 아니고 ;;

데브피아, 오광섭 님의 미친병아리 서비의 이야기, 늘 보기만 해도

골이 띵한 MSDN 에서 이리저리 뒤져보고 …

머 그런거져;;

xxxCtrl.h

[CODE]#include "ObjSafe.h"[/CODE]

[CODE] DECLARE_INTERFACE_MAP()
BEGIN_INTERFACE_PART(ObjSafe, IObjectSafety)
STDMETHOD_(HRESULT, GetInterfaceSafetyOptions) (
/* [in] */ REFIID riid,
/* [out] */ DWORD __RPC_FAR *pdwSupportedOptions,
/* [out] */ DWORD __RPC_FAR *pdwEnabledOptions
);

STDMETHOD_(HRESULT, SetInterfaceSafetyOptions) (
/* [in] */ REFIID riid,
/* [in] */ DWORD dwOptionSetMask,
/* [in] */ DWORD dwEnabledOptions
);
END_INTERFACE_PART(ObjSafe);[/CODE]

xxxCtrl.cpp
ek120000000027.hfk120000000019.cpp

파일출처:미친병아리 http://www.madchick.com

[CODE]#include "helpers.h"[/CODE]

[CODE]const DWORD dwSupportedBits =
INTERFACESAFE_FOR_UNTRUSTED_CALLER |
INTERFACESAFE_FOR_UNTRUSTED_DATA;
const DWORD dwNotSupportedBits = ~ dwSupportedBits;
/////////////////////////////////////////////////////////////////////////////
// CxxxCtrl::XObjSafe::GetInterfaceSafetyOptions
// Allows container to query what interfaces are safe for what. We're
// optimizing significantly by ignoring which interface the caller is
// asking for.

HRESULT STDMETHODCALLTYPE
CxxxCtrl::XObjSafe::GetInterfaceSafetyOptions(
/* [in] */ REFIID riid,
/* [out] */ DWORD __RPC_FAR *pdwSupportedOptions,
/* [out] */ DWORD __RPC_FAR *pdwEnabledOptions)
{
METHOD_PROLOGUE(CxxxCtrl, ObjSafe)

HRESULT retval = ResultFromScode(S_OK);

// does interface exist?
IUnknown FAR* punkInterface;
retval = pThis->ExternalQueryInterface(&riid,
(void * *)&punkInterface);
if (retval != E_NOINTERFACE) { // interface exists
punkInterface->Release(); // release it–just checking!
}

// we support both kinds of safety and have always both set,
// regardless of interface
*pdwSupportedOptions = *pdwEnabledOptions = dwSupportedBits;

return retval; // E_NOINTERFACE if QI failed
}[/CODE]

[CODE]////////////////////////////////////////////////////////////////////////////
// CxxxCtrl::XObjSafe::SetInterfaceSafetyOptions
// since we're always safe, this is a no-brainer-but we do check to make
// sure the interface requested exists and that the options we're asked to
// set exist and are set on (we don't support unsafe mode).

HRESULT STDMETHODCALLTYPE
CxxxCtrl::XObjSafe::SetInterfaceSafetyOptions(
/* [in] */ REFIID riid,
/* [in] */ DWORD dwOptionSetMask,
/* [in] */ DWORD dwEnabledOptions)
{
METHOD_PROLOGUE(CxxxCtrl, ObjSafe)

// does interface exist?
IUnknown FAR* punkInterface;
pThis->ExternalQueryInterface(&riid,(void**)&punkInterface);
if (punkInterface)
{ // interface exists
punkInterface->Release(); // release it–just checking!
}
else
{ // interface doesn't exist
return ResultFromScode(E_NOINTERFACE);
}

// can't set bits we don't support
if (dwOptionSetMask & dwNotSupportedBits)
{
return ResultFromScode(E_FAIL);
}

// can't set bits we do support to zero
dwEnabledOptions &= dwSupportedBits;
// (we already know there are no extra bits in mask )
if ((dwOptionSetMask & dwEnabledOptions) != dwOptionSetMask)
{
return ResultFromScode(E_FAIL);
}

// don't need to change anything since we're always safe
return ResultFromScode(S_OK);
}[/CODE]

[CODE]/////////////////////////////////////////////////////////////
// Interface map for IObjectSafety
BEGIN_INTERFACE_MAP( CxxxCtrl, COleControl )
INTERFACE_PART(CxxxCtrl, IID_IObjectSafety, ObjSafe)
END_INTERFACE_MAP()[/CODE]

[CODE]/////////////////////////////////////////////////////////////
// IObjectSafety member functions
// Delegate AddRef, Release, QueryInterface
ULONG FAR EXPORT CxxxCtrl::XObjSafe::AddRef()
{
METHOD_PROLOGUE(CxxxCtrl, ObjSafe)
return pThis->ExternalAddRef();
}

ULONG FAR EXPORT CxxxCtrl::XObjSafe::Release()
{
METHOD_PROLOGUE(CxxxCtrl, ObjSafe)
return pThis->ExternalRelease();
}

HRESULT FAR EXPORT CxxxCtrl::XObjSafe::QueryInterface(
REFIID iid, void FAR* FAR* ppvObj)
{
METHOD_PROLOGUE(CxxxCtrl, ObjSafe)
return (HRESULT)pThis->ExternalQueryInterface(&iid, ppvObj);
}[/CODE]


관련 MSDN :
MSDN Home >
 MSDN Library >
  Win32 and COM Development >
   Component Development >
    ActiveX Controls >
     Technical Articles >
      Signing and Marking ActiveX Controls >

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaxctrl/html/msdn_signmark.asp

ActiveX 컨트롤 깨져서 보일때~~

해결 방법은
일일히 해당 컨트롤들을 Invalidate 해주는 방법이 있는데 이것도 깔끔하게는 안되더군여..
그래서 정법을 소개합니다.. 이걸로 하니 깔끔하게 잘되더군여..

/////
1.. 먼저 헤더파일에..

[CODE]public:
virtual BOOL OnSetObjectRects(LPCRECT lpRectPos, LPCRECT lpRectClip); //오버라이드

private:
void MyGetClippingCoordinates(LPCRECT pPosRect, LPCRECT pClipRect,
LPRECT pIntersectRect, LPPOINT pOffsetPoint);[/CODE]

2. CPP 파일에…

[CODE]void CxxxCtrl::MyGetClippingCoordinates(LPCRECT pPosRect, LPCRECT pClipRect,
LPRECT pIntersectRect, LPPOINT pOffsetPoint)
{
int clipLeft = 0;
int clipTop = 0;

if ((pClipRect == NULL) || IsRectEmpty(pClipRect))
{
CopyRect(pIntersectRect, pPosRect);
}
else
{
IntersectRect(pIntersectRect, pPosRect, pClipRect);
clipLeft = pClipRect->left;
clipTop = pClipRect->top;
}

pOffsetPoint->x = min(0, pPosRect->left – clipLeft);
pOffsetPoint->y = min(0, pPosRect->top – clipTop);
}

BOOL CxxxCtrl::OnSetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
ASSERT(lprcPosRect != NULL);

// Remember the position rectangle for later
m_rcPos = *lprcPosRect;

// Calculate complete rectangle including the tracker (if present)
CRect rectPos = m_rcPos;
if (m_bUIActive && m_pRectTracker != NULL)
{
// Save new clipping rectangle (for DestroyTracker)
if (lprcClipRect != NULL)
m_pRectTracker->m_rectClip = *lprcClipRect;

// Adjust tracker rectangle to new dimensions
CRect rectTmp = rectPos;
rectTmp.OffsetRect(-rectTmp.left, -rectTmp.top);
m_pRectTracker->m_rect = rectTmp;

// Adjust the "true" rectangle to include handles/hatching
UINT nHandleSize = m_pRectTracker->m_nHandleSize – 1;
rectPos.InflateRect(nHandleSize, nHandleSize);
}

// Now clip that rectangle as appropriate
CRect rectClip;

// CHANGE – call your own copy of _GetClippingCoordinates
MyGetClippingCoordinates(rectPos, lprcClipRect, rectClip, &m_ptOffset);

// Move outer window first. then inner window

if (!m_bInPlaceSiteWndless)
{
CWnd* pWndOuter = GetOuterWindow();

//BEGIN CHANGE
if (pWndOuter != NULL)
{

::MoveWindow(pWndOuter->m_hWnd, rectPos.left, rectPos.top,
rectPos.Width(), rectPos.Height(), TRUE);
}
//END CHANGE
if (pWndOuter != this)
MoveWindow(0, 0, rectPos.Width(), rectPos.Height());
}

return TRUE;
} [/CODE]

자료출처 : 데브피아(http://www.devpia.com) VC++ Q&A #483453
2004-11-25 꽁기꽁기(kurt6) 님의 글

ActiveX 에서 컨트롤 사용하기

ActiveX에 Dialog를 올렸다.
Dialog에 MS 웹브라우져 컨트롤을 넣었다..

뎅장.. 안나온다…

[CODE]BOOL CMoongTaengApp::InitInstance()
{
BOOL bInit = COleControlModule::InitInstance();

AfxEnableControlContainer(); //요것만 추가해주자!!
.
.
.
}[/CODE]

데브피아(http://www.devpia.com)
VC++ Q/A 게시판

Q: 473982번 게시물 최종희(bell2) 님
A: 473982번 게시물 야요(yaho)님