1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
BOOL COleControlContainer::FillListSitesOrWnds(_AFX_OCC_DIALOG_INFO* pOccDlgInfo)
{
if (pOccDlgInfo==NULL) { return FALSE; }
COleControlSiteOrWnd *pSiteOrWnd = NULL;
//When this function is called, the m_listSitesOrWnds contains only ActiveX controls
//created by MFC from resource, or by user who called CreateControl.
//The code inserts the Win32 controls (found in dialog template resource) into
//the list, before, in between or after the ActiveX controls, according to the
//order in the dialog template.
POSITION pos = m_listSitesOrWnds.GetHeadPosition();
POSITION posOld = pos;
if(pos)
{
pSiteOrWnd = m_listSitesOrWnds.GetNext(pos);
}
HWND hwndStart=NULL;
for(unsigned i = 0; i < pOccDlgInfo->m_cItems; i++)
{
ASSERT(!pSiteOrWnd || pSiteOrWnd->m_pSite); //pSiteOrWnd must point at either ActiveX or NULL (list end).
if(pSiteOrWnd!=NULL && pSiteOrWnd->m_pSite!=NULL &&
pSiteOrWnd->m_pSite->m_nID == pOccDlgInfo->m_pItemInfo[i].nId)
{ => ne passe pas ici
//If not Windowless control, update the starting position in z-order search.
if (pSiteOrWnd->m_pSite->m_hWnd != NULL)
{
hwndStart = pSiteOrWnd->m_pSite->m_hWnd;
}
posOld = pos;
pSiteOrWnd = pos ? m_listSitesOrWnds.GetNext(pos) : NULL;
}
else
{Passe ici
if(pOccDlgInfo->m_pItemInfo[i].nId)
{
//AfxGetDlgItemStartFromHWND fix , is to handle non-unique ids
//of resource items (IDC_STATIC), that causes ::GetDlgItem
//to always find the first (in Win32 z-order child list) window with
//this id, and thus m_listSitesOrWnds contained several instances of the same hwnd.
//First time start searching from first z-order, else
//search from 1 after the previous window.
HWND hwndSearchFrom= (hwndStart == NULL) ?
GetWindow(m_pWnd->GetSafeHwnd(),GW_CHILD) :
::GetWindow(hwndStart,GW_HWNDNEXT);
HWND hwndCtrl=AfxGetDlgItemStartFromHWND(pOccDlgInfo->m_pItemInfo[i].nId, hwndSearchFrom);
//If not found, revert to prev method of GetDlgItem, this means Win32 children list and
//resource item array are out of sync
if (hwndCtrl == NULL)
{
hwndCtrl = ::GetDlgItem(m_pWnd->GetSafeHwnd(),pOccDlgInfo->m_pItemInfo[i].nId);
TRACE(traceAppMsg, 0, "Warning: Resource items and Win32 Z-order lists are out of sync. Tab order may be not defined well.\n");
}
COleControlSiteOrWnd *pTemp =
new COleControlSiteOrWnd(
hwndCtrl,
pOccDlgInfo->m_pItemInfo[i].bAutoRadioButton);
ASSERT(IsWindow(pTemp->m_hWnd));
if (IsWindow(pTemp->m_hWnd)) Plante ici, m_hWnd est null |
Partager