void
HTMLOptGroupElement::RemoveChildAt(uint32_t aIndex, bool aNotify)
{
  SafeOptionListMutation safeMutation(GetSelect(), this, nullptr, aIndex,
                                      aNotify);
  nsGenericHTMLElement::RemoveChildAt(aIndex, aNotify);
}
void CWndFriendCtrl::OnLButtonDblClk( UINT nFlags, CPoint point )
{
	u_long idFriend;
	Friend* pFriend;
	int nSelect		= GetSelect( point, idFriend, &pFriend );
	if( nSelect != -1 )
	{
		CPlayerDataCenter* pPlayerDataCenter	= CPlayerDataCenter::GetInstance();
#ifdef __RT_1025
		if( pFriend->dwState != FRS_OFFLINE && !pFriend->bBlock )
#else	// __RT_1025
		if( pFriend->dwState != FRS_OFFLINE && pFriend->dwState != FRS_BLOCK && pFriend->dwState != FRS_OFFLINEBLOCK )
#endif	// __RT_1025
		{
			m_nCurSelect	= nSelect;
			CWndMessage* pWndMessage	= g_WndMng.OpenMessage( pPlayerDataCenter->GetPlayerString( idFriend ) );
		}
		else
		{
			CString szMessage;
			if( pFriend->dwState == FRS_OFFLINE )
				szMessage	= prj.GetText(TID_GAME_NOTLOGIN);	//szMessage += "님은 접속되어 있지 않습니다";
			else
				szMessage.Format( prj.GetText( TID_GAME_MSGBLOCKCHR ), pPlayerDataCenter->GetPlayerString( idFriend ) );  //szMessage += "님은 차단되어 있어 메세지를 보낼수 없습니다";
			g_WndMng.PutString( szMessage, NULL, prj.GetTextColor(TID_GAME_NOTLOGIN) );
		}
	}	
}
//{{AFX
void CWndFriendCtrl::OnLButtonDblClk( UINT nFlags, CPoint point )
{
	LPFRIEND lpFriend = NULL;
	int nSelect = GetSelect( point, &lpFriend );
	if( nSelect != -1 )
	{
#ifdef __SYS_PLAYER_DATA
		CPlayerDataCenter* pPlayerDataCenter	= CPlayerDataCenter::GetInstance();
#endif	// __SYS_PLAYER_DATA
		if( lpFriend->dwState != FRS_OFFLINE && lpFriend->dwState != FRS_BLOCK && lpFriend->dwState != FRS_OFFLINEBLOCK )
		{
			m_nCurSelect = nSelect;
#ifdef __SYS_PLAYER_DATA
			CWndMessage* pWndMessage	= g_WndMng.OpenMessage( pPlayerDataCenter->GetPlayerString( lpFriend->dwUserId ) );
#else	// __SYS_PLAYER_DATA
			CWndMessage* pWndMessage = g_WndMng.OpenMessage( lpFriend->szName );
#endif	// __SYS_PLAYER_DATA
		}
		else
		{
			CString szMessage;
			if( lpFriend->dwState == FRS_OFFLINE )
				szMessage = prj.GetText(TID_GAME_NOTLOGIN);                               //szMessage += "님은 접속되어 있지 않습니다";
			else
#ifdef __SYS_PLAYER_DATA
				szMessage.Format( prj.GetText( TID_GAME_MSGBLOCKCHR ), pPlayerDataCenter->GetPlayerString( lpFriend->dwUserId ) );  //szMessage += "님은 차단되어 있어 메세지를 보낼수 없습니다";
#else	// __SYS_PLAYER_DATA
				szMessage.Format( prj.GetText(TID_GAME_MSGBLOCKCHR), lpFriend->szName );  //szMessage += "님은 차단되어 있어 메세지를 보낼수 없습니다";
#endif	// __SYS_PLAYER_DATA
			g_WndMng.PutString( szMessage, NULL, prj.GetTextColor(TID_GAME_NOTLOGIN) );
			
		}
	}	
}
Example #4
0
void CDoubleSidedPrintButton::PaintCustomize(CDC& dcButton, CRect crButton)
{
	if (m_fChecked)
	{
		crButton.InflateRect(-4, -4);
		if (GetSelect())
		{
			crButton.OffsetRect(1, 1);
		}
		Util::DrawBorderWithColor(dcButton, crButton, ::GetSysColor(COLOR_HIGHLIGHT), 2);
	}
}
Example #5
0
BOOL SourceEdit::PreTranslateMessage(MSG* pMsg)
{
  if ((m_markSel.cpMin >= 0) && (pMsg->hwnd == GetSafeHwnd()))
  {
    CHARRANGE sel = GetSelect();
    if ((m_markSel.cpMin != sel.cpMin) || (m_markSel.cpMax != sel.cpMax))
    {
      m_markSel.cpMin = -1;
      m_markSel.cpMax = -1;
      CallEdit(SCI_MARKERDELETEALL,m_marker);
    }
  }
  return CWnd::PreTranslateMessage(pMsg);
}
NS_IMETHODIMP
HTMLOptionElement::SetSelected(bool aValue)
{
  // Note: The select content obj maintains all the PresState
  // so defer to it to get the answer
  HTMLSelectElement* selectInt = GetSelect();
  if (selectInt) {
    int32_t index = Index();
    // This should end up calling SetSelectedInternal
    selectInt->SetOptionsSelectedByIndex(index, index, aValue,
                                         false, true, true);
  } else {
    SetSelectedInternal(aValue, true);
  }

  return NS_OK;
}
nsresult
HTMLOptionElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
                                 const nsAttrValueOrString* aValue,
                                 bool aNotify)
{
  nsresult rv = nsGenericHTMLElement::BeforeSetAttr(aNamespaceID, aName,
                                                    aValue, aNotify);
  NS_ENSURE_SUCCESS(rv, rv);

  if (aNamespaceID != kNameSpaceID_None || aName != nsGkAtoms::selected ||
      mSelectedChanged) {
    return NS_OK;
  }

  // We just changed out selected state (since we look at the "selected"
  // attribute when mSelectedChanged is false).  Let's tell our select about
  // it.
  HTMLSelectElement* selectInt = GetSelect();
  if (!selectInt) {
    return NS_OK;
  }

  // Note that at this point mSelectedChanged is false and as long as that's
  // true it doesn't matter what value mIsSelected has.
  NS_ASSERTION(!mSelectedChanged, "Shouldn't be here");

  bool newSelected = (aValue != nullptr);
  bool inSetDefaultSelected = mIsInSetDefaultSelected;
  mIsInSetDefaultSelected = true;

  int32_t index = Index();
  // This should end up calling SetSelectedInternal, which we will allow to
  // take effect so that parts of SetOptionsSelectedByIndex that might depend
  // on it working don't get confused.
  selectInt->SetOptionsSelectedByIndex(index, index, newSelected,
                                       false, true, aNotify);

  // Now reset our members; when we finish the attr set we'll end up with the
  // rigt selected state.
  mIsInSetDefaultSelected = inSetDefaultSelected;
  mSelectedChanged = false;
  // mIsSelected doesn't matter while mSelectedChanged is false

  return NS_OK;
}
Example #8
0
nsresult
HTMLOptionElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName,
                                const nsAttrValue* aValue, bool aNotify)
{
  if (aNameSpaceID == kNameSpaceID_None &&
      aName == nsGkAtoms::value && Selected()) {
    // Since this option is selected, changing value
    // may have changed missing validity state of the
    // Select element
    HTMLSelectElement* select = GetSelect();
    if (select) {
      select->UpdateValueMissingValidityState();
    }
  }

  return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName,
                                            aValue, aNotify);
}
Example #9
0
int32_t
HTMLOptionElement::Index()
{
  static int32_t defaultIndex = 0;

  // Only select elements can contain a list of options.
  HTMLSelectElement* selectElement = GetSelect();
  if (!selectElement) {
    return defaultIndex;
  }

  HTMLOptionsCollection* options = selectElement->GetOptions();
  if (!options) {
    return defaultIndex;
  }

  int32_t index = defaultIndex;
  MOZ_ALWAYS_SUCCEEDS(options->GetOptionIndex(this, 0, true, &index));
  return index;
}
Example #10
0
/**
 *
 *  Query SecureBoot value at System\\CurrentControlSet\\Control\\Lsa
 *
 *  SystemKey levels were verified with XP Professional
 *
 *    0 - Not enabled
 *    1 - Random key generated by OS,  stored in registry,  default on all OS since windows 2000
 *    2 - Derived from password chosen by administrator,  stored in administrators brain ;-)
 *    3 - Random key generated by OS,  stored on floppy disk
 *
 */
