Where is my Taskbar Icon?

Started by
6 comments, last by chippydip 24 years, 1 month ago
I posted this question to the DirectX/OpenGL/etc. board by mistake so I'm gonna remost it here... Hey, This isn't a real big deal, but it would be nice if I could get an icon to show up on my program's taskbar button. I've been able to get the Application's icon to work, but the taskbar one still eludes me Here's my window intialization:


// =============================================================================
//  Function:   InitApp
//  Purpose:    This sets the fields of a WNDCLASSEX object and then uses it
//              to register a new windows class. Finally, it creates a new
//              fullscreen window and returns a handle to this window.
// =============================================================================

HWND InitApp (HINSTANCE instance)           // Application instance handle
{
    // Local variables

    WNDCLASSEX winClass;

    // Fill in the WNDCLASSEX object with some default values

    winClass.cbSize         = sizeof(WNDCLASSEX);
                                            // Set the size just to be safe
    winClass.style          = CS_DBLCLKS / CS_OWNDC / CS_HREDRAW / CS_VREDRAW;
                                            // Use a standard game style
    winClass.lpfnWndProc    = WinProc;      // Our message handling function
    winClass.cbClsExtra	    = 0;            // Extra class info space (not used)
    winClass.cbWndExtra	    = 0;            // Window info space (not used)
    winClass.hInstance      = instance;     // Application instance handle
    winClass.hIcon          = LoadIcon(NULL, MAKEINTRESOURCE(IDI_BIGICON));
                                            // Large icon to be used by windows
    winClass.hCursor        = LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW));
                                            // Cursor to be used by windows
    winClass.hbrBackground  = (HBRUSH) GetStockObject(BLACK_BRUSH);
                                            // Brush used to clear the screen
    winClass.lpszMenuName   = NULL;         // No menus used
    winClass.lpszClassName  = WIN_CLASS_NAME;
                                            // Name of the new window class
    winClass.hIconSm        = LoadIcon(NULL, MAKEINTRESOURCE(IDI_SMALLICON));
                                            // Small icon to be used by windows

    // Register the window class

    if (!RegisterClassEx(&winClass))
        exit(10);

    // Create a new window

    return CreateWindowEx(NULL,             // Advanced...
                          WIN_CLASS_NAME,   // Name used to register winClass
                          WIN_TITLE,        // Name used in window title bar
                          WS_POPUP / WS_VISIBLE,
                                            // A basic, full screen style
                          0, 0,             // Window postion
                          GetSystemMetrics(SM_CXFULLSCREEN),
                                            // Set window width to the width of the desktop
                          GetSystemMetrics(SM_CYFULLSCREEN),
                                            // Set window height to the height of the desktop
                          NULL,             // Handle to parent window
                          NULL,             // Handle to window's menu
                          instance,         // Application instance
                          NULL);            // Advanced...
}


Which is supposed to load a different icon for the large and small icons (just so I can see what's going on.) Both icons are 32x32 (MSVC++ didn't seem to want to let me make a 16x16 small ICON ... This might be the problem, but I don't know.) Any help would be greatly appreciated Edited by - chippydip on 3/20/00 12:52:09 AM Edited by - chippydip on 3/20/00 1:00:14 AM
Advertisement
Try creating the window with WS_SYSMENU
ooh, thanks... I have an Icon now (not the one I was trying to load, but its a start...) Now I have the information icon that you would see in a dialog box (the one that looks like a question mark...)

Any other ideas? I''ll play around with the ID''s and see if I can work anything out...

Also, any idea why MSVC++ won''t let me make 16x16 icons for the small icon (and should I try and use that size for a small icon?)
Well, after playing around with the resource ID''s for a couple minutes, I''ve found that I can get a variety of system icons (I''ve gotten the info one, the exclamation pt., and the windows one) but none of my own I''m using the resource ID''s defined in my .rc file and calling LoadIcon() and MAKEINTRESOURCE() as shown above in my code... the same calls that are working for the app''s icon (although, now that I think about it... the actual call in the program shouldn''t affect how the application looks in windows should it?)

I''m new to this whole resource thing and any help would be appreciated
interesting....Im working on the same kind of application at this moment, loading an icon into the tasktray, and am also having trouble with making the program load MY icons.... and not the triangle with the exclamation point...the value returned by LoadIcon isnt the correct type and MAKEINTRESOURCE does give me the right type, but apparently not for the right icon....
Damn windows! Why can''t it just do what its told!?!

No luck so far... if I figure anything out I''ll let you know... and if anyone else has had (and preferable solved) this problem, please chime in with your 2 cents. I just hate it when the code LOOKS like it should work perfectly, but doesn''t for some dumb reason... Please tell me why I''m dumb hehe

Its not my fault! Honestly, Windows did it! hehe
That''s funny.. I could use my own icons fine.

I do something like this

winclass.hIcon = (HICON)LoadImage(h_inst, hicon,IMAGE_ICON,
0,0, LR_DEFAULTCOLOR); // icon

wheere hicon is the name of image resource, h_inst is instance
Stupid me! I figured out what was wrong with my code... When I switched from using the standard resources to me own Icons and Cursors, I neglected to change the NULL in LoadIcon() and LoadCursor() to my application''s instance handle! After fixing that, it works fine

This topic is closed to new replies.

Advertisement