Click here to Skip to main content
15,917,059 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ BG Color Pin
Nish Nishant5-Apr-03 12:59
sitebuilderNish Nishant5-Apr-03 12:59 
GeneralRe: VC++ BG Color Pin
Michael Dunn5-Apr-03 15:47
sitebuilderMichael Dunn5-Apr-03 15:47 
GeneralRe: VC++ BG Color Pin
Makover6-Apr-03 0:02
Makover6-Apr-03 0:02 
GeneralRe: VC++ BG Color Pin
yashraj6-Apr-03 0:44
yashraj6-Apr-03 0:44 
GeneralMenu shortcuts in a dialog based application Pin
Mahesh Varma5-Apr-03 5:30
Mahesh Varma5-Apr-03 5:30 
GeneralRe: Menu shortcuts in a dialog based application Pin
Nish Nishant5-Apr-03 9:21
sitebuilderNish Nishant5-Apr-03 9:21 
GeneralRe: Menu shortcuts in a dialog based application Pin
Mahesh Varma5-Apr-03 16:52
Mahesh Varma5-Apr-03 16:52 
GeneralTrue colour icon in sys tray Pin
Rohit  Sinha5-Apr-03 3:46
Rohit  Sinha5-Apr-03 3:46 
Yeah. The subject says it. How to display a true colour icon in the sys tray? It seems my icons change magically to 16 colour when in the sys tray. It's driving me mad. I've been at it for the whole afternoon now without success.

Here's what I'm doing.

C++
void CMyClass::ShowTrayIcon()
{
	if(m_bTrayIconCreated == FALSE)
	{
		if(m_IconList.m_hImageList == NULL)
			LoadSysTrayIcons();
		ZeroMemory(&m_SystemTray, sizeof(m_SystemTray));
		m_SystemTray.cbSize = sizeof(NOTIFYICONDATA);
		m_SystemTray.hWnd   = GetSafeHwnd();
		m_SystemTray.uID    = 1;
		m_SystemTray.hIcon  = m_IconList.ExtractIcon(0);
		m_SystemTray.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
		m_SystemTray.uCallbackMessage = TaskbarCallbackMsg;
		_tcscpy(m_SystemTray.szTip, SZ_APPNAME);

		m_bTrayIconCreated = Shell_NotifyIcon(NIM_ADD, &m_SystemTray);
	}
}

BOOL CMyClass::LoadSysTrayIcons()
{
	CBitmap		cBitmap;
	BITMAP		bmBitmap;
	CSize		cSize;
	int		nNoIcon;
	
	if(!cBitmap.Attach(LoadImage(AfxGetInstanceHandle(),
MAKEINTRESOURCE(IDB_BMP_SYSTRAYICON), IMAGE_BITMAP, 0, 0,
LR_DEFAULTSIZE | LR_CREATEDIBSECTION)) ||
	   !cBitmap.GetBitmap(&bmBitmap))
	{
		return FALSE;
	}

	cSize  = CSize(bmBitmap.bmWidth, bmBitmap.bmHeight);
	nNoIcon = cSize.cx / 16;
	RGBTRIPLE* rgb		= (RGBTRIPLE*)(bmBitmap.bmBits);
	COLORREF   rgbMask	= RGB(255, 255, 255);/*RGB(rgb[0].rgbtRed,
		                      rgb[0].rgbtGreen, rgb[0].rgbtBlue);*/
	
	if(!m_IconList.Create(16, 16, ILC_COLOR24 | ILC_MASK, nNoIcon, 0))
	{
		return FALSE;
	}
	
	if(m_IconList.Add(&cBitmap, rgbMask) == -1)
		return FALSE;

	cBitmap.Detach();

	return TRUE;
}


You might have noticed that I commented out the mask colour in the LoadSysTrayIcons() function in the line COLORREF rgbMask = RGB(255, 255, 255);/*RGB(rgb[0].rgbtRed, rgb[0].rgbtGreen, rgb[0].rgbtBlue);*/ with the actual RGB value. This was because the correct colour was not being obtained in the rgbMask. Is it the cause of the problem, ie that the function is not somehow reading the bitmap data properly? What am I doing wrong? Or am I taking an entirely wrong approach? I tried loading icons instead of a bitmap into the imagelist, but that failed to load the true colour icons too. I'd really like to have the icons in an imagelist, but whatever works will be fine with me. As long as the icon is true colour.

Please help. Thanks. Smile | :)


Regards,

Rohit Sinha



GeneralRe: True colour icon in sys tray Pin
Jörgen Sigvardsson5-Apr-03 4:39
Jörgen Sigvardsson5-Apr-03 4:39 
GeneralRe: True colour icon in sys tray Pin
Rohit  Sinha5-Apr-03 4:52
Rohit  Sinha5-Apr-03 4:52 
GeneralRe: True colour icon in sys tray Pin
Rohit  Sinha5-Apr-03 5:23
Rohit  Sinha5-Apr-03 5:23 
GeneralRe: True colour icon in sys tray Pin
Jörgen Sigvardsson5-Apr-03 6:13
Jörgen Sigvardsson5-Apr-03 6:13 
GeneralRe: True colour icon in sys tray Pin
Nish Nishant5-Apr-03 9:28
sitebuilderNish Nishant5-Apr-03 9:28 
GeneralRe: True colour icon in sys tray Pin
Rohit  Sinha5-Apr-03 14:20
Rohit  Sinha5-Apr-03 14:20 
GeneralRe: True colour icon in sys tray Pin
Nish Nishant5-Apr-03 14:27
sitebuilderNish Nishant5-Apr-03 14:27 
GeneralRe: True colour icon in sys tray Pin
Rohit  Sinha5-Apr-03 16:53
Rohit  Sinha5-Apr-03 16:53 
GeneralRe-post - Intercepting Window Updates in DX Game Pin
#realJSOP5-Apr-03 1:20
professional#realJSOP5-Apr-03 1:20 
GeneralRe: Re-post - Intercepting Window Updates in DX Game Pin
Stephane Rodriguez.5-Apr-03 2:05
Stephane Rodriguez.5-Apr-03 2:05 
GeneralRe: Re-post - Intercepting Window Updates in DX Game Pin
Christian Graus6-Apr-03 1:26
protectorChristian Graus6-Apr-03 1:26 
GeneralQuestion about WSAStartup. Pin
George25-Apr-03 0:11
George25-Apr-03 0:11 
GeneralRe: Question about WSAStartup. Pin
Nish Nishant5-Apr-03 9:34
sitebuilderNish Nishant5-Apr-03 9:34 
GeneralRe: Question about WSAStartup. Pin
George25-Apr-03 17:57
George25-Apr-03 17:57 
GeneralA neat Trick to do on VC++6 Pin
Ernesto D.4-Apr-03 23:34
Ernesto D.4-Apr-03 23:34 
GeneralRe: A neat Trick to do on VC++6 Pin
Stephane Rodriguez.5-Apr-03 2:07
Stephane Rodriguez.5-Apr-03 2:07 
QuestionHow to save a bitmap Pin
gumber4-Apr-03 23:11
gumber4-Apr-03 23:11 

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.