void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, LPTSTR pstrValue, int nMaxLength, CRecordset* pRecordset) { ASSERT_VALID(pRecordset); HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); if (pDX->m_bSaveAndValidate) { int nLen = ::GetWindowText(hWndCtrl, pstrValue, nMaxLength); if (nLen == 0) { if (pRecordset->IsFieldNullable(pstrValue)) pRecordset->SetFieldNull(pstrValue, TRUE); } else pRecordset->SetFieldNull(pstrValue, FALSE); } else if (pRecordset->IsDeleted()) { CString strDeleted(MAKEINTRESOURCE(AFX_IDS_DELETED)); AfxSetWindowText(hWndCtrl, strDeleted); } else AfxSetWindowText(hWndCtrl, pstrValue); }
void AFXAPI AfxTextFloatFormat(CDataExchange* pDX, int nIDC, void* pData, double value, int nSizeGcvt) { ASSERT(pData != NULL); HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); TCHAR szBuffer[32]; if (pDX->m_bSaveAndValidate) { ::GetWindowText(hWndCtrl, szBuffer, _countof(szBuffer)); double d; if (!_AfxSimpleFloatParse(szBuffer, d)) { AfxMessageBox(AFX_IDP_PARSE_REAL); pDX->Fail(); // throws exception } if (nSizeGcvt == FLT_DIG) *((float*)pData) = (float)d; else *((double*)pData) = d; } else { _stprintf(szBuffer, _T("%.*g"), nSizeGcvt, value); AfxSetWindowText(hWndCtrl, szBuffer); } }
void AFXAPI AfxTextFloatFormat(CDataExchange* pDX, int nIDC, void* pData, double value, int nSizeGcvt) { ASSERT(pData != NULL); pDX->PrepareEditCtrl(nIDC); HWND hWndCtrl; pDX->m_pDlgWnd->GetDlgItem(nIDC, &hWndCtrl); const int TEXT_BUFFER_SIZE = 400; TCHAR szBuffer[TEXT_BUFFER_SIZE]; if (pDX->m_bSaveAndValidate) { ::GetWindowText(hWndCtrl, szBuffer, _countof(szBuffer)); double d; if (_sntscanf_s(szBuffer, _countof(szBuffer), _T("%lf"), &d) != 1) { AfxMessageBox(AFX_IDP_PARSE_REAL); pDX->Fail(); // throws exception } if (nSizeGcvt == FLT_DIG) *((float*)pData) = (float)d; else *((double*)pData) = d; } else { ATL_CRT_ERRORCHECK_SPRINTF(_sntprintf_s(szBuffer, _countof(szBuffer), _countof(szBuffer) -1, _T("%.*g"), nSizeGcvt, value)); AfxSetWindowText(hWndCtrl, szBuffer); } }
void CMDIChildWnd::OnUpdateFrameTitle(BOOL bAddToTitle) { // update our parent window first GetMDIFrame()->OnUpdateFrameTitle(bAddToTitle); if ((GetStyle() & FWS_ADDTOTITLE) == 0) return; // leave child window alone! CDocument* pDocument = GetActiveDocument(); if (bAddToTitle) { TCHAR szText[256+_MAX_PATH]; if (pDocument == NULL) Checked::tcsncpy_s(szText, _countof(szText), m_strTitle, _TRUNCATE); else Checked::tcsncpy_s(szText, _countof(szText), pDocument->GetTitle(), _TRUNCATE); if (m_nWindow > 0) { TCHAR szWinNumber[16+1]; _stprintf_s(szWinNumber, _countof(szWinNumber), _T(":%d"), m_nWindow); if( lstrlen(szText) + lstrlen(szWinNumber) < _countof(szText) ) { Checked::tcscat_s( szText, _countof(szText), szWinNumber ); } } // set title if changed, but don't remove completely AfxSetWindowText(m_hWnd, szText); } }
void AFXAPI DDX_CBString(CDataExchange* pDX, int nIDC, CString& value) { HWND hWndCtrl = pDX->PrepareCtrl(nIDC); if (pDX->m_bSaveAndValidate) { // just get current edit item text (or drop list static) int nLen = ::GetWindowTextLength(hWndCtrl); if (nLen > 0) { // get known length ::GetWindowText(hWndCtrl, value.GetBufferSetLength(nLen), nLen+1); } else { // for drop lists GetWindowTextLength does not work - assume // max of 255 characters ::GetWindowText(hWndCtrl, value.GetBuffer(255), 255+1); } value.ReleaseBuffer(); } else { // set current selection based on model string if (::SendMessage(hWndCtrl, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)(LPCTSTR)value) == CB_ERR) { // just set the edit text (will be ignored if DROPDOWNLIST) AfxSetWindowText(hWndCtrl, value); } } }
void CChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle) //---------------------------------------------------- { // update our parent window first GetMDIFrame()->OnUpdateFrameTitle(bAddToTitle); if ((GetStyle() & FWS_ADDTOTITLE) == 0) { return; // leave child window alone! } CDocument* pDocument = GetActiveDocument(); if (bAddToTitle) { TCHAR szText[256+_MAX_PATH]; if (pDocument == NULL) { lstrcpy(szText, m_strTitle); } else { lstrcpy(szText, pDocument->GetTitle()); if (pDocument->IsModified()) lstrcat(szText, "*"); } if (m_nWindow > 0) { wsprintf(szText + lstrlen(szText), _T(":%d"), m_nWindow); } // set title if changed, but don't remove completely AfxSetWindowText(m_hWnd, szText); } }
AFX_STATIC void AFX_CDECL _Afx_DDX_TextWithFormat(CDataExchange* pDX, int nIDC, LPCTSTR lpszFormat, UINT nIDPrompt, ...) // only supports windows output formats - no floating point { va_list pData; va_start(pData, nIDPrompt); HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); TCHAR szT[32]; if (pDX->m_bSaveAndValidate) { // the following works for %d, %u, %ld, %lu ::GetWindowText(hWndCtrl, szT, _countof(szT)); if (!_AfxSimpleScanf(szT, lpszFormat, pData)) { AfxMessageBox(nIDPrompt); pDX->Fail(); // throws exception } } else { wvsprintf(szT, lpszFormat, pData); // does not support floating point numbers - see dlgfloat.cpp AfxSetWindowText(hWndCtrl, szT); } va_end(pData); }
void ArbI18N::DDX_ASCII_Text_(CDataExchange* pDX, int nIDC, CString& value) { HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); if (pDX->m_bSaveAndValidate) { char tempStrANSI[512]; memset(tempStrANSI, 0, 512); ::GetWindowText(hWndCtrl, tempStrANSI, 512); int iLimitText = SendMessage(hWndCtrl, EM_GETLIMITTEXT, 0, 0); CString tempStrUTF8 = translateToUTF8(tempStrANSI); int iSize = tempStrUTF8.GetLength(); if (iSize <= iLimitText) value = tempStrUTF8; else { char truncatedUTF8[512]; CString truncatedANSI; CString prompt; arb_safe_strncpy(truncatedUTF8, tempStrUTF8, iLimitText); truncatedANSI = translateFromUTF8(truncatedUTF8); ::SetWindowText(hWndCtrl, truncatedANSI); prompt.Format(GetIntlString(IDS_UTF8_STRING_TOOLONG), tempStrANSI); AfxMessageBox(prompt, MB_ICONEXCLAMATION); pDX->Fail(); //Throw exceptions } } else { CString tempStrANSI = translateFromUTF8(value); AfxSetWindowText(hWndCtrl, tempStrANSI); } }
void CMainFrame::UpdateFrameTitleForDocument(LPCTSTR lpszDocName) { // copy first part of title loaded at time of frame creation TCHAR szText[256+_MAX_PATH]; if (GetStyle() & FWS_PREFIXTITLE) { szText[0] = '\0'; // start with nothing // get name of currently active view if (lpszDocName != NULL) { lstrcpy(szText, lpszDocName); // add current window # if needed if (m_nWindow > 0) wsprintf(szText + lstrlen(szText), _T(":%d"), m_nWindow); lstrcat(szText, _T(" - ")); } lstrcat(szText, m_strTitle); } else { // get name of currently active view if ( m_nAppMode!=modeNoProject ) { lstrcpy(szText, m_project.GetName()); lstrcat(szText, _T(" - ")); lstrcat(szText, m_strTitle); } else lstrcpy(szText, m_strTitle); if ( m_nAppMode==modeDebug ) lstrcat(szText, _T(" [run] ")); else if ( m_nAppMode==modeDebugBreak ) lstrcat(szText, _T(" [break] ")); if (lpszDocName != NULL) { BOOL maximized; CMDIChildWnd* child = theApp.GetMainFrame()->MDIGetActive(&maximized); if (!maximized) { lstrcat(szText, _T(" - [")); lstrcat(szText, lpszDocName); // add current window # if needed if (m_nWindow > 0) wsprintf(szText + lstrlen(szText), _T(":%d"), m_nWindow); lstrcat(szText, _T("]")); } } } // set title if changed, but don't remove completely // Note: will be excessive for MDI Frame with maximized child AfxSetWindowText(m_hWnd, szText); }
/// <summary>Dialog data exchange for paths</summary> UtilExport void AFXAPI DDX_Text(CDataExchange* pDX, int nIDC, Path& path) { HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); if (pDX->m_bSaveAndValidate) ::GetWindowText(hWndCtrl, (wchar*)path, MAX_PATH); else AfxSetWindowText(hWndCtrl, path.c_str()); }
void AFXAPI DDX_FieldCBString(CDataExchange* pDX, int nIDC, CString& value, CRecordset* pRecordset) { ASSERT_VALID(pRecordset); HWND hWndCtrl = pDX->PrepareCtrl(nIDC); if (pDX->m_bSaveAndValidate) { // just get current edit item text (or drop list static) int nLen = ::GetWindowTextLength(hWndCtrl); if (nLen != -1) { CString strTemp; ::GetWindowText(hWndCtrl, strTemp.GetBuffer(nLen), nLen+1); strTemp.ReleaseBuffer(); nLen = strTemp.GetLength(); if (nLen > value.GetAllocLength()) AfxFailMaxChars(pDX, value.GetAllocLength()); // get known length ::GetWindowText(hWndCtrl, value.GetBuffer(0), nLen+1); } else { // for drop lists GetWindowTextLength does not work - assume // preallocated length ::GetWindowText(hWndCtrl, value.GetBuffer(0), value.GetAllocLength()+1); } value.ReleaseBuffer(); if (value.GetLength() == 0) { if (pRecordset->IsFieldNullable(&value)) pRecordset->SetFieldNull(&value, TRUE); } else { pRecordset->SetFieldNull(&value, FALSE); } } else { if (!pRecordset->IsOpen() || pRecordset->IsFieldNull(&value)) { SendMessage(hWndCtrl, CB_SETCURSEL, (WPARAM)-1, 0L); } else { // set current selection based on model string if (::SendMessage(hWndCtrl, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)(LPCTSTR)value) == CB_ERR) { // just set the edit text (will be ignored if DROPDOWNLIST) AfxSetWindowText(hWndCtrl, value); } } } }
void AFXAPI DDX_FieldText(CDataExchange* pDX, int nIDC, CString& value, CRecordset* pRecordset) { ASSERT_VALID(pRecordset); HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); if (pDX->m_bSaveAndValidate) { // check if length is too long (this is complicated by Windows NT/J) int nLen = ::GetWindowTextLength(hWndCtrl); if (nLen > value.GetAllocLength()) { if (!_afxDBCS) AfxFailMaxChars(pDX, value.GetAllocLength()); CString strTemp; ::GetWindowText(hWndCtrl, strTemp.GetBuffer(nLen), nLen+1); strTemp.ReleaseBuffer(); nLen = strTemp.GetLength(); if (nLen > value.GetAllocLength()) AfxFailMaxChars(pDX, value.GetAllocLength()); } // get known length ::GetWindowText(hWndCtrl, value.GetBuffer(0), nLen+1); value.ReleaseBuffer(); if (nLen == 0) { if (pRecordset->IsFieldNullable(&value)) pRecordset->SetFieldNull(&value, TRUE); } else { pRecordset->SetFieldNull(&value, FALSE); } } else if (pRecordset->IsDeleted()) { CString strDeleted(MAKEINTRESOURCE(AFX_IDS_DELETED)); AfxSetWindowText(hWndCtrl, strDeleted); } else { AfxSetWindowText(hWndCtrl, value); } }
void CGuiMiniFrame::RecalcLayout(BOOL bNotify) { if (!m_bInRecalcLayout) { CMiniDockFrameWnd::RecalcLayout(bNotify); // syncronize window text of frame window with dockbar itself TCHAR szTitle[_MAX_PATH]; m_wndDockBar.GetWindowText(szTitle, _countof(szTitle)); AfxSetWindowText(m_hWnd, szTitle); } }
void CMiniDockFrameWnd::RecalcLayout(BOOL bNotify) { if (!m_bInRecalcLayout) { CMiniFrameWnd::RecalcLayout(bNotify); // syncronize window text of frame window with dockbar itself CString strTitle; m_wndDockBar.GetWindowText(strTitle); AfxSetWindowText(m_hWnd, strTitle); } }
BOOL AFXAPI AfxFieldText(CDataExchange* pDX, int nIDC, void* pv, CRecordset* pRecordset) { ASSERT_VALID(pRecordset); HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); TCHAR szT[2]; if (pDX->m_bSaveAndValidate) { ::GetWindowText(hWndCtrl, szT, _countof(szT)); if (szT[0] == '\0') { if (pRecordset->IsFieldNullable(pv)) { pRecordset->SetFieldNull(pv); return TRUE; } } else pRecordset->SetFieldNull(pv, FALSE); } else { if (!pRecordset->IsOpen() || pRecordset->IsFieldNull(pv)) { szT[0] = '\0'; AfxSetWindowText(hWndCtrl, szT); return TRUE; } else if (pRecordset->IsDeleted()) { CString strDeleted(MAKEINTRESOURCE(AFX_IDS_DELETED)); AfxSetWindowText(hWndCtrl, strDeleted); return TRUE; } } return FALSE; }
void AFXAPI DDX_Text(CDataExchange* pDX, int nIDC, CString& value) { HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); if (pDX->m_bSaveAndValidate) { int nLen = ::GetWindowTextLength(hWndCtrl); ::GetWindowText(hWndCtrl, value.GetBufferSetLength(nLen), nLen+1); value.ReleaseBuffer(); } else { AfxSetWindowText(hWndCtrl, value); } }
void AFXAPI DDX_Text(CDataExchange* pDX, int nIDC, LPTSTR value, int nMaxLen) { ASSERT(nMaxLen != 0); HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); if (pDX->m_bSaveAndValidate) { int nLen = ::GetWindowTextLength(hWndCtrl); int nRetrieved = ::GetWindowText(hWndCtrl, value, nMaxLen); if (nLen > nRetrieved) TRACE1("Text in control ID %d is too long. Call DDV_MaxChars()!\n", nIDC); } else { AfxSetWindowText(hWndCtrl, value); } }
/// <summary>Dialog data exchange for std::wstring</summary> UtilExport void AFXAPI DDX_Text(CDataExchange* pDX, int nIDC, wstring& value) { HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); CString str; if (pDX->m_bSaveAndValidate) { int nLen = ::GetWindowTextLength(hWndCtrl); ::GetWindowText(hWndCtrl, str.GetBufferSetLength(nLen), nLen+1); str.ReleaseBuffer(); value = (LPCWSTR)str; } else { AfxSetWindowText(hWndCtrl, value.c_str()); } }
void CChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle) { GetMDIFrame()->OnUpdateFrameTitle(bAddToTitle); if ( (GetStyle() & FWS_ADDTOTITLE) == 0) return; if (bAddToTitle) { CDocument* pDoc = GetActiveDocument(); CString csText; if (pDoc == NULL) csText = m_strTitle; else { csText = pDoc->GetTitle(); } if (m_nWindow > 0) csText.Format(_T("%s: %d"), csText, m_nWindow); if (pDoc->IsModified()) csText += " *"; AfxSetWindowText(m_hWnd, csText); } }
void CChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle) { GetMDIFrame()->OnUpdateFrameTitle(bAddToTitle); if ((GetStyle() & FWS_ADDTOTITLE) == 0) return; // leave child window alone! CView * pView = GetActiveView( ); if (bAddToTitle) { TCHAR szText[256+_MAX_PATH]; memset( szText, 0, sizeof(szText) ); if (pView == NULL) lstrcpyn(szText, m_strTitle, 256+MAX_PATH); else pView->SendMessage( WM_USER_GETVIEWTITLE, 255+MAX_PATH, long(szText) ); // set title if changed, but don't remove completely AfxSetWindowText(m_hWnd, szText); } }
BOOL AFXAPI AfxFieldText(CDataExchange* pDX, int nIDC, void* pv, CDaoRecordset* pRecordset) { ASSERT_VALID(pRecordset); HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); TCHAR szT[2]; if (pDX->m_bSaveAndValidate) { ::GetWindowText(hWndCtrl, szT, _countof(szT)); if (szT[0] == '\0') { // If edit buffer not NULL prior to update, set it dirty // to catch case of setting field value from PSEUDO NULL to NULL. if (!pRecordset->IsFieldNull(pv)) pRecordset->SetFieldDirty(pv, TRUE); pRecordset->SetFieldNull(pv); return TRUE; } else { // If edit buffer NULL prior to update, set it dirty // to catch case of setting field value to PSEUDO NULL. if (pRecordset->IsFieldNull(pv)) pRecordset->SetFieldDirty(pv, TRUE); pRecordset->SetFieldNull(pv, FALSE); } } else { if (!pRecordset->IsOpen() || pRecordset->IsFieldNull(pv)) { szT[0] = '\0'; AfxSetWindowText(hWndCtrl, szT); return TRUE; } } return FALSE; }
void AFXAPI DDX_CBStringExact(CDataExchange* pDX, int nIDC, CString& value) { HWND hWndCtrl = pDX->PrepareCtrl(nIDC); if (pDX->m_bSaveAndValidate) { DDX_CBString(pDX, nIDC, value); } else { // set current selection based on data string int i = (int)::SendMessage(hWndCtrl, CB_FINDSTRINGEXACT, (WPARAM)-1, (LPARAM)(LPCTSTR)value); if (i < 0) { // just set the edit text (will be ignored if DROPDOWNLIST) AfxSetWindowText(hWndCtrl, value); } else { // select it SendMessage(hWndCtrl, CB_SETCURSEL, i, 0L); } } }
void ArbI18N::DDX_UTF8_Text_(CDataExchange* pDX, int nIDC, CString& value, int nStorageSize) //Note: nStorageSize is optional, and only used if storage size was NOT tripled for UTF8. // When used, nStorageSize is the same size used for DDV_UTF8_MaxChars (nChar) // It is also possible to set nStorageSize = 1/3 nChars, which is like the default { ASSERT (nStorageSize <= MAXIMUM_DB_STORAGE); //Verify proper calling CString prompt; HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC); if (pDX->m_bSaveAndValidate) { char tempStrANSI[512]; char truncatedUTF8[512]; CString truncatedANSI; memset(tempStrANSI, 0, 512); ::GetWindowText(hWndCtrl, tempStrANSI, 512); int iLimitText = SendMessage(hWndCtrl, EM_GETLIMITTEXT, 0, 0); CString tempStrUTF8 = translateToUTF8(tempStrANSI); int iSize = tempStrUTF8.GetLength(); if (! DB_IS_UTF8()) //This defaults to normal DDX_Text for non-UTF8 { if (iSize <= iLimitText) value = tempStrUTF8; else { MessageBeep(0xFFFFFFFF); } return; } //Remainder is for UTF8 if (nStorageSize == 0) //This is default, no optional nStorageSize { if (iSize <= (iLimitText/CHAR_ENCODING_MULTIPLE())*3) value = tempStrUTF8; else { MessageBeep(0xFFFFFFFF); //CAMqa81465 arb_safe_strncpy(truncatedUTF8, tempStrUTF8, (iLimitText/CHAR_ENCODING_MULTIPLE())*3); truncatedANSI = translateFromUTF8(truncatedUTF8); ::SetWindowText(hWndCtrl, truncatedANSI); value = truncatedUTF8; //We need to set the value now prompt.Format(GetIntlString(IDS_UTF8_STRING_TOOLONG), tempStrANSI); AfxMessageBox(prompt, MB_ICONEXCLAMATION); pDX->Fail(); //Throw exceptions } } // if (iSize... else { //We want maximum characters for English and we'll accept a moderate //number of accented characters. It is only valid for UTF8 DB's. if (iSize <= nStorageSize) value = tempStrUTF8; else { arb_safe_strncpy(truncatedUTF8, tempStrUTF8, nStorageSize); truncatedANSI = translateFromUTF8(truncatedUTF8); ::SetWindowText(hWndCtrl, truncatedANSI); value = truncatedUTF8; //We need to set the value now prompt.Format(GetIntlString(IDS_UTF8_STRING_TOOLONG), tempStrANSI); AfxMessageBox(prompt, MB_ICONEXCLAMATION); pDX->Fail(); //Throw exceptions } } } // if (nStorageSize... else { CString tempValue = translateFromUTF8(value); AfxSetWindowText(hWndCtrl, tempValue); } }
void CMainFrame::OnUpdateFrameTitle(BOOL) { AfxSetWindowText(m_hWnd, GetDocTitle()); }
void CDockBar::DockControlBar(CControlBar* pBar, LPCRECT lpRect) { ASSERT_VALID(this); ASSERT_VALID(pBar); ASSERT(pBar->IsKindOf(RUNTIME_CLASS(CControlBar))); // set CBRS_FLOAT_MULTI style if docking bar has it if (m_bFloating && (pBar->m_dwDockStyle & CBRS_FLOAT_MULTI)) m_dwStyle |= CBRS_FLOAT_MULTI; CRect rectBar; pBar->GetWindowRect(&rectBar); if (pBar->m_pDockBar == this && (lpRect == NULL || rectBar == *lpRect)) { // already docked and no change in position return; } if (!(m_dwStyle & CBRS_FLOAT_MULTI)) { CString strTitle; pBar->GetWindowText(strTitle); AfxSetWindowText(m_hWnd, strTitle); } // align correctly and turn on all borders pBar->m_dwStyle &= ~(CBRS_ALIGN_ANY); pBar->m_dwStyle |= (m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY; int nPos = -1; if (lpRect != NULL) { // insert into appropriate row CRect rect(lpRect); ScreenToClient(&rect); CPoint ptMid(rect.left + rect.Width()/2, rect.top + rect.Height()/2); nPos = Insert(pBar, rect, ptMid); // position at requested position pBar->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS); } else { // always add on current row, then create new one m_arrBars.Add(pBar); m_arrBars.Add(NULL); // align off the edge initially pBar->SetWindowPos(NULL, -afxData.cxBorder2, -afxData.cyBorder2, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOCOPYBITS); } // attach it to the docking site if (pBar->GetParent() != this) pBar->SetParent(this); if (pBar->m_pDockBar == this) pBar->m_pDockBar->RemoveControlBar(pBar, nPos); else if (pBar->m_pDockBar != NULL) pBar->m_pDockBar->RemoveControlBar(pBar); pBar->m_pDockBar = this; // get parent frame for recalc layout CFrameWnd* pFrameWnd = GetDockingFrame(); pFrameWnd->DelayRecalcLayout(); }
void CExtDockBar::_SlideDockControlBar( CControlBar* pBar, LPCRECT lpRect, BOOL bMovingEnabled ) { ASSERT_VALID(this); ASSERT_VALID(pBar); ASSERT_KINDOF(CControlBar, pBar); CRect rcBar; pBar->GetWindowRect(&rcBar); if( pBar->m_pDockBar == this && (lpRect == NULL || rcBar == *lpRect) ) { // already docked and no change in position return; } // set CBRS_FLOAT_MULTI style if docking bar has it if( m_bFloating && (pBar->m_dwDockStyle & CBRS_FLOAT_MULTI) ) m_dwStyle |= CBRS_FLOAT_MULTI; m_dwStyle &= ~(CBRS_SIZE_FIXED | CBRS_SIZE_DYNAMIC); m_dwStyle |= pBar->m_dwStyle & (CBRS_SIZE_FIXED | CBRS_SIZE_DYNAMIC); if( !(m_dwStyle & CBRS_FLOAT_MULTI) ) { TCHAR szTitle[_MAX_PATH]; pBar->GetWindowText(szTitle, _countof(szTitle)); AfxSetWindowText(m_hWnd, szTitle); } // align correctly and turn on all borders DWORD dwStyle = pBar->GetBarStyle(); dwStyle &= ~(CBRS_ALIGN_ANY); dwStyle |= (m_dwStyle & CBRS_ALIGN_ANY) | CBRS_BORDER_ANY; if( m_bFloating ) dwStyle |= CBRS_FLOATING; else dwStyle &= ~CBRS_FLOATING; pBar->SetBarStyle( dwStyle ); /* // hide first if changing to a new docking site to avoid flashing BOOL bShow = FALSE; if( pBar->m_pDockBar != this && pBar->IsWindowVisible() ) { pBar->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_HIDEWINDOW); bShow = TRUE; } */ int nPos = -1; if( lpRect != NULL ) { // insert into appropriate row CRect rc( lpRect ); ScreenToClient( &rc ); CPoint ptMid( rc.left + rc.Width()/2, rc.top + rc.Height()/2 ); nPos = Insert( pBar, rc, ptMid ); // position at requested position if( bMovingEnabled ) pBar->SetWindowPos( NULL, rc.left, rc.top, rc.Width(), rc.Height(), SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS |SWP_NOREDRAW|SWP_NOSENDCHANGING ); } else { // always add on current row, then create new one m_arrBars.Add(pBar); m_arrBars.Add(NULL); // align off the edge initially if( bMovingEnabled ) pBar->SetWindowPos( NULL, -afxData.cxBorder2, -afxData.cyBorder2, 0, 0, SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_NOCOPYBITS |SWP_NOREDRAW|SWP_NOSENDCHANGING ); } // attach it to the docking site if( pBar->GetParent() != this ) pBar->SetParent(this); if( pBar->m_pDockBar == this ) pBar->m_pDockBar-> RemoveControlBar(pBar, nPos); else if( pBar->m_pDockBar != NULL ) pBar->m_pDockBar-> RemoveControlBar( pBar, -1, m_bFloating && !pBar->m_pDockBar->m_bFloating ); pBar->m_pDockBar = this; /* if( bShow ) { ASSERT(!pBar->IsWindowVisible()); pBar->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE|SWP_SHOWWINDOW); } */ // remove any place holder for pBar in this dockbar RemovePlaceHolder( pBar ); /* // get parent frame for recalc layout CFrameWnd* pFrameWnd = GetDockingFrame(); pFrameWnd->DelayRecalcLayout(); */ }