LRESULT CTangramTabCtrlWnd::OnCreatePage(WPARAM wParam, LPARAM lParam) { HWND hPageWnd = (HWND)wParam; //CTabPageWnd* pWnd = new CTabPageWnd(); //pWnd->SubclassWindow(hPageWnd); CWnd* pWnd = FromHandlePermanent(hPageWnd); if (pWnd == NULL) { pWnd = new CTabPageWnd(); pWnd->SubclassWindow(hPageWnd); } AddTab(pWnd, (LPCTSTR)lParam, (UINT)GetTabsNum()-1); //AddTab(pView,LPCTSTR(pObj->m_strCaption),0); //if(nIndex==m_pTangramXMLObj->m_nActivePage) //{ // SetFocusedItem(pItem); //} //AddPage(pWnd,(LPCTSTR)lParam); //SendMessage(WM_TGM_SETACTIVEPAGE); InvalidateRect(NULL); //if(pWnd) //{ // pWnd->UnsubclassWindow(); // delete pWnd; //} return 0; }
///////////////////////////////////////////////////////////////////////////// //++ // // CBasePropertyPage::OnCreate // // Description: // Handler for the WM_CREATE message. // // Arguments: // lpCreateStructIn // Window create structure. // // Return Value: // -1 // Error. // // 0 // Success. // //-- ///////////////////////////////////////////////////////////////////////////// int CBasePropertyPage::OnCreate( LPCREATESTRUCT lpCreateStructIn ) { AFX_MANAGE_STATE( AfxGetStaticModuleState() ); // // Attach the window to the property page structure. // This has been done once already in the main application, since the // main application owns the property sheet. It needs to be done here // so that the window handle can be found in the DLL's handle map. // if ( FromHandlePermanent( m_hWnd ) == NULL ) // is the window handle already in the handle map { HWND hWnd = m_hWnd; m_hWnd = NULL; Attach( hWnd ); m_bDoDetach = TRUE; } // if: is the window handle in the handle map return CPropertyPage::OnCreate( lpCreateStructIn ); } //*** CBasePropertyPage::OnCreate
void CMDITabs::Update() { SetRedraw(false); HWND active = ::GetTopWindow(m_mdiClient); // get active view window (actually the frame of the view) typedef std::vector<HWND> TWndVec; typedef TWndVec::iterator TWndIter; TWndVec vChild; // put all child windows in a list (actually a vector) for (HWND child = active; child; child = ::GetNextWindow(child, GW_HWNDNEXT)) { vChild.push_back(child); } TCITEM item; char text[256]; item.pszText = text; int i = GetItemCount(); while ( i-- > 0 ) // for each tab { item.mask = TCIF_PARAM; GetItem(i, &item); TWndIter it = std::find(vChild.begin(), vChild.end(), HWND(item.lParam)); if (it == vChild.end()) // associatete view does no longer exist, so delete the tab { DeleteItem(i); if (m_bImages) RemoveImage(i); } else // update the tab's text, image and selection state { item.mask = TCIF_TEXT; ::GetWindowText(*it, text, 256); if (m_bImages) m_images.Replace(i, (HICON)::GetClassLong(*it, GCL_HICONSM)); SetItem(i, &item); if (*it == active) SetCurSel(i); // associated view is active => make it the current selection vChild.erase(it); // remove view from list } } // all remaining views in vChild have to be added as new tabs i = GetItemCount(); for (TWndIter it = vChild.begin(), end = vChild.end(); it != end; ++it) { item.mask = TCIF_TEXT|TCIF_PARAM|TCIF_IMAGE; ::GetWindowText(*it, text, 256); if (m_bImages) m_images.Add((HICON)::GetClassLong(*it, GCL_HICONSM)); item.iImage = i; item.lParam = LPARAM(*it); InsertItem(i, &item); if (*it == active) SetCurSel(i); ++i; } // this removes the control when there are no tabs and shows it when there is at least one tab bool bShow = GetItemCount() >= m_minViews; if ((!bShow && IsWindowVisible()) || (bShow && !IsWindowVisible())) { static_cast<CMDIFrameWnd*>(FromHandlePermanent(::GetParent(m_mdiClient)))->RecalcLayout(); } RedrawWindow(NULL, NULL, RDW_FRAME|RDW_INVALIDATE|RDW_ERASE); SetRedraw(true); }
/** * ウィンドウ プロシージャ * @param[in] hWnd ウィンドウ ハンドル * @param[in] message 処理される Windows メッセージを指定します * @param[in] wParam メッセージの処理で使う付加情報を提供します。このパラメータの値はメッセージに依存します * @param[in] lParam メッセージの処理で使う付加情報を提供します。このパラメータの値はメッセージに依存します * @return メッセージに依存する値を返します */ LRESULT CALLBACK CWndProc::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { CWndProc* pWnd = FromHandlePermanent(hWnd); if (pWnd == NULL) { return ::DefWindowProc(hWnd, message, wParam, lParam); } else { return pWnd->WindowProc(message, wParam, lParam); } }
BOOL CImageList::Attach(HIMAGELIST hImageList) { ASSERT(m_hImageList == NULL); // only attach once, detach on destroy ASSERT(FromHandlePermanent(hImageList) == NULL); if (hImageList == NULL) return FALSE; CHandleMap* pMap = afxMapHIMAGELIST(TRUE); ASSERT(pMap != NULL); pMap->SetPermanent(m_hImageList = hImageList, this); return TRUE; }
/** * CWndProc オブジェクトに関連付けられた Windows のウィンドウを破棄します * @return ウィンドウが破棄された場合は 0 以外を返します。それ以外の場合は 0 を返します */ BOOL CWndProc::DestroyWindow() { if (m_hWnd == NULL) { return FALSE; } CWndProc* pWnd = FromHandlePermanent(m_hWnd); const BOOL bResult = ::DestroyWindow(m_hWnd); if (pWnd == NULL) { Detach(); } return bResult; }