Results 1 to 16 of 16

Thread: Change Start Button Image using code?

  1. #1

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238

    Change Start Button Image using code?

    Does anyone know how to change the start button image through some API call?

    I manage to get the Start Button handle, but fail to change the image... enclose is the sample code

    PHP Code:
        HWND    hWnd=NULL;
        
    HBITMAP    hBitmap=NULL;
        
    long    x=0;

        
    hWnd FindWindow("Shell_TrayWnd",NULL);
        if (
    hWnd != NULL)
        {
            
    hWnd FindWindowEx(hWndNULL"Button"NULL);
            if (
    hWnd != NULL)
            {
                
    hBitmap static_cast<HBITMAP>(LoadImage(hInst, (LPCTSTR)IDB_MYBUTTONIMAGE_BITMAP00LR_DEFAULTSIZE));
                
    SendMessage(hWndBM_SETIMAGEIMAGE_BITMAP, (LPARAM)hBitmap);        
            }
        } 
    regaards,

  2. #2
    Zaei
    Guest
    Just BitBlt the image on top of the start button in a loop =P.

    Z.

  3. #3

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    yap, Bitbit will do... but it can retain the image after the button repaint

  4. #4
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Subclass the start button and put the BitBlt code in the WM_PAINT message. You will need a dll for this.

    As an alternative you can do this with a timer but it is not proffesional.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  5. #5

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Does anybody know y the BM_SETIMAGE is not working

  6. #6
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Where do you get your image from. Are you using LoadImage API or not. What is the code?
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  7. #7

    Re: Change Start Button Image using code?

    Originally posted by Chris
    Does anyone know how to change the start button image through some API call?
    The image for the Start button is in some DLL, I think user32.dll. So if you modify the icon in there and restart the pooter, the icon will change too.

  8. #8

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    Vlatko, yes I load the bitmal with LoadImage API from the resource
    PHP Code:
    hBitmap static_cast<HBITMAP>(LoadImage(hInst, (LPCTSTR)IDB_MYBUTTONIMAGE_BITMAP00LR_DEFAULTSIZE)); 
    I enclose is the source that I have workout and it can remove the "Start" wording from the start button. The only thing is I fail to update a new image into it.

    With the same method, I manage to transfer the image into the runtime create button in the same program.

    Hope you can give me some hints

    filburt1, I know that can be done by modifiy the user.sys file but juz wanna to find out a way to do it without modified this file. Hope you get my point

    regards,
    Attached Files Attached Files

  9. #9
    amac
    Guest
    Subclass the start button and put the BitBlt code in the WM_PAINT message. You will need a dll for this.
    Why? I know you need to, but I dont know exactly why.

  10. #10
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Why you need a dll.

    Well subclassing is in fact changing the windows procedure of a specified windows. Like in VB you make your own procedure and tell your window to use it for certain events (messages). Well because the WndProc is in your app (your app's memory area) the window ca access it. But when you subclass another window (like the start button), that window belongs to some other process and because in Windoes apps can't access other apps' memory space the start button can not access the WndProc in your exe. That is why you have to put it in a dll beacuse every app can access the functions in the DLL.

    That is a rough explanation but easy to understand.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  11. #11

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    em.... sound like interesting. I'll look more detail abt subclassing in MSDN. By the way, Vlatko, can i have some sample code on subclassing?

    regards,

  12. #12
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Here is an example i made on subclassing other windows using a DLL. This sample app subclasses the Start button. When a user left clicks on the start button a message box will appear instead of the start menu. It can easily be changed to handle messages of every window in your own way.

    Just open the dll workspace file with VC++ not the exe one.
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  13. #13
    amac
    Guest
    I understand what subclassing is... but I didnt understand why a DLL was needed... if you wanna give a more complicated explanation I am sure I will manage to understand. : )

    Can you send messages to another window without having it a DLL?

  14. #14
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    Well, of course you can send messages without a dll. Just use the send message API function.

    The DLL is needed for the other app to be able to "see" the WndProc "made" by you.

    For example in the default WndProc of the desktop window there is something like this.

    WM_RBUTTONDOWN
    {
    //popup menu code
    }

    This is the default behaviour of the desktop window. Its WndProc is in Explorer.exe (i think). It is its exe so it can read everything in its process.

    Now let's say you want to change the behaviour of the dekstop window when it recieves the WM_RBUTTONDOWN message. You make your WndProc and using SetWindowLong that you want the desktop window to see your WndProc (to react to messages in your way)

    My WndProc

    WM_RBUTTONDOWN
    {
    //pop up message box
    }

    In order for the desktop window to read the WndProc it must be in a DLL (where all functions can be accessed by all programs). If the WndProc is not in a dll but it is in your exe (process) then it can not be accessed by the desktop window 'cos it can not access your apps memory space.

    I hope this helps!
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

  15. #15

    Thread Starter
    PowerPoster Chris's Avatar
    Join Date
    Jan 1999
    Location
    K-PAX
    Posts
    3,238
    I can't see any attachment

    Originally posted by Vlatko
    Here is an example i made on subclassing other windows using a DLL. This sample app subclasses the Start button. When a user left clicks on the start button a message box will appear instead of the start menu. It can easily be changed to handle messages of every window in your own way.

    Just open the dll workspace file with VC++ not the exe one.

  16. #16
    Frenzied Member Vlatko's Avatar
    Join Date
    Aug 2000
    Location
    Skopje, Macedonia
    Posts
    1,409
    What an idiot i am. LOL Here is the sample code. Sorry
    Attached Files Attached Files
    I am become death, the destroyer of worlds.
    mail:[email protected]

    • Visual Basic 6.0 & .NET
    • Visual C++ 6.0 & .NET
    • ASP
    • LISP
    • PROLOG
    • C
    • Pascal

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