c++ - ShowWindow 替代方案

标签 c++ window terminate showwindow

显然我不能终止一个给定的进程,当它的主窗口被隐藏时(“最小化到托盘”)。所以我尝试在其他进程的 FormClosing 处理程序中再次显示该窗口。也没用。

现在我想使用 ShowWindow

IntPtr Handle = Gateway->MainWindowHandle;
ShowWindow((HWND)Handle.ToPointer(), SW_SHOWDEFAULT);

不幸的是产生了

error LNK2028: Nicht aufgelöstes Token (0A000072) ""extern "C" int __stdcall ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z)", auf das in Funktion ""private: void __clrcall lidarctrl::Form1::Form1_FormClosing(class System::Object ^,class System::Windows::Forms::FormClosingEventArgs ^)" (?Form1_FormClosing@Form1@lidarctrl@@$$FA$AAMXP$AAVObject@System@@P$AAVFormClosingEventArgs@Forms@Windows@4@@Z)" verwiesen wird.
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""extern "C" int __stdcall ShowWindow(struct HWND__ *,int)" (?ShowWindow@@$$J18YGHPAUHWND__@@H@Z)" in Funktion ""private: void __clrcall lidarctrl::Form1::Form1_FormClosing(class System::Object ^,class System::Windows::Forms::FormClosingEventArgs ^)" (?Form1_FormClosing@Form1@lidarctrl@@$$FA$AAMXP$AAVObject@System@@P$AAVFormClosingEventArgs@Forms@Windows@4@@Z)".

抱歉 - 德语错误;不知道如何更改编译器的语言环境。

Non resolved Token...in function...referenced by...

在函数中引用未解析的外部符号...

我感谢任何有关要包含哪个 header 、要加载的库的提示。

我正在使用 Microsoft Visual C++ 2010 Express;该项目是一个普通的 Windows 窗体应用程序。

谢谢!

最佳答案

在从标准 Windows 窗体应用程序模板创建的项目中,没有链接通常包含在 native 项目中的标准/默认库。您需要在项目设置或代码中明确添加它们。你在哪里包括<windows.h> , 添加 #pragma如下图:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

#pragma comment(lib, "user32.lib") // <<--- Add Me

这将链接您丢失的 ShowWindow .

关于c++ - ShowWindow 替代方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12913669/

相关文章:

c# - 事件后线程未完成

iphone - 在退出iOS应用之前显示消息?

c++ - 像 `float[10][10]` 这样初始化的数组是否已针对 SIMD/SSE 进行内存对齐?

c++ - 无效* p ...; if (p > 0) .... 这是未定义的行为吗?

javascript获取网页中选定文本的段落

c - Eclipse C/C++ 在构建时不包含文件

c# - 在 Window 上实现搜索功能的方法

c++ - 初级 C++ : object creation at runtime without knowing how many objects to create

c++ - C++将结构传递给函数以访问嵌套结构

Prolog 子句单独终止,但不一起终止