为 WinAPI 创建面向对象的包装器
这是一个有点抽象的问题,所以我将提供必要的用例以使这个问题更加具体。如果为了清楚起见需要发布代码,只需说出这个词,我一定会这样做。为了清楚起见,我也会写一些例子。
问题
我想知道是否可以用 C++ 为 win32 API 创建包装器?这尤其适用于简单的游戏引擎。发布的示例仅仅是示例,本身并不完全是我直接询问它们的问题,而是将它们用作理解主要问题的扩展。不过,如果有人也想回答这些问题,那将会很有帮助。
示例一
我有一个简单的 WndProc
函数,它是我的 App::Game
类的一部分,我希望能够将其分配给WNDCLASSEX
,但是,由于它有一个命名空间并且是类的一部分,我担心没有办法做到这一点。起初我想到了重载,然后我意识到 wc.lpfnWndProc 是结构的一部分,因此不可重载。
示例二
通过创建 main 函数并让它调用 WinMain
,将 WinMain
隐藏在普通 C/C++ main
函数下面代码>.
This is a bit of an abstract question, so I'll provide the necessary use cases to make this a little more concrete. If code needs to be posted for clarity, just say the word and I'll be sure to do so. I'll write examples for clarity as well.
Question
What I'd like to know is whether or not it's possible to create wrappers in C++ for the win32 API? This would be for a simple game engine in particular. The examples posted are merely examples, and not quite questions themselves in the sense that I'm asking them directly, but rather using them as extensions for understanding the main question. Although if anyone wishes to answer these as well, it would be helpful.
Example One
I have a simple WndProc
function which is part of my App::Game
class which I would like to be able to assign to a WNDCLASSEX
, yet, because of the fact that it has a namespace and is part of a class, I fear there is no way to do this. At first I thought of overloading, then I realized that the wc.lpfnWndProc
is part of a struct, and therefore un-overloadable.
Example Two
Hiding the WinMain
underneath the normal C/C++ main
function, by creating the main function and having it call WinMain
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试 http://vaca.sourceforge.net/
Try http://vaca.sourceforge.net/