我需要将一段代码从 C++ 转换为 VB6。
具体来说,这个:
reinterpret_cast<WPARAM>(reinterpret_cast<LPCREATESTRUCT>(lParam)->hwndParent)
Run Code Online (Sandbox Code Playgroud)
谁能告诉我这在 VB6 中会是什么样子?我在 C++ 方面的经验不够,无法理解它到底是做什么的。
非常感谢!
关于这个问题的背景:
如果在 Visual Basic 6 中使用控件,则它似乎不具有完整的 Unicode 支持。为什么?Visual Basic 6 创建的窗体是 ANSI 窗口。因此,它们强制控件的底层本机树视图窗口类在与窗体通信时使用 ANSI 消息。这在某些情况下会破坏 Unicode 支持。要解决此问题,必须将 WM_NOTIFYFORMAT 消息反射回控件。在 Visual Basic 中,必须对控件的容器窗口进行子类化,并将 WM_NOTIFYFORMAT 发送回其发送的窗口。在 C++ 中,消息反射的工作原理类似。
LRESULT ExplorerTreeView::OnCreate(UINT message, WPARAM wParam, LPARAM lParam, BOOL& /*wasHandled*/)
{
LRESULT lr = DefWindowProc(message, wParam, lParam);
if(*this) {
// this will keep the object alive if the client destroys the control window in an event handler
AddRef();
/* SysTreeView32 already sent a WM_NOTIFYFORMAT/NF_QUERY message to the parent window, but
unfortunately our reflection object did not yet know where to reflect this message to. So we ask
SysTreeView32 to send the message again. */
SendMessage(WM_NOTIFYFORMAT, reinterpret_cast<WPARAM>(reinterpret_cast<LPCREATESTRUCT>(lParam)->hwndParent), NF_REQUERY);
Raise_RecreatedControlWindow(HandleToLong(static_cast<HWND>(*this)));
}
return lr;
}
Run Code Online (Sandbox Code Playgroud)