DUILIB modification program exe icons and taskbar icon

1. Modify the exe icon

     1.1 Adds a icon in the resource file icon, and then recompile, exe icon This program will add the icons come in;

     1.2 If not, you need to use the message; use LoadIcon loading icon, returns a handle to the icon, and then after the window is created, use :: SendMessage to send a message to duilib STM_SETICON window to update the icon;

#include<tchar.h>
#include "CDuiFramWnd.h"
#include "CDuiFramWnd_impl.h"
#include "menu.h"
#include"resource.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
	_In_opt_ HINSTANCE hPrevInstance,
	_In_ LPWSTR    lpCmdLine,
	_In_ int       nCmdShow)
{
	CPaintManagerUI::SetInstance(hInstance);
	CPaintManagerUI::SetResourcePath(CPaintManagerUI::GetInstancePath());//设置资源路径为exe同一路径
	HRESULT hr = ::CoInitialize(NULL);
	if ((FAILED(hr))) return 0;
	//CDuiFramWnd duiFrame;
	
	CDuiFramWnd_impl duiFrame;
	duiFrame.Create(NULL, _T("DUIWnd"), UI_WNDSTYLE_FRAME, WS_EX_WINDOWEDGE);
    //修改exe图标
	HICON hIcon = ::LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
	::SendMessage(duiFrame.GetHWND(), STM_SETICON, IMAGE_ICON, (LPARAM)(UINT)hIcon);

	duiFrame.CenterWindow();
	duiFrame.ShowModal();
	::CoUninitialize();
	//::MessageBox(NULL, _T("hello world"), NULL, NULL);
	return 0;
}

 

2. Modify the taskbar icon

  Use SetIcon function or functions InitWindow duilib OnCreate function of the main window is set;

 

SetIcon(IDI_ICON1);

 

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

Guess you like

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