Click here to Skip to main content
16,006,348 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Hiding A Check Box Pin
[James Pullicino]7-Aug-01 2:30
[James Pullicino]7-Aug-01 2:30 
QuestionHow to know when a window is shown? Pin
7-Aug-01 1:19
suss7-Aug-01 1:19 
AnswerRe: How to know when a window is shown? Pin
Tomasz Sowinski7-Aug-01 1:58
Tomasz Sowinski7-Aug-01 1:58 
GeneralDisabled Images Pin
Derek Lakin6-Aug-01 23:58
Derek Lakin6-Aug-01 23:58 
GeneralRe: Disabled Images Pin
Tomasz Sowinski7-Aug-01 0:37
Tomasz Sowinski7-Aug-01 0:37 
GeneralCopy into a bitmap Pin
Derek Lakin7-Aug-01 3:31
Derek Lakin7-Aug-01 3:31 
GeneralRe: Copy into a bitmap Pin
Tomasz Sowinski7-Aug-01 3:43
Tomasz Sowinski7-Aug-01 3:43 
GeneralRe: Copy into a bitmap Pin
Derek Lakin7-Aug-01 8:58
Derek Lakin7-Aug-01 8:58 
Thanks for helping me out with this. The situation is this:

I am in the middle of doing an owner-drawn button that I want to allow bitmaps or icons to be added, which I can do by adding either to a CImageList. The problem so far is the disabled image. I have two functions which are illustrated below. The first is for adding the bitmap, which works for standard and disabled images and the second which works for the standard image but requires the addition of the disabled image. I apologise if the code is a bit spaghetti, but I am working towards having the ability if having multiple images set, but I'm not there yet Smile | :)
BOOL SSLButtonEx::SetButtonBitmap(UINT nResourceID, COLORREF crMask) {
	BOOL bReturn = m_bmpImage.LoadBitmap (nResourceID);
	if (TRUE == bReturn) {
		m_bmpImage.GetObject (sizeof m_bmp, &m_bmp);
		m_nImageWidth = m_bmp.bmWidth;
		m_nImageHeight = m_bmp.bmHeight;
		bReturn = m_imageList.Create (nResourceID, m_bmp.bmWidth, 1, crMask);
		if (TRUE == bReturn) {
			if (m_imageList.Add (&m_bmpImage, crMask) > -1) {
				m_bImageLoaded = TRUE;
			}
			else {
				m_bImageLoaded = FALSE;
			}
			m_crMask = crMask;

			HBITMAP bmpTemp;
			COLORMAP mapColour;
			mapColour.from = crMask;
			mapColour.to  = RGB(255,255,255);

			bmpTemp = (HBITMAP)::CreateMappedBitmap (AfxGetApp()->m_hInstance, 
				nResourceID, IMAGE_BITMAP, &mapColour, 1);
			m_hbmpDisabled = (HBITMAP)::CopyImage(bmpTemp, IMAGE_BITMAP, 
				m_nImageWidth, m_nImageHeight, LR_COPYDELETEORG);
		}
		else {
			m_bImageLoaded = FALSE;
		}
	}
	return bReturn;
}

BOOL SSLButtonEx::SetButtonIcon(UINT nResourceID, COLORREF crMask) {
	BOOL bReturn = FALSE;
	HINSTANCE hInstance = AfxFindResourceHandle (MAKEINTRESOURCE (nResourceID), RT_GROUP_ICON);

	m_hIcon = (HICON)::LoadImage (hInstance, MAKEINTRESOURCE (nResourceID), IMAGE_ICON, 0, 0, 0);
	if (NULL != m_hIcon) {
		m_crMask = crMask;
		ICONINFO iconInfo;
		ZeroMemory (&iconInfo, sizeof (ICONINFO));
		bReturn = ::GetIconInfo (m_hIcon, &iconInfo);
		if (TRUE == bReturn) {
			m_nImageWidth = iconInfo.xHotspot * 2;
			m_nImageHeight = iconInfo.yHotspot * 2;
			::DeleteObject(iconInfo.hbmMask);
			::DeleteObject(iconInfo.hbmColor);
			bReturn = m_imageList.Create (m_nImageWidth, m_nImageHeight, ILC_COLOR32 | ILC_MASK, 1, 1);
			if (TRUE == bReturn) {
				if (m_imageList.Add (m_hIcon) > -1) {
					m_bImageLoaded = TRUE;
				}
				else {
					m_bImageLoaded = FALSE;
				}
			}
		}
	}

	return bReturn;
}

GeneralRe: Copy into a bitmap Pin
Tomasz Sowinski7-Aug-01 9:23
Tomasz Sowinski7-Aug-01 9:23 
GeneralRe: Copy into a bitmap Pin
Derek Lakin8-Aug-01 2:08
Derek Lakin8-Aug-01 2:08 
GeneralRe: Copy into a bitmap Pin
Tomasz Sowinski8-Aug-01 2:25
Tomasz Sowinski8-Aug-01 2:25 
GeneralRe: Copy into a bitmap Pin
Derek Lakin9-Aug-01 1:29
Derek Lakin9-Aug-01 1:29 
Generalsql connect Pin
6-Aug-01 23:38
suss6-Aug-01 23:38 
GeneralRe: sql connect Pin
7-Aug-01 0:39
suss7-Aug-01 0:39 
GeneralUrgent - read MAC address ?!?!?!?! Pin
6-Aug-01 23:08
suss6-Aug-01 23:08 
GeneralRe: Urgent - read MAC address ?!?!?!?! Pin
Ryszard Krakowiak7-Aug-01 2:40
Ryszard Krakowiak7-Aug-01 2:40 
GeneralRe: Re: Urgent - read MAC address ?!?!?!?! Pin
7-Aug-01 6:24
suss7-Aug-01 6:24 
GeneralCustom attribute to the file Pin
vikram_barate6-Aug-01 23:00
vikram_barate6-Aug-01 23:00 
GeneralRe: Custom attribute to the file Pin
Tomasz Sowinski7-Aug-01 0:44
Tomasz Sowinski7-Aug-01 0:44 
GeneralResour editor Pin
NBee6-Aug-01 22:59
NBee6-Aug-01 22:59 
GeneralRe: Resour editor Pin
Derek Waters8-Aug-01 15:05
Derek Waters8-Aug-01 15:05 
GeneralCEdit and Enter Pin
Arjan Schouten6-Aug-01 22:59
Arjan Schouten6-Aug-01 22:59 
GeneralTimers Pin
6-Aug-01 22:51
suss6-Aug-01 22:51 
GeneralRe: Timers Pin
Tomasz Sowinski7-Aug-01 1:16
Tomasz Sowinski7-Aug-01 1:16 
Questionhow to make debug more accurate Pin
Gérald Mercet6-Aug-01 21:47
Gérald Mercet6-Aug-01 21:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.