DWORD SystemKey::AuthType (VOID) {
  DWORD dwSize = sizeof (DWORD);
  HKEY hSubKey;

  GetSelect();

  std::wstring path = regFile + L"\\ControlSet"
      + format<std::wstring, int>(dwSelect, 3) + L"\\Control\\Lsa";

  dwError = RegOpenKeyEx (HKEY_LOCAL_MACHINE, path.c_str(), 0, KEY_QUERY_VALUE, &hSubKey);

  if (dwError == ERROR_SUCCESS) {
    dwError = RegQueryValueEx (hSubKey, L"SecureBoot", NULL, NULL,
        reinterpret_cast<BYTE*>(&dwKeyType), &dwSize);
    RegCloseKey (hSubKey);
  } else {
    wprintf (L"\nRegOpenKeyEx(%s) failed with %i", path.c_str(), dwError);
  }
  return dwKeyType;
}
Example #11
0
/* 範囲選択開始 */
void CViewCommander::Command_BEGIN_SELECT( void )
{
	if( !m_pCommanderView->GetSelectionInfo().IsTextSelected() ){	/* テキストが選択されているか */
		/* 現在のカーソル位置から選択を開始する */
		m_pCommanderView->GetSelectionInfo().BeginSelectArea();
	}

	//	ロックの解除切り替え
	if ( m_pCommanderView->GetSelectionInfo().m_bSelectingLock ) {
		m_pCommanderView->GetSelectionInfo().m_bSelectingLock = false;	/* 選択状態のロック解除 */
	}
	else {
		m_pCommanderView->GetSelectionInfo().m_bSelectingLock = true;	/* 選択状態のロック */
	}
	if( GetSelect().IsOne() ){
		GetCaret().m_cUnderLine.CaretUnderLineOFF(true);
	}
	m_pCommanderView->GetSelectionInfo().PrintSelectionInfoMsg();
	return;
}
Example #12
0
NS_IMETHODIMP
HTMLOptionElement::SetSelected(bool aValue)
{
  // Note: The select content obj maintains all the PresState
  // so defer to it to get the answer
  HTMLSelectElement* selectInt = GetSelect();
  if (selectInt) {
    int32_t index = Index();
    uint32_t mask = HTMLSelectElement::SET_DISABLED | HTMLSelectElement::NOTIFY;
    if (aValue) {
      mask |= HTMLSelectElement::IS_SELECTED;
    }

    // This should end up calling SetSelectedInternal
    selectInt->SetOptionsSelectedByIndex(index, index, mask);
  } else {
    SetSelectedInternal(aValue, true);
  }

  return NS_OK;
}
Example #13
0
VOID CDUIIconTextItem::PaintText(HDC dc)
{
	if(m_pParentControl == NULL)
	{
		DUI_ASSERT(FALSE);
		return;
	}

	CRefPtr<CTextStyle> pTextStyle = m_pParentControl->GetTextStyle();
	if(pTextStyle.IsNull()) return;

	CRefPtr<CFontObject> pFont = pTextStyle->GetFont();
	if(pFont.IsNull() || pFont->IsNull()) return;
	HFONT hFont = pFont->GetFont();
	
	if(m_strText.size() > 0)
	{
		RECT rtText = GetTextRect();
		SelectObject(dc, hFont);
		SetBkMode(dc, TRANSPARENT);

		if(GetSelect())
		{
			SetTextColor(dc, pTextStyle->GetSelectColor().GetColor());
		}
		else if(GetStatus() & CONTROL_STATUS_HOVER)
		{
			SetTextColor(dc, pTextStyle->GetHoverColor().GetColor());
		}
		else
		{
			SetTextColor(dc, pTextStyle->GetNormalColor().GetColor());
		}

		CDUIRenderEngine::DrawText(dc, m_strText.c_str()
			, m_strText.size(), &rtText, pTextStyle->GetTextFormat());
	}
}
void CWndFriendCtrl::OnRButtonUp( UINT nFlags, CPoint point )
{
	u_long idPlayer;
#ifdef __RT_1025
	Friend* pFriend;
	int nSelect		= GetSelect( point, idPlayer, &pFriend );
#else	// __RT_1025
	LPFRIEND lpFriend = NULL;
	int nSelect		= GetSelect( point, &lpFriend );
#endif	// __RT_1025
	if( nSelect != -1 )
	{
#ifdef __RT_1025
		idPlayer		= idPlayer;
		DWORD dwState	= pFriend->dwState;
#else	// __RT_1025
		idPlayer		= lpFriend->dwUserId;
		DWORD dwState	= lpFriend->dwState;
#endif	// __RT_1025
		m_nCurSelect	= nSelect;
		ClientToScreen( &point );
		m_menu.DeleteAllMenu();
#ifdef __RT_1025
		if( dwState != FRS_OFFLINE && !pFriend->bBlock )
#else	// __RT_1025
		if( dwState != FRS_OFFLINE && dwState != FRS_BLOCK && dwState != FRS_OFFLINEBLOCK )
#endif	// __RT_1025
			m_menu.AppendMenu( 0, 0 ,_T( prj.GetText( TID_APP_MESSAGE ) ) );
#ifdef __RT_1025
		if( pFriend->bBlock )
#else	// __RT_1025
		if( dwState == FRS_BLOCK || dwState == FRS_OFFLINEBLOCK )
#endif	// __RT_1025
			m_menu.AppendMenu( 0, 1 ,_T( prj.GetText( TID_FRS_BLOCKRESTORE ) ) );
		else
			m_menu.AppendMenu( 0, 1 ,_T( prj.GetText( TID_FRS_BLOCK ) ) );
		m_menu.AppendMenu( 0, 2 ,_T( prj.GetText( TID_FRS_DELETE ) ) );
#ifdef __RT_1025
		if( !pFriend->bBlock )
#else	// __RT_1025
		if( dwState != FRS_OFFLINE && dwState != FRS_OFFLINEBLOCK )
#endif	// __RT_1025
		{					
			if( g_pPlayer->IsAuthHigher( AUTH_GAMEMASTER ) )
				m_menu.AppendMenu( 0, 3 ,_T( prj.GetText( TID_FRS_MOVE2 ) ) );	
#ifndef __RT_1025
			if( dwState != FRS_BLOCK )
#endif	// __RT_1025
			{
				if( g_Party.IsMember( idPlayer ) == FALSE )
					m_menu.AppendMenu( 0, 4 ,_T( prj.GetText( TID_MMI_INVITE_PARTY ) ) );
			}
		}
#ifdef __RT_1025
		if( dwState == FRS_OFFLINE || pFriend->bBlock )
#else	// __RT_1025
		if( dwState == FRS_OFFLINE || dwState == FRS_BLOCK || dwState == FRS_OFFLINEBLOCK )
#endif	// __RT_1025
			m_menu.AppendMenu( 0, 6 , _T( prj.GetText( TID_GAME_TAGSEND ) ) );
		m_menu.Move( point );
		m_menu.SetVisible( TRUE );
		m_menu.SetFocus();
	}
}
Example #15
0
void CFX_ListCtrl::OnVK_UP(bool bShift, bool bCtrl) {
  OnVK(IsMultipleSel() ? GetCaret() - 1 : GetSelect() - 1, bShift, bCtrl);
}
Example #16
0
nsresult
HTMLOptionElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName,
                                 nsAttrValueOrString* aValue,
                                 bool aNotify)
{
  nsresult rv = nsGenericHTMLElement::BeforeSetAttr(aNamespaceID, aName,
                                                    aValue, aNotify);
  NS_ENSURE_SUCCESS(rv, rv);

  if (aNamespaceID != kNameSpaceID_None || aName != nsGkAtoms::selected ||
      mSelectedChanged) {
    return NS_OK;
  }

  bool defaultSelected = aValue;
  // First make sure we actually set our mIsSelected state to reflect our new
  // defaultSelected state.  If that turns out to be wrong,
  // SetOptionsSelectedByIndex will fix it up.  But otherwise we can end up in a
  // situation where mIsSelected is still false, but mSelectedChanged becomes
  // true (later in this method, when we compare mIsSelected to
  // defaultSelected), and then we start returning false for Selected() even
  // though we're actually selected.
  mIsSelected = defaultSelected;

  // We just changed out selected state (since we look at the "selected"
  // attribute when mSelectedChanged is false).  Let's tell our select about
  // it.
  HTMLSelectElement* selectInt = GetSelect();
  if (!selectInt) {
    return NS_OK;
  }

  NS_ASSERTION(!mSelectedChanged, "Shouldn't be here");

  bool inSetDefaultSelected = mIsInSetDefaultSelected;
  mIsInSetDefaultSelected = true;

  int32_t index = Index();
  uint32_t mask = HTMLSelectElement::SET_DISABLED;
  if (defaultSelected) {
    mask |= HTMLSelectElement::IS_SELECTED;
  }

  if (aNotify) {
    mask |= HTMLSelectElement::NOTIFY;
  }

  // This can end up calling SetSelectedInternal if our selected state needs to
  // change, which we will allow to take effect so that parts of
  // SetOptionsSelectedByIndex that might depend on it working don't get
  // confused.
  selectInt->SetOptionsSelectedByIndex(index, index, mask);

  // Now reset our members; when we finish the attr set we'll end up with the
  // rigt selected state.
  mIsInSetDefaultSelected = inSetDefaultSelected;
  // mIsSelected might have been changed by SetOptionsSelectedByIndex.  Possibly
  // more than once; make sure our mSelectedChanged state is set correctly.
  mSelectedChanged = mIsSelected != defaultSelected;

  return NS_OK;
}
Example #17
0
void CFX_ListCtrl::OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl)
{
	OnVK(IsMultipleSel() ? GetCaret()+1 : GetSelect()+1, bShift, bCtrl);
}
Example #18
0
void CMlsSimpleBitmapButton::DrawButton(CDC* pDC)
{
	// Upack the state of the button.
	BOOL fSelected = GetSelect();
	BOOL fFocused = FALSE;
	BOOL fDisabled = !IsWindowEnabled();
	BOOL fDefault = FALSE;

	// Create a bitmap which will be used to draw the button image.
	// When the bitmap is complete, it will be drawn onto the button.
	CRect crButton;
	GetClientRect(crButton);

	CBitmap bmButton;
	bmButton.CreateCompatibleBitmap(pDC, crButton.Width(), crButton.Height());

	CDC dcButton;
	dcButton.CreateCompatibleDC(pDC);

	dcButton.SelectObject(&bmButton);

	// Initialize the button bitmap to the button face color.
	Util::FillRectangleWithColor(dcButton, crButton, GetSysColor(COLOR_BTNFACE));

	// Compute the area available for content.
	CRect crContent(crButton);
	crContent.InflateRect(-MinimumMargin, -MinimumMargin);
	CRect crTextContent(crContent);

	// Compute the bitmap dimensions and its nominal position. Adjust crTextContent to the
	// area which is available next to the bitmap.
	CRect crBitmap;
	crBitmap.SetRectEmpty();

	if (!crContent.IsRectEmpty())
	{
		if (m_fHaveBitmap)
		{
			crBitmap.SetRect(0, 0, m_nBitmapWidth, m_nBitmapHeight);

			// Set first bitmap position base on major alignment type.
			switch (m_Alignment)
			{
				case Left:
				{
					crBitmap.OffsetRect(crContent.left, crContent.top+(crContent.Height()-crBitmap.Height())/2);
					crTextContent.left += crBitmap.Width()+Separator;
					break;
				}
				case Right:
				{
					crBitmap.OffsetRect(crContent.right-crBitmap.Width(), crContent.top+(crContent.Height()-crBitmap.Height())/2);
					crTextContent.right -= crBitmap.Width()+Separator;
					break;
				}
				case Top:
				{
					crBitmap.OffsetRect(crContent.left+(crContent.Width()-crBitmap.Width())/2, crContent.top);
					crTextContent.top += crBitmap.Height()+Separator;
					break;
				}
				case Bottom:
				{
					crBitmap.OffsetRect(crContent.left+(crContent.Width()-crBitmap.Width())/2, crContent.bottom-crBitmap.Height());
					crTextContent.bottom -= crBitmap.Height()+Separator;
					break;
				}
				default:
				{
					ASSERT(FALSE);
				}
			}
		}
		else
		{
			crBitmap.SetRectEmpty();
		}
	}

	// Compute the text dimensions and its nominal position.
	CRect crText;
	crText.SetRectEmpty();
	CString csText;

	if (!crTextContent.IsRectEmpty())
	{
		GetWindowText(csText);
		if (!csText.IsEmpty())
		{
			// Get the font which we are using for the text.
			CFont* pFont = GetFont();
			if (pFont != NULL)
			{
				// Select the font we are going to use for drawing the text.
				dcButton.SelectObject(pFont);

				// Compute the extent of the text. The text is formatted into the area next to
				// the button. If the text is multiple line, the full width is always used.
				crText.SetRect(0, 0, crTextContent.Width(), crTextContent.Height());
				int nTextHeight = Util::DrawText(&dcButton, csText, crText, DT_CALCRECT | (m_fMultipleLine ? (m_fWordWrap ? DT_WORDBREAK : 0) : DT_SINGLELINE));

				// Build the rectangle that has the dimensions of the text.
				crText.bottom = nTextHeight;

				// Clip to content dimensions.
				if (crText.Width() > crTextContent.Width())
				{
					crText.right = crTextContent.Width();
				}
				if (crText.Height() > crTextContent.Height())
				{
					crText.bottom = crTextContent.Height();
				}

				// Adjust text rectangle within content rectangle.
				int nXOffset = 0;
				int nYOffset = 0;

				switch (m_Alignment)
				{
					case Left:
					case Right:
					{
						switch (m_nVariation)
						{
							case 0: nXOffset = 0;                                        break;
							case 1: nXOffset = (crTextContent.Width()-crText.Width())/2; break;
							case 2: nXOffset = (crTextContent.Width()-crText.Width());   break;
							case 3: nXOffset = 0;                                        break;
						}
						if (m_Alignment == Right)
						{
							nXOffset = (crTextContent.Width()-crText.Width())-nXOffset;
						}
						nYOffset = (crTextContent.Height()-crText.Height())/2;
						break;
					}
					case Top:
					case Bottom:
					{
						switch (m_nVariation)
						{
							case 0: nYOffset = 0;                                          break;
							case 1: nYOffset = (crTextContent.Height()-crText.Height())/2; break;
							case 2: nYOffset = (crTextContent.Height()-crText.Height());   break;
							case 3: nYOffset = 0;                                          break;
						}
						if (m_Alignment == Bottom)
						{
							nYOffset = (crTextContent.Height()-crText.Height())-nYOffset;
						}
						nXOffset = (crTextContent.Width()-crText.Width())/2;
						break;
					}
					default:
					{
						ASSERT(FALSE);
					}
				}

				crText.OffsetRect(crTextContent.left+nXOffset, crTextContent.top+nYOffset);
			}
		}
	}

	// If the layout variation is 3, then center both the bitmap and text within the
	// content rectangle.
	if (!crContent.IsRectEmpty())
	{
		if (m_nVariation == 3)
		{
			// Compute the rectangle which encloses both the bitmap and text.
			CRect crBoth;
			crBoth.SetRectEmpty();
			if (!crBitmap.IsRectEmpty())
			{
				crBoth |= crBitmap;
			}
			if (!crText.IsRectEmpty())
			{
				crBoth |= crText;
			}

			// Move the bitmap and text back to the content rectangle.
			int nXOffset = 0;
			int nYOffset = 0;

			switch (m_Alignment)
			{
				case Left:
				case Right:
				{
					nXOffset = (crContent.Width()-crBoth.Width())/2;
					if (m_Alignment == Right)
					{
						nXOffset = -nXOffset;
					}
					break;
				}
				case Top:
				case Bottom:
				{
					nYOffset = (crContent.Height()-crBoth.Height())/2;
					if (m_Alignment == Bottom)
					{
						nYOffset = -nYOffset;
					}
					break;
				}
				default:
				{
					ASSERT(FALSE);
				}
			}

			// Adjust the bitmap and text rectangles.
			crBitmap.OffsetRect(nXOffset, nYOffset);
			crText.OffsetRect(nXOffset, nYOffset);
		}
	}

	// If the button is selected, offset the bitmap and text.
	if (fSelected)
	{
		crBitmap.OffsetRect(1, 1);
		crText.OffsetRect(1, 1);
	}

	// Draw the bitmap onto the button image at the computed position.
	if (!crBitmap.IsRectEmpty())
	{
		CDC dcBitmap;
		dcBitmap.CreateCompatibleDC(pDC);

		// Erase to 0's (black) the areas of the button where the opaque portions
		// of the bitmap will be drawn.
		dcButton.SetTextColor(RGB(0,0,0));
		dcButton.SetBkColor(RGB(255,255,255));
		dcBitmap.SelectObject(&m_bmMask);
		dcButton.BitBlt(crBitmap.left, crBitmap.top, crBitmap.Width(), crBitmap.Height(), &dcBitmap, 0, 0, SRCAND);

		// Draw the bitmap onto the button.
		dcBitmap.SelectObject(&m_bmBitmap);
		dcButton.BitBlt(crBitmap.left, crBitmap.top, crBitmap.Width(), crBitmap.Height(), &dcBitmap, 0, 0, SRCPAINT);
	}

	// Draw the text onto the button image at the computed position.
	if (!crText.IsRectEmpty())
	{
		// Draw the text.
		dcButton.SetTextColor(GetSysColor(COLOR_BTNTEXT));
		dcButton.SetBkMode(TRANSPARENT);
		Util::DrawText(&dcButton, csText, crText, (m_fMultipleLine ? (DT_CENTER | (m_fWordWrap ? DT_WORDBREAK : 0)) : DT_SINGLELINE));
	}

	// If the button is disabled, indicate this by embossing the bitmap.
	if (fDisabled)
	{
		Util::Emboss(dcButton, crButton, GetSysColor(COLOR_BTNFACE), GetSysColor(COLOR_BTNHILIGHT), GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNHILIGHT));
	}

	// Draw the button in its current state.
	if (fSelected)
	{
		// Button is selected, draw a black border with a shadow border inside.
		CRect crDraw(crButton);
		Util::DrawBorderWithColor(dcButton, crDraw, GetSysColor(COLOR_BTNTEXT), 1);
		crDraw.InflateRect(-1, -1);
		Util::DrawBorderWithColor(dcButton, crDraw, GetSysColor(COLOR_BTNSHADOW), 1);
	}
	else
	{
		CRect crDraw(crButton);

		// If the button is focused or the default button, draw a
		// black border around it. The rest of the image moves in
		// to make room.
		if (fFocused | fDefault)
		{
			Util::DrawBorderWithColor(dcButton, crDraw, GetSysColor(COLOR_BTNTEXT), 1);
			crDraw.InflateRect(-1, -1);
		}

		// Draw the raised 3D border:
		//
		//    W-----------WB
		//    |           D|
		//    |           ||
		//    |           ||
		//    WD----------D|
		//    B------------B


		CRect crSide;

		// W horizontal
		crSide.SetRect(crDraw.left, crDraw.top, crDraw.right-1, crDraw.top+1);
		Util::FillRectangleWithColor(dcButton, crSide, GetSysColor(COLOR_BTNHILIGHT));

		// W vertical
		crSide.SetRect(crDraw.left, crDraw.top+1, crDraw.left+1, crDraw.bottom-1);
		Util::FillRectangleWithColor(dcButton, crSide, GetSysColor(COLOR_BTNHILIGHT));

		// B horizontal
		crSide.SetRect(crDraw.left, crDraw.bottom-1, crDraw.right, crDraw.bottom);
		Util::FillRectangleWithColor(dcButton, crSide, GetSysColor(COLOR_BTNTEXT));

		// B vertical
		crSide.SetRect(crDraw.right-1, crDraw.top, crDraw.right, crDraw.bottom-1);
		Util::FillRectangleWithColor(dcButton, crSide, GetSysColor(COLOR_BTNTEXT));

		// D horizontal
		crSide.SetRect(crDraw.left+1, crDraw.bottom-2, crDraw.right-1, crDraw.bottom-1);
		Util::FillRectangleWithColor(dcButton, crSide, GetSysColor(COLOR_BTNSHADOW));

		// D vertical
		crSide.SetRect(crDraw.right-2, crDraw.top+1, crDraw.right-1, crDraw.bottom-2);
		Util::FillRectangleWithColor(dcButton, crSide, GetSysColor(COLOR_BTNSHADOW));
	}

	// If the button is focused, draw the focus rectangle.
	if (fFocused)
	{
		CRect crDraw(crButton);
		crDraw.InflateRect(-4, -4);
		dcButton.DrawFocusRect(crDraw);
	}

	// Copy the bitmap onto the button.
	pDC->BitBlt(crButton.left, crButton.top, crButton.Width(), crButton.Height(), &dcButton, 0, 0, SRCCOPY);

	dcButton.DeleteDC();
	bmButton.DeleteObject();
}