|
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.
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);
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.
Regards,
Rohit Sinha
|
|
|
|
|
Have you checked the icon which comes from ExtractIcon(0) ?
When I look in the MFC source and the MSDN docs, it all boils down to the function ImageList_GetIcon . Maybe it's retarded in the way that it will only create 4-bit color icons?
Try adding your icon in your resources as a true color icon and then put that in the tray and see if it's any different.
--
Some of them wants to abuse you
Some of the wants to be abused by you
|
|
|
|
|
Jörgen Sigvardsson wrote:
Have you checked the icon which comes from ExtractIcon(0)?
OK I'll do that. I admit I didn't do it till now. :feeling_dumb:
Jörgen Sigvardsson wrote:
Try adding your icon in your resources as a true color icon and then put that in the tray and see if it's any different.
Yeah, I've tried that too. Didn't seem to work.
Regards,
Rohit Sinha
|
|
|
|
|
Jörgen Sigvardsson wrote:
Have you checked the icon which comes from ExtractIcon(0)?
I checked it now by displaying it inside a dialog box and the icon is indeed displayed in all its glory in true colour. Dunno why it's not so in the systray though.
Regards,
Rohit Sinha
|
|
|
|
|
Hmm. How odd! I wish I had any more ideas/suggestions, but I don't. Partly because I'm slightly intoxicated.
--
Some of them wants to abuse you
Some of the wants to be abused by you
|
|
|
|
|
Rohit
Prior to Windows XP, the task tray supports only 16 color icons because it used a 4bpp image list. Perhaps there is some technique to replace this image list. But anyway you now know why your icons dont show properly.
HTH
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Oooh, so that means I'm stuck with 16 colour icons.
Anyway Nish, thanks a lot for that bit of info. I can now stop trying and wasting my time. Thanks again.
Regards,
Rohit Sinha
|
|
|
|
|
Rohit Sinha wrote:
Oooh, so that means I'm stuck with 16 colour icons.
Rohit
It's only a 16x16 icon right? And I dont see why you cant make a decent enough icon with 16 colors considering we are talking about 256 pixels here Unless someone is using a 640x480 resolution on a 21" monitor the task tray icons are gonna be too small for anyone to notice any untidiness
Nish
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
Review by Shog9
Click here for review[NW]
|
|
|
|
|
Well, you are right of course. But the true colour icons are easier to make and look neater. Besides, the colour I wanted to have for my icons are not there in the 16 colour pallette. I'll now have to either use some other colours, or juggle with alternating red, yellow, and white to bring "my kinda orange" look, for example.
Regards,
Rohit Sinha
|
|
|
|
|
I have a game that allows you to display the frame rate in the upper right corner of the screen. I want to intercept the data being shown there so I can determine the minimum and maximum frame rate attained (it changes wildly depending on the current conditions of the game).
I tried using Spy++ to see if I might be able to get a window handle (while the game was running), but no joy.
Does anyone have an idea of how I might go about intercepting this data?
Oh yeah, it must work no matter which 3d engine the game is using - OpenGL or DirectX, and it would be nice if it would also work in both full-screen AND windowed mode.
I was hunting around in MSDN, and noticed that MS recommends writing screen updates (like what I want to intercept) to the "back buffer", and then using GDI calls to update the buffer. I mention this in hopes that it will spark some deeply buried double-super-secret knowledge that someone may have of the process.
Many thanks in advance.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Use one of the WIN32 API hook techniques (CodeProject articles), and hook ::TextOut().
|
|
|
|
|
Who the HELL voted this a '2' ? Man, I vote that we should be able to see the names of people who vote on our posts. This is just a joke.
Anyhow, yes, S.Rod has probably given the best advice. Any animation should be double buffered, so you have two images, one that is visible and one you are drawing on. If you hook the GDI calls to put text onto a bitmap, that is probably your best bet to catch this stuff.
Christian
NO MATTER HOW MUCH BIG IS THE WORD SIZE ,THE DATA MUCT BE TRANSPORTED INTO THE CPU. - Vinod Sharma
Anonymous wrote:
OK. I read a c++ book. Or...a bit of it anyway. I'm sick of that evil looking console window.
I think you are a good candidate for Visual Basic. - Nemanja Trifunovic
|
|
|
|
|
Hi, everyone!
In one C/C++ applcation, I think I just need to call WSAStartup once and
not every time when I want to open a socket connection. Before, I call
the function each time in a module of my application which needs network
socket communication. Am I correct?
Thanks in advance,
George
|
|
|
|
|
|
Thanks, Nish buddie!
George
|
|
|
|
|
Hi all, here´s a neat trick i discovered:
If you have Visual C++ 6 and windows XP, you can have VC use the Windows XP
visual styles!!! and i dont mean the apps you writte on it, i mean VC
itself!, this includes the VC dialog editor!, when you are designing a
dialog, you can have all the controls look like windows XP!
there are a few controls that (for some reason unknown to me) still appear
in W9x style, but buttons, list & combo boxes, and (like i said) all
controls you draw on dialog editor (including the dialog itself) look XP
like!
here´s what you do:
-copy the manifest lines below into a new text file (or use the one on MSDN
documentation)
-Rename the text file EXACTLY this: MSDev.exe.manifest
-Put the file on the same folder where the MSDev.exe (VC6 executable) file
is (typically Program Files\Microsoft Visual Studio\Common\MSDev98\Bin)
Thats it!
Note: you MUST put the manifest file on the same folder as the VC executable
or it will NOT work!
Enjoy!!
Here´s the manifest:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="x86"
name="MSDev"
type="win32"
/>
<description>
MSDev Application
</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="x86"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>
|
|
|
|
|
I believe it's worth an article on CodeProject, especially if you can list the limitations and special behaviors.
|
|
|
|
|
I've got an array containing the bitmap image.
How do I save it to make a .bmp file?
Gaurav Gumber
|
|
|
|
|
The term "array containing the bitmap image" is very unspecific.
-Does this bitmap array contains the pixel values only? Or contains the bitmap header as well?
-If it doesn't containg the header, so do you know the it's width and height and what color depth is used?
-Is the array bytes aligned to DWORD, i.e. padding zeros is added to the end of each horizontal scan to be divisible by 4?
Give me these details and I could help you.
|
|
|
|
|
How can I add an "OK" button, three "Text" lines and play an AVI in a window created by API as below in a Microsoft C 6.0 to be run in Win98?
DLLEXPORT int _stdcall Test(unsigned char * key)
{
const char g_szClassName[] = "myWindowClass";
RECT rcClient; // client area of parent window
int cyVScroll; // height of scroll bar arrow
HWND hwndParent; // handle of parent window
HWND hwndPB; // handle of progress bar
HWND hwndAVI; // handle of avi
int i;
WNDCLASSEX wc;
// Register the Window Class
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hInstance;
wc.hIcon = 0;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = 0;
if(!RegisterClassEx(&wc)) {
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
// Create the Window
hwndParent = CreateWindowEx(
WS_POPUPWINDOW,
g_szClassName,
"Encryption in Progess",
WS_OVERLAPPEDWINDOW & ~WS_MINIMIZEBOX & ~WS_MAXIMIZEBOX & ~WS_THICKFRAME,
GetSystemMetrics(SM_CXSCREEN)/3, GetSystemMetrics(SM_CYSCREEN)/3,
GetSystemMetrics(SM_CXSCREEN)/3, GetSystemMetrics(SM_CYSCREEN)/3,
NULL, NULL, g_hInstance, NULL);
if(hwndParent == NULL) {
MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwndParent, SW_SHOWNORMAL);
UpdateWindow(hwndParent);
GetClientRect(hwndParent, &rcClient);
cyVScroll = GetSystemMetrics(SM_CYVSCROLL);
hwndPB = CreateWindowEx(0, PROGRESS_CLASS, (LPSTR) NULL,
WS_CHILD | WS_VISIBLE | PBS_SMOOTH,
rcClient.left + cyVScroll, (rcClient.bottom - 2*cyVScroll),
(rcClient.right - 2*cyVScroll), cyVScroll,
hwndParent, NULL, g_hInstance, NULL);
// Set the range and increment of the progress bar.
SendMessage(hwndPB, PBM_SETRANGE, 0, MAKELPARAM(0, 4000));
SendMessage(hwndPB, PBM_SETSTEP, (WPARAM) 1, 0);
for (i = 0; i < 4000; i++)
// one small step of lengthy operation
SendMessage(hwndPB, PBM_STEPIT, 0, 0);
DestroyWindow(hwndPB);
return 0;
}
|
|
|
|
|
Hey All,
Can anyone point me towards a tutorial and/or sample code on sending rtf formatted email. I have to send a small 10 row by 4 column table every morning. Right now I am using Simple MAPI to send it, but it is totally unreadable unless viewed with a fixed width font.
Any help appreciated.
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
It's because you can't directly. Watch out TNEF in MSDN (OpenTnefStream, WrapCompressedRTFStream, ...). It's what is used by Outlook by the way.
|
|
|
|
|
Can't you just send it as an attachment?
Regards,
Rohit Sinha
|
|
|
|
|
Hi, does anybody know (can tell us/point us to source code/docs) how to change keyboard mappings for the whole system. Eg. say we want to have Ctrl-K act as if someone pressed the Down Arrow. Can we intercept keyboard messages for the whole system, and then change them before other applications receive them?
thanks in advance
|
|
|
|
|
I suppose you could write a filter and attach it to the driver stack. That way you could modify the IRP before it reaches the RIT. Take a look at kbfiltr in the DDK. There is also another another similar solution at www.sysinternals.com (ctrl2cap), but kbfiltr seems to give you more freedom to manipulate the entire buffer, like inserting keystrokes.
BTW, I will probably have to write something similar in a couple of weeks, so if you find another way I'd be glad to hear about it...
/moliate
The corners of my eyes catch hasty, bloodless motion -
a mouse?
Well, certainly a peripheral of some kind.
Neil Gaiman - Cold Colours
|
|
|
|
|