tmighty
tmighty

Reputation: 11409

How do I translate reinterpret_cast<WPARAM>(reinterpret_cast<LPCREATESTRUCT>(lParam)->hwndParent) to VB6?

I neeed to convert a piece of code from C++ to VB6.

Specifically, this one:

reinterpret_cast<WPARAM>(reinterpret_cast<LPCREATESTRUCT>(lParam)->hwndParent)

Can somebody tell me what this would look like in VB6? I am not experienced enough in C++ to understand what exactely this does.

Thank you very much!

About the background of this question:

A control doesn't seem to have full Unicode support if it is used in Visual Basic 6. Why? The forms, that Visual Basic 6 is creating, are ANSI windows. Therefore they force the control's underlying native treeview window class to use ANSI messages when communicating with the form. This breaks Unicode support in some situations. To work around this problem, the WM_NOTIFYFORMAT message must be reflected back to the control. In Visual Basic, you must subclass the control's container window and send WM_NOTIFYFORMAT back to the window that it was sent for. In C++, message reflection works similar.

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;
}

Upvotes: 3

Views: 120

Answers (1)

VanGogh Gaming
VanGogh Gaming

Reputation: 466

That's just the handle of the form where the control resides, you can replace that code with Me.hWnd.

Upvotes: 5

Related Questions