Icon Buttons...

This is a discussion on Icon Buttons... within the Windows Programming forums, part of the Platform Specific Boards category; For some reason, this code does not load the icon that it should when the program runs, hope some1 can ...

  1. #1
    Registered User Finchie_88's Avatar
    Join Date
    Aug 2004
    Posts
    154

    Question Icon Buttons...

    For some reason, this code does not load the icon that it should when the program runs, hope some1 can help, thanks in advance...

    Code:
    //Main window set up...
    
    LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
        MSG msg;
        HWND hwd;
        HINSTANCE g_hinst;
        static HBITMAP hbmp;
        static HICON   hIcon;
        static HWND    hIconBtn;
        static HWND    hBmpBtn;
        switch (message)                  /* handle the messages */
        {
                // ICON BUTTON
                hIconBtn = CreateWindowEx(0,
                            TEXT("BUTTON"),
                            TEXT(""),
                            WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
                            220,
                            5,
                            150,
                            65,
                            hwnd,
                            NULL,
                            g_hinst,
                            NULL);
                // INSERT ICON
            hIcon=(HICON)LoadImage(NULL,IDI_EXCLAMATION,IMAGE_ICON,0,0,LR_SHARED);
            SendMessage(hIconBtn,BM_SETIMAGE,IMAGE_ICON,(LPARAM)hIcon);
    }
    Any ideas
    Last edited by Finchie_88; 10-25-2004 at 01:54 PM.


  2. #2
    Registered User Xzyx987X's Avatar
    Join Date
    Sep 2003
    Posts
    107
    Try InvalidateRect() and UpdateWindow() on the control after you set the icon.

  3. #3
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    Try using the BS_ICON style.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Icon Help
    By The Brain in forum Windows Programming
    Replies: 11
    Last Post: 04-05-2009, 05:06 PM
  2. Icon problem
    By mkyong in forum Windows Programming
    Replies: 0
    Last Post: 02-17-2003, 05:39 PM
  3. Icon? help!
    By Unregistered in forum C++ Programming
    Replies: 1
    Last Post: 12-16-2001, 06:21 PM
  4. icon in title bar?
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 12-12-2001, 06:43 PM
  5. Grouping radio buttons
    By Bazz in forum Windows Programming
    Replies: 1
    Last Post: 08-28-2001, 08:15 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21