|
-
Jul 26th, 2001, 08:37 PM
#1
Thread Starter
Frenzied Member
poor systray icon resolution
Hi,
Please look at my attached C++ and VB programs.
Can anyone explain why the icon looks terrible in C++ and fine in VB?
Can it be because of the way I load the icon? I commented out
other methods I used that didn't seem to work.
thanks
Last edited by wey97; Jul 27th, 2001 at 10:20 AM.
-
Aug 8th, 2001, 07:40 PM
#2
PowerPoster
They both look same for me
-
Aug 10th, 2001, 10:26 AM
#3
Thread Starter
Frenzied Member
Well, the systray has to be 16X16. I have both sizes in my icon
file, but I think ExtractIcon is defaulting to 32X32.
Who has the code for ExtractIconEx?
-
Aug 10th, 2001, 10:35 AM
#4
PowerPoster
Why can't you use NOTIFYTRAYICON structure?
-
Aug 10th, 2001, 03:30 PM
#5
Thread Starter
Frenzied Member
Is this what you mean? if so, this is the code in the project I posted.
You have to have some way to set the icon, even if you use
NOTIFYTRAYICON. I can't get MAKEINTRESOURCE to work.
I only get a blank icon in the system tray.
Code:
#include <windows.h>
// main icon identifier
#define IDI_ICONMAIN 1001
// Main Window Handle
HWND hwndMain;
// for system tray
NOTIFYICONDATA nid;
// The window procedure
LRESULT CALLBACK WindowProcedure(HWND hwnd, UINT message, WPARAM wParam,
LPARAM lParam){
switch(message)
{
case WM_DESTROY:
{
Shell_NotifyIcon(NIM_DELETE, &nid);
DestroyWindow(hwndMain);
PostQuitMessage(0);
break;
}
default:
{
return DefWindowProc(hwnd, message, wParam, lParam);
break;
}
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpszArgument, int nCmdShow){
MSG messages;
WNDCLASSEX wincl;
wincl.hInstance = hInstance;
wincl.lpszClassName = "systray";
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof(WNDCLASSEX);
wincl.hIcon = ExtractIcon(NULL,"systray.exe",0);
wincl.hIconSm = ExtractIcon(NULL,"systray.exe",0);
wincl.hCursor = LoadCursor(NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH)COLOR_BTNSHADOW;
if(!RegisterClassEx(&wincl)) return 0;
hwndMain = CreateWindowEx(
0,
"systray",
"systray",
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, //| WS_MAXIMIZEBOX | WS_MINIMIZEBOX,
CW_USEDEFAULT,
CW_USEDEFAULT,
250,
120,
HWND_DESKTOP,
NULL,
hInstance,
NULL
);
nid.cbSize = sizeof(nid);
nid.hIcon = ExtractIcon(NULL,"systray.exe",0);//LoadIcon(NULL,IDI_WINLOGO); LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICONMAIN));
nid.hWnd = hwndMain;
strcpy(nid.szTip, "systray\0");
nid.uCallbackMessage = WM_RBUTTONDOWN;
nid.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;
nid.uID = 2;
Shell_NotifyIcon(NIM_ADD, &nid);
ShowWindow(hwndMain,nCmdShow);
while(GetMessage(&messages, NULL, 0, 0)){
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
-
Oct 8th, 2001, 06:31 PM
#6
Thread Starter
Frenzied Member
Always use this to load a 16X16 icon:
Code:
HICON hIconSm;
hIconSm = (HICON)LoadImage(GetModuleHandle(NULL),
MAKEINTRESOURCE(IDI_ICONMAIN),
IMAGE_ICON, 16, 16, 0);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|