简体   繁体   English

C ++ Windows API-如何使用ListView的默认WIndows Proc?

[英]C++ Windows API - how to use a ListView's default WIndows Proc?

Okay, I have a ListView and I've just worked out how to manually set it's Callback procedure: 好的,我有一个ListView,并且我已经弄清楚了如何手动设置它的Callback过程:

// Sets the list view procedure
listproc = (D_ListView *) LocalAlloc(LMEM_FIXED, sizeof(D_ListView));
               listproc->oldproc = (WNDPROC)SetWindowLongPtr(g_hList, GWL_WNDPROC, (LONG)&ListViewProc);
               SetWindowLongPtr(g_hList, GWL_USERDATA, (LONG)&listproc);

I used a code example I found - D_ListView is just a struct with a WNDPROC variable called oldproc . 我使用的代码示例,我发现- D_ListView只是一个struct具有WNDPROC称为变oldproc

Anyhow, I'm sending messages to my ListView to add items. 无论如何,我正在向我的ListView发送消息以添加项目。 But I don't want to handle the ADD messages manually, I want to pass them onto the ListView's default procedure, and only handle messages that I need to over-ride the functionality for. 但是我不想手动处理ADD消息,我希望将它们传递到ListView的默认过程中,而仅处理需要覆盖其功能的消息。

LRESULT CALLBACK ListViewProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
        // Just a test - we're getting this message so it worked
        case LVM_INSERTCOLUMN:
        {
            cout << "CREATED" << endl;

        }    
    }
    WNDPROC* wp;
    wp = (WNDPROC*)(::GetWindowLongPtr(hwnd, GWL_WNDPROC));
    return ::CallWindowProc(*wp, hwnd, msg, wParam, lParam);   
}

In the above, I don't want to deal withe LVM_INSERTCOLUMN: I just want to pass it on. 在上面,我不想处理LVM_INSERTCOLUMN:我只想将其传递。

Any one able to help? 有人能帮忙吗?

Thanks, Rob 谢谢,罗伯

使用getWindowLongPtr (...GWL_USERDATA)获取指向D_ListView实例的指针,然后将所有不需要的消息转发到oldproc

::CallWindowProc(*listproc->oldproc, hwnd, msg, wParam, lParam);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM