我想通过知道窗口句柄来找出窗口的顶级组件名称。
这在托管 C++ 代码中是这样完成的:
//handle is the window handle as int
System::Windows::Forms::Control^ c = Control::FromHandle((System::IntPtr)System::Convert::ToInt32(handle));
System::Type^ t= c->GetType();
Console::WriteLine(t->FullName);//This is the top level name of the component.
但是,我不能将托管代码用于我必须开发的解决方案。
我曾尝试将其GetClassName()
用作等效项,但这只是给了我WindowsForms10.STATIC. [...]
莫名其妙的东西 :)
有谁知道如何在非托管代码中完成此操作?
我知道 C++ 本身并不提供对 WinForms 的任何支持,但我希望以正确的方式获得指针。我已经看到它在一些解决方案中完成,但无法让我的代码工作:(
提前谢谢你。