BUG: MFC - Changing the BorderStyle Stock Property of An ActiveX Control Changes the Z-Order (306539)
The information in this article applies to:
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
This article was previously published under Q306539 SYMPTOMS When a Microsoft Foundation Classes (MFC) ActiveX Control's
BorderStyle stock property is changed at runtime, this changes the Z-order of
the ActiveX control to the topmost window. CAUSE When an MFC ActiveX control's BorderStyle stock property is changed at runtime, the function _AfxToggleBorderStyle is called. This function calls SetWindowLong and then calls SetWindowPos, but does not set the SWP_NOZORDER flag. The ActiveX control is therefore incorrectly moved to the
top of the Z-order. RESOLUTION To work around this problem, you can save the Z-order
position before you set the BorderStyle in the ActiveX Control. Next, restore the Z-order position after
you set the BorderStyle. The following is an example:
void CMyEditCtrl::SetBorderStyle(short sBorderStyle)
{
HWND hwndParent = 0;
HWND hwndPrev = 0;
if (m_pInPlaceSite != NULL)
{
m_pInPlaceSite->GetWindow(&hwndParent);
if (hwndParent)
hwndPrev = ::GetNextDlgTabItem(hwndParent, m_hWnd, TRUE);
}
COleControl::SetBorderStyle(sBorderStyle);
if (hwndPrev && ::IsWindow(hwndPrev))
::SetWindowPos(m_hWnd, hwndPrev, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
}
STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
REFERENCES For more information, visit the following Microsoft Web
site: For more general information about Visual C++ .NET, visit the
following Microsoft Usenet newsgroup and Microsoft Web site:
Modification Type: | Minor | Last Reviewed: | 5/28/2003 |
---|
Keywords: | kbbug kbNewsgroupLink kbpending KB306539 |
---|
|