|
-
September 7th, 2004, 09:05 AM
#1
Changing the icon of a window
Hi Gurus
I'trying to make an exe to change the icon of the window of an other application.
Here my code :
#include "stdafx.h"
#include <winbase.h>
#include <windows.h>
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND hWnd;
HICON hIcon;
// AUDROS (5.5) is the title of the window of I want to change the icon
hWnd = FindWindow(NULL, "AUDROS (5.5)");
if (hWnd)
{
hIcon = (HICON)LoadImage(NULL, "ico00001.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
SendMessage(hWnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSmall);
}
return(0);
}
It really change the icon but as soon as the window is activate, the new icon is lost and it's replace with a defaut icon !!!
Any helps
Thanks
Chris
-
September 7th, 2004, 09:18 AM
#2
Re: Changing the icon of a window
It is because your app loaded that icon, and when it quits the handle is no longer valid.
In order to really change the icon, you would need to force the other application to call LoadImage itself. This is complicated, but there is something called thread injection that could be useful to you.
http://www.codeproject.com/threads/winspy.asp
Regards / Z
-
September 7th, 2004, 09:28 AM
#3
Re: Changing the icon of a window
Please don't create identical threads in the future. If you were unsatisfied with your post, you should have used Edit, to change it. Any post can be re-edited by the original poster, or the forum moderators.
-
September 7th, 2004, 09:39 AM
#4
Re: Changing the icon of a window
 Originally Posted by Chris ZANARDI
It really change the icon but as soon as the window is activate, the new icon is lost and it's replace with a defaut icon !!!
what window should be "activate" (active?)? Does the icon restores when target application's window reactivates (seting focus)? Or when your programm closes?
"Programs must be written for people to read, and only incidentally for machines to execute."
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
|