windows 更改c++应用程序的应用程序窗口图标

您所在的位置:网站首页 如何更换小米默认浏览器 windows 更改c++应用程序的应用程序窗口图标

windows 更改c++应用程序的应用程序窗口图标

#windows 更改c++应用程序的应用程序窗口图标 | 来源: 网络整理| 查看: 265

所以我在为C++图形应用程序窗口设置默认图标时遇到了问题。我正在学习DirectX 11系列教程(找到here)任务栏图标更改得非常好,生成的可执行文件使用自定义图标,但由于某种原因,应用程序窗口没有。根据Microsoft文档中找到的here,我应该在WNDCLASSEX中设置两个HICON属性的值:hIcon和hIconSm;根据研究,其可以设置为LoadIcon(hInstance, IDI_APPLICATION),如本例中所示LoadIcon我不完全确定会采取什么步骤来重现这个问题。我不知道当我在.ico映像中加载.rc文件时是否出了问题。或者我加载的映像不正确,或者...嗯...一些模糊的原因导致它只能工作一半。这是我注册用来创建窗口的窗口类的代码

// The window class. This has to be filled BEFORE the window can be WNDCLASSEX wc; / Flags [Redraw on width/height change from resize/movement] wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Pointer to the window processing function for handling messages from this window wc.lpfnWndProc = HandleMessageSetup; // Number of extra bytes to allocate following the window-class structure wc.cbClsExtra = 0; // Number of extra bytes to allocate following the window instance wc.cbWndExtra = 0; // Handle to the instance that contains the window procedure wc.hInstance = m_hInstance; // Handle to the class icon. Must be a handle to an Icon resource wc.hIcon = LoadIcon(m_hInstance, IDI_APPLICATION); // Handle to the small icon for the class wc.hIconSm = LoadIcon(m_hInstance, IDI_APPLICATION); // Handle to the class cursor. If null, an application must explicitly set the cursor shape whenever the mouse moves into the application window wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Handle to the class background brush for the window's background colour. When NULL an application must paint its own background colour wc.hbrBackground = NULL; // Pointer to a null-terminated string for the menu wc.lpszMenuName = NULL; // Pointer to null-terminated string of our class name wc.lpszClassName = m_windowClass.c_str(); wc.cbSize = sizeof(WNDCLASSEX); // Register the class to make it usable RegisterClassEx(&wc);

如果需要更多代码,可以在github上找到我的存储库(主要类是engine/RenderWindow)根据研究,使用CreateWindowEx创建窗口应该很简单。我的任务栏图标会改变,但应用程序窗口图标不会改变。Screenshot没有错误。代码编译并运行成功。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3