In Visual Studio, I created a simple old Win32 application and shared all resources and generated code so that my application consisted of this:
#include "stdafx.h" #include "IcoTest.h" int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { ::MessageBox( NULL, L"Testing", L"Test", MB_OK ); }
When I run the application, this is what I see:
screenshot http://i43.tinypic.com/a0c68m.png
So the question is, can I change the default application icon on the taskbar? If so, what code do you need to add for this?
Edit:
That's what I did, and such work, but it is not perfect. The new icon displays well, but the taskbar preview window in Vista does not work, and the system menu does not work, so I just leave it alone.
HWND CreateDummyWindow(HINSTANCE hInstance, int iconId, LPCTSTR taskbarTitle) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = DefWindowProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(iconId)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = 0; wcex.lpszMenuName = 0; wcex.lpszClassName = taskbarTitle, wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(iconId)); ATOM atom = RegisterClassEx(&wcex); HWND wnd = ::CreateWindow( wcex.lpszClassName, taskbarTitle, WS_ICONIC | WS_DISABLED, -1000, -1000, 1, 1, NULL, NULL, hInstance, NULL); return wnd; } int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { HWND wnd = CreateDummyWindow(hInstance, IDI_ICON1, _T("Test") ); ::MessageBox( wnd, _T("Testing"), _T("Test"), MB_OK ); ::DestroyWindow( wnd ); }