Results 1 to 6 of 6

Thread: poor systray icon resolution

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276

    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.

  2. #2
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    They both look same for me
    Baaaaaaaaah

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    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?

  4. #4
    PowerPoster abdul's Avatar
    Join Date
    Dec 2000
    Location
    Ontario,Canada
    Posts
    2,827
    Why can't you use NOTIFYTRAYICON structure?
    Baaaaaaaaah

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    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;
    }

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    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
  •  



Click Here to Expand Forum to Full Width