ActiveX debugging and M_hwnd for empty solutions

Source: Internet
Author: User

1. Click "Start", "Run" command: regedit.
2. Navigate to Internet Explorer, Microsoft, hkey_localmachine, software, Main
3. In the right area, right-click to create a new DWORD value named Tabprocgrowth, and set the value data to 0.

vs without rebooting, you can directly press F5 to debug ActiveX!

See: http://social.microsoft.com/Forums/en-US/vsdebug/thread/e2c795cd-b7a0-4fad-b7c9-b1ca40d7302e

The OCX control HWND in the Web page is empty when the OCX control in the Web page does not appear before the screen (or the size is 0 o'clock), its wm_create message will not be called. This causes the Mfc/atl underlying library to crash when the script program calls some operations that must have a valid HWND (the Debug version asserts). Debug Version in MFC:
ASSERT (:: IsWindow (m_hwnd)); Debug Version in ATL:

Http://www.cnblogs.com/lidabo/archive/2012/12/12/2815199.html

Atlassert (:: IsWindow (m_hwnd)); The workaround for MFC is to hook Onsetclientsite in the derived class and create a window with the following code://Cmycontrol is derived from COleControl.
void Cmycontrol::onsetclientsite ()
{
It doesn ' t matter who the parent window was or what the size of
The window is because the control ' s window would be reparented
and resized correctly later when it ' s in-place activated.
if (m_pclientsite)
VERIFY (Createcontrolwindow (:: GetDesktopWindow (), CRect (0,0,0,0), CRect (0,0,0,0)));
Colecontrol::onsetclientsite ();
Solutions for}atl:
Cmycontrol is derived from CComControl
STDMETHOD (SetClientSite) (IOleClientSite *pclientsite)
{
if (pClientSite)
{
RECT rc = {0,0,0,0};
Don ' t has access to the container's window so just use the
Desktop. Window'll be resized correctly during In-place
Activation.
HWND hwnd = Createcontrolwindow (:: GetDesktopWindow (), RC);
_assert (HWND);
}
Return Ioleobjectimpl<cmycontrol>::setclientsite (pClientSite);
}hresult inplaceactivate (LONG iVerb, const rect* prcposrect)
{
Get the container ' s window.
_assert (M_spclientsite);
Lpoleinplacesite pinplacesite = NULL;
HRESULT hr = M_spclientsite->queryinterface (Iid_ioleinplacesite, (void**) &pinplacesite);
_assert (SUCCEEDED (HR) && pinplacesite);
HWND hparent = NULL;
hr = Pinplacesite->getwindow (&hparent);
_assert (SUCCEEDED (HR) && hparent);
Pinplacesite->release ();

Set Container window as our parent window
SetParent (hparent);
Return Ccomcontrolbase::inplaceactivate (IVerb, prcposrect);
}

ActiveX debugging and M_hwnd for empty solutions

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.