Step 1 − Drag a group box and three radio buttons and remove the Caption of Static Text control. Let us look into an example of Radio button by creating a new MFC dialog based application. The framework calls this member function when an application makes a request to repaint a button. The framework calls this member function when button is double clicked. The framework calls this member function when button is disabled. The framework calls this member function when is button clicked. Here is the list of messages mapping for Radio Button control − Message Sets the text margin of the button control. Sets the highlighting state of a button control. Sets the bounding rectangle of the drop-down component of the current split button control. ![]() Specifies information that defines the current split button control. Sets the note on the current command link control.Īssociates a specified glyph with the current split button control.Īssociates an image list with the current split button control. Sets the image list of the button control. Specifies an icon to be displayed on the button. Sets the drop-down state of the current split button control. Specifies a cursor image to be displayed on the button. Sets the check state of a button control. ![]() Specifies a bitmap to be displayed on the button. Retrieves the text margin of the button control. Retrieves the check state, highlight state, and focus state of a button control. Retrieves the split button styles that define the current split button control. Retrieves the bounding rectangle of the drop-down component of the current split button control. Retrieves information that defines the current split button control. Retrieves the image list for the current split button control. Retrieves the glyph associated with the current split button control. Retrieves the length of the note text for the current command link control. Retrieves the note component of the current command link control. Retrieves the image list of the button control. Retrieves the ideal size of the button contro. Retrieves the handle of the icon previously set with SetIcon. Retrieves the handle of the cursor image previously set with SetCursor. Retrieves information about the button control style Retrieves the handle of the bitmap previously set with SetBitmap. Override to draw an owner-drawn CButton object. I'm sure you can adapt this to the main menu buttons (and the special way you want the application state have effect on the icons) without problems.Creates the Windows button control and attaches it to the CButton object. M_pBtnFilter->AddSubItem(apBtn.release()) ::GetDIBits(hDC, hBmp, 0, bm.bmHeight, pData, bmi, DIB_RGB_COLORS) įor (i = 0 i apBtn(new CMFCRibbonButtonEx(ID_FILTER_BASE + i, (LPCTSTR)m_csaNames, m_tbiIcons.ExtractIcon(m_nIcons, true, NULL, true, true)) LPBYTE pBitData = (LPBYTE) ::LocalAlloc(LPTR, bm.bmWidth * bm.bmHeight * sizeof(DWORD)) If( !bRes || bmi->bmiHeader.biBitCount != 32 ) return ::ZeroMemory(bmi, sizeof(BITMAPINFOHEADER) + (256 * sizeof(RGBQUAD))) īmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) īOOL bRes = ::GetDIBits(hDC, hBmp, 0, bm.bmHeight, NULL, bmi, DIB_RGB_COLORS) Void CMFCRibbonButtonEx::PremultiplyBitmapAlpha(HDC hDC, HBITMAP hBmp)īITMAPINFO* bmi = (BITMAPINFO*) _alloca(sizeof(BITMAPINFOHEADER) + (256 * sizeof(RGBQUAD))) SelectObject(dcMem.m_hDC, cbm.m_hObject) PremultiplyBitmapAlpha(dcMem.m_hDC, cbm) Void CMFCRibbonButtonEx::DrawCheckmark(CDC* pDC, int CheckmarkResourceBitmapID, RECT *r)Ĭbm.LoadBitmap(CheckmarkResourceBitmapID) If (type = RibbonImageLarge & m_bChecked)ĭrawCheckmark(pDC, IDB_BIG_ICON_CHECKMARK, &rectImage) Void CMFCRibbonButtonEx::DrawImage(CDC* pDC, RibbonImageType type, CRect rectImage)ĬMFCRibbonButton::DrawImage(pDC, type, rectImage) Void CMFCRibbonButtonEx::SetCheck(BOOL bCheck) Implementation: CMFCRibbonButtonEx::CMFCRibbonButtonEx() : CMFCRibbonButton() ![]() Void PremultiplyBitmapAlpha(HDC hDC, HBITMAP hBmp) Void DrawCheckmark(CDC* pDC, int CheckmarkResourceBitmapID, RECT *r) Void DrawImage(CDC* pDC, RibbonImageType type, CRect rectImage) Header: class CMFCRibbonButtonEx : public CMFCRibbonButtonĬMFCRibbonButtonEx(UINT nID, LPCTSTR lpszText, int nSmallImageIndex = -1, int nLargeImageIndex = -1, BOOL bAlwaysShowDescription = FALSE) ĬMFCRibbonButtonEx(UINT nID, LPCTSTR lpszText, HICON hIcon, BOOL bAlwaysShowDescription = FALSE, HICON hIconSmall = NULL, BOOL bAutoDestroyIcon = FALSE, BOOL bAlphaBlendIcon = FALSE) In this special case I wanted to alpha-blend a green checkmark over the original icon: ![]() I derived a class CMFCRibbonButtonEx from CMFCRibbonButton to control how the icon is being drawn.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |