BOOL CSSEditCtrls::SubclassCtrls(CWnd *pParent, int nIDEdit, int nIDSpinner, int nIDSlider) { ASSERT(!m_nLockCnt); m_nLockCnt = 1; ASSERT(nIDEdit && nIDEdit != -1); ASSERT(!nIDSpinner || nIDSpinner != -1 && nIDSpinner != nIDEdit); ASSERT(!nIDSlider || nIDSlider != -1 && nIDSlider != nIDEdit && (!nIDSlider || nIDSlider != nIDSpinner)); ASSERT(!m_hWnd); if (!SubclassDlgItem(nIDEdit, pParent)) return FALSE; ASSERT(!m_Spinner.m_hWnd); if (nIDSpinner && !m_Spinner.SubclassDlgItem(nIDSpinner, pParent)) { UnsubclassWindow(); return FALSE; } ASSERT(!m_Slider.m_hWnd); if (nIDSlider && !m_Slider.SubclassDlgItem(nIDSlider, pParent)) { if (nIDSpinner) m_Spinner.UnsubclassWindow(); UnsubclassWindow(); return FALSE; } ASSERT(m_hWnd && GetDlgCtrlID() == nIDEdit); ASSERT(!nIDSpinner || m_Spinner.m_hWnd && m_Spinner.GetDlgCtrlID() == nIDSpinner); ASSERT(!nIDSlider || m_Slider.m_hWnd && m_Slider.GetDlgCtrlID() == nIDSlider); --m_nLockCnt; return TRUE; }
BOOL CTextCheckBox::AutoLoad(UINT nID, CWnd* pParent) { // first attach the CBitmapCheckButton to the dialog control if (!SubclassDlgItem(nID, pParent)) return FALSE; // // Load the bitmaps for the different states // m_bmpNormal.DeleteObject(); m_bmpNormal.LoadBitmap( "CHECKBOXN" ); m_bmpFocus.DeleteObject(); m_bmpFocus.LoadBitmap( "CHECKBOXF" ); m_bmpChecked.DeleteObject(); m_bmpChecked.LoadBitmap( "CHECKBOXC" ); // // Load the fonts and color // m_lfNormal.lfWeight = FW_DEMIBOLD; //m_lfNormal.lfQuality = ANTIALIASED_QUALITY; //strcpy( m_lfNormal.lfFaceName, "Arial" ); SizeToContent(); return TRUE; }
BOOL CAniButton::AutoLoad(UINT nID, CWnd* pParent) { // first attach the CBitmapCheckButton to the dialog control if (!SubclassDlgItem(nID, pParent)) return FALSE; CRect Rect; GetClientRect( Rect ); // Create the animated control and size the button to the avi if( !::IsWindow( m_AnimateCtrl ) ) { m_AnimateCtrl.Create( WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT, Rect, this, 0 ); m_AnimateCtrl.Open( m_nAniID ); m_AnimateCtrl.GetClientRect(Rect); SetWindowPos(NULL, 0, 0, Rect.Width()+2, Rect.Height()+2, SWP_NOMOVE|SWP_NOZORDER|SWP_NOREDRAW|SWP_NOACTIVATE); //Rect.OffsetRect(1,1); m_AnimateCtrl.MoveWindow(Rect); } return TRUE; }
//CMyButton是CButton派生类,具有CButton的全部成员函数, //但在创建时需要使用BS_OWNERDRAW风格。 //如果按钮不是动态生成,使用Attach函数使CMyButton代替原来按钮的窗口过程。 BOOL CMyButton3::Attach(const UINT nID, CWnd* pParent) { //GetDlgItem(nID)->ModifyStyle(0,BS_OWNERDRAW,0); if (!SubclassDlgItem(nID, pParent)) return FALSE; return TRUE; }
void CColorStatic::SetLabelEx(UINT nID, CWnd *pParent) { SubclassDlgItem(nID, pParent); m_bIsTransParent = FALSE; m_nBkColor = COLOR_TORJAN_BK; SetLogoFont(DEFAULT_FONT, DEFAULT_HEIGHT); SetColor(~COLOR_TORJAN_BK); }
void CColorStatic::SetLabelQuery(UINT nID, CWnd *pParent) { SubclassDlgItem(nID, pParent); m_bIsTransParent = FALSE; m_nBkColor = PASSECK_DIALOG_BKCOLOR; SetLogoFont(DEFAULT_FONT, DEFAULT_HEIGHT); SetColor(COLOR_TEXT_NORMAL); }
BOOL CArborEditCurrency::SubclassEdit(UINT nID, CWnd* pParent, int iCurrencyCode) { // set the currency code if the iCurrencyCode parm is supplied if(iCurrencyCode > 0 ) SetCurrencyCode(iCurrencyCode); return SubclassDlgItem(nID, pParent); }
BOOL CColorButton::Attach(const UINT nID, CWnd *pParent, const COLORREF BGColor, const COLORREF FGColor, const COLORREF DisabledColor, const UINT nBevel) { if (!SubclassDlgItem(nID, pParent)) return FALSE; //m_fg = FGColor; m_bg = BGColor; m_disabled = RGB(128, 128, 128); m_bevel = nBevel; return TRUE; }
void CListBoxCtrl::Set(CWnd* pParent, int nIDCombo, SC_IntArray& intValArray) { VERIFY(SubclassDlgItem(nIDCombo, pParent)); m_intValArray = intValArray; multiSelection = true; ResetStrings(); EnableWindow(!listStrings.IsEmpty()); ResetSelection(); }
void CListBoxCtrl::Set(CWnd* pParent, int nIDCombo, int* pintVal) { VERIFY(SubclassDlgItem(nIDCombo, pParent)); m_pintVal = pintVal; multiSelection = false; ResetStrings(); EnableWindow(!listStrings.IsEmpty()); ResetSelection(); }
// Autoload will load the bitmap resources BOOL CMappedBitmapButton::AutoLoad(UINT nID, CWnd* pParent, UINT idBitmapResource) { // first attach the CMappedBitmapButton to the dialog control if (!SubclassDlgItem(nID, pParent)) return FALSE; if (!LoadBitmap(idBitmapResource)) return FALSE; // size to content SizeToContent(); return TRUE; }
BOOL CArborEdit::SubclassEdit(UINT nID, CWnd* pParent, EDIT_STYLE EditStyle, BOOL bNegativeValue, int iNumberOfDigits, BOOL bSkipValidateOfControls ) { CWnd* hwndControl = NULL; m_bNegativeValue = bNegativeValue; m_EditStyle = EditStyle; m_iNumberOfDigits = iNumberOfDigits; return SubclassDlgItem(nID, pParent); }
void CSendCombo::OnParentInit( UINT uID, CWnd *pParent ) { // BUGBUG hard coded maximum number of copy to's // an array to toggle and track muliple selections // out of the m_ctrlTo combo box for( int i=0; i<MAX_CC; ++i) m_iSelect[i] = 0; CClientDC dc( pParent ); CString sTest = "Test String"; CSize csName = dc.GetTextExtent( sTest, sTest.GetLength() ); m_uCharHeight = csName.cy + 1; sTest.Empty(); BOOL bRet = SubclassDlgItem( uID, pParent ); }
void SearchEdit::Init(UINT id, CWnd* parent) { SubclassDlgItem(id,parent); m_editing = false; SetWindowText(m_displayText); CRect clientSize; GetClientRect(clientSize); CSize fontSize = theApp.MeasureFont(GetFont()); int ym = (clientSize.Height()-fontSize.cy)/2; CRect editSize; GetRect(editSize); editSize.OffsetRect(0,ym); editSize.left += m_image->GetSize().cx+1; SetRect(editSize); }
BOOL CBitmapButton::AutoLoad( UINT nID, CWnd *pParent ) /*****************************************************/ { if( !SubclassDlgItem( nID, pParent ) ) { return( FALSE ); } CString strText; GetWindowText( strText ); ASSERT( strText.GetLength() > 0 ); if( !LoadBitmaps( strText + _T("U"), strText + _T("D"), strText + _T("F"), strText + _T("X") ) ) { return( FALSE ); } SizeToContent(); return( TRUE ); }
// Autoload will load the bitmap resources based on the text of // the button // Using suffices "U", "D", "F" and "X" for up/down/focus/disabled BOOL CBitmapButton::AutoLoad(UINT nID, CWnd* pParent) { // first attach the CBitmapButton to the dialog control if (!SubclassDlgItem(nID, pParent)) return FALSE; CString buttonName; GetWindowText(buttonName); ASSERT(!buttonName.IsEmpty()); // must provide a title LoadBitmaps(buttonName + _T("U"), buttonName + _T("D"), buttonName + _T("F"), buttonName + _T("X")); // we need at least the primary if (m_bitmap.m_hObject == NULL) return FALSE; // size to content SizeToContent(); return TRUE; }
void CMlsBitmapButton::Initialize(UINT nID, CWnd* pParent) { CString csText; // CString csBitmap; int nBitmapID; CString csStyle; CDC* pDC = NULL; CDC dcBitmap; CBitmap* pOldBitmap = NULL; CRect crBitmap; CDC dcMask; CBitmap* pOldMask = NULL; CRect crMask; TRY { // Subclass the dialog item. if (SubclassDlgItem(nID, pParent)) { // Get the control's text and extract the properties. GetWindowText(csText); m_Properties.ExtractProperties(csText); SetWindowText(csText); #if 0 //- the old way: m_Properties.AsString(0, csBitmap); if (!csBitmap.IsEmpty()) { m_bmBitmap.LoadBitmap(csBitmap); #endif // Note: had to change the strategy for loading these bitmaps // because LoadBitmap() fails under Win95/98 with VC6 when // the resource file is bloated. For more info, see PROPSTR.CPP. // - jdf - 2/18/99 if( ! m_Properties.AsResourceIDFromString(0, &nBitmapID) ) { ASSERT( FALSE ); // this is a bit unkosher, but I put this in here to help // QA trap missing resources in the release build AfxMessageBox( "There is a missing bitmap resource for one of the buttons in this window.\n\nThis will not hinder behavior of the program.\n\nPlease report this to Mindscape programmers." ); } else { m_bmBitmap.LoadBitmap( MAKEINTRESOURCE(nBitmapID) ); // Extract some information about the bitmap. BITMAP Bitmap; if (m_bmBitmap.GetObject(sizeof(Bitmap), &Bitmap) != 0) { crBitmap.SetRect(0, 0, Bitmap.bmWidth, Bitmap.bmHeight); m_nBitmapWidth = crBitmap.Width(); m_nBitmapHeight = crBitmap.Height(); // Get the DC for this control. pDC = GetDC(); // Get the transparent color indicated by the pixel at (0,Height-1). dcBitmap.CreateCompatibleDC(pDC); pOldBitmap = dcBitmap.SelectObject(&m_bmBitmap); COLORREF clTransparent = dcBitmap.GetPixel(0, m_nBitmapHeight-1); // Create the mask bitmap with 1's (white) for pixels that match the // transparent color and 0's (black) for pixels that are not transparent. Util::CreateMask(dcMask, m_bmMask, crMask, dcBitmap, crBitmap, clTransparent, TRUE); if ((pOldMask = dcMask.SelectObject(&m_bmMask)) != NULL) { // Set all the transparent pixels in the bitmap to 0's (black). dcBitmap.SetTextColor(RGB(255,255,255)); // 0's in mask (opaque) go to 1's dcBitmap.SetBkColor(RGB(0,0,0)); // 1's in mask (transparent) go to 0's dcBitmap.BitBlt(0, 0, m_nBitmapWidth, m_nBitmapHeight, &dcMask, 0, 0, SRCAND); m_fHaveBitmap = TRUE; } } } // Unpack the button's style. m_Properties.AsString(1, csStyle, "", TRUE); UnpackAlignment(csStyle); } } END_TRY if (pDC != NULL) { ReleaseDC(pDC); pDC = NULL; } if (pOldBitmap != NULL) { dcBitmap.SelectObject(pOldBitmap); pOldBitmap = NULL; } if (pOldMask != NULL) { dcMask.SelectObject(pOldMask); pOldMask = NULL; } } void CMlsBitmapButton::UnpackAlignment(const CString& csStyle) { // Unpack the major alignment type (L, R, T, or B). if (csStyle.Find('L') != -1) m_Alignment = Left; else if (csStyle.Find('R') != -1) m_Alignment = Right; else if (csStyle.Find('T') != -1) m_Alignment = Top; else if (csStyle.Find('B') != -1) m_Alignment = Bottom; else m_Alignment = Left; // Unpack the alignment variation (0, 1, 2, or 3). if (csStyle.Find('0') != -1) m_nVariation = 0; else if (csStyle.Find('1') != -1) m_nVariation = 1; else if (csStyle.Find('2') != -1) m_nVariation = 2; else if (csStyle.Find('3') != -1) m_nVariation = 3; else m_nVariation = 3; // Unpack the multiple line flag. if (csStyle.Find('S') != -1) m_fMultipleLine = FALSE; else if (csStyle.Find('M') != -1) m_fMultipleLine = TRUE; else m_fMultipleLine = FALSE; // Unpack the word wrap flag. if (csStyle.Find('N') != -1) m_fWordWrap = FALSE; else if (csStyle.Find('W') != -1) m_fWordWrap = TRUE; else m_fWordWrap = FALSE; } ///////////////////////////////////////////////////////////////////////////// // CMlsBitmapButton message handlers // Owner draw buttons can be double clicked. We turn this into a single click since // we want to simulate the behavior of a regular button. void CMlsBitmapButton::OnLButtonDblClk(UINT nFlags, CPoint point) { SendMessage(WM_LBUTTONDOWN, (WPARAM)nFlags, (LPARAM)(*((DWORD*)(&point)))); }
BOOL CColorWnd::SubclassStatic(UINT nID, CWnd * pParent) { return SubclassDlgItem(nID, pParent); }
void CButtonCtrl::Set(CWnd* pParent, int nIDEdit) { VERIFY(SubclassDlgItem(nIDEdit, pParent)); }
BOOL CuParseEditCtrl::SubclassEdit(UINT nID, CWnd* pParent, WORD wParseStyle) { m_wParseStyle = wParseStyle; return SubclassDlgItem(nID, pParent); }