WIN32 desktop program edit icon

The upper left corner of the icon on the desktop icons and toolbars are modified by a member of the window class object inside the function to modify the registration window:


//
//  函数: MyRegisterClass()
//
//  目标: 注册窗口类。
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
    WNDCLASSEXW wcex;

    wcex.cbSize = sizeof(WNDCLASSEX);

    wcex.style          = CS_HREDRAW | CS_VREDRAW;
    wcex.lpfnWndProc    = WndProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
  //  wcex.hIcon          = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINDOWSPROJECT1));//加载系统图标,第一个参数要为null
	//wcex.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(32512));
	//桌面工具栏上的图标
	wcex.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_INFORMATION));
	
	wcex.hCursor        = LoadCursor(nullptr, IDC_ARROW);
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
	wcex.lpszMenuName = NULL;// MAKEINTRESOURCEW(IDC_WINDOWSPROJECT1);
    wcex.lpszClassName  = szWindowClass;
	//wcex.hIconSm = NULL;// LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
	//程序左上角图标
	wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_CYCLE));
    return RegisterClassExW(&wcex);
}

 

2. Desktop icon of exe program modifications:

See a way, is to use the next few icons Icon smallest value in value than the ID IDR_MAINFRAME small value, so I want to change generated exe file icon, to ensure that value is the value of the icon next few icons Icon smallest of the ;

Modify the ID value, mainly in Resource.h , the own resources Value added icon changed to a minimum and a defined position sequence but also on the front, and therefore do not have to delete IDR_MAINFRAME.

Then compile and run, find your debug directory, the implementation of the general will see the .exe file icon has changed.

problem:

   exe file icon after often compiled to run, debug issued under the directory does not change, but will copy the exe file debug directory, put elsewhere, the icon will change, and a back, then changed back to the old icon a. . .

 Then, I put this debug into debug2, is a change of name, I want to become an icon of; then the directory name should we go back to debug, the icon has become old. . . I do not understand. . .

 

Follow found:

  Right exe files, view attributes, issued icon on the Properties window is what you want, and still is the old icon on the exe file:

 

Or: The debug tree somewhere else path, the icon becomes wanted. . .

Published 69 original articles · won praise 10 · views 30000 +

Guess you like

Origin blog.csdn.net/u010096608/article/details/103220867