我需要将一段C++代码转换为VB6。
具体来说,就是这段代码:
reinterpret_cast<WPARAM>(reinterpret_cast<LPCREATESTRUCT>(lParam)->hwndParent)
有人能告诉我这在VB6中是什么样子吗? 我不太熟悉C++,无法理解这个代码的确切含义。
非常感谢!
关于这个问题的背景:
如果在Visual Basic 6中使用控件,则似乎没有完全支持Unicode。为什么?Visual Basic 6创建的窗体是ANSI窗口,因此当与窗体通信时,它们强制控件的基础本地treeview窗口类使用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;
}
A()= "MyCustomString"
(其中A()
定义为byte
将给你一个包含Unicode字符的字节数组)。窗体需要使用CreateWindowsW
创建,所以唯一的方法是创建自己的窗体(或API称之为窗口),并仅使用字节数组作为字符串。 - LundtCreateWindowA
创建窗口,所以所有发送给控件的字符串消息将由Windows(而不是VB6)从Unicode转换为ANSI。 - Lundt