简体   繁体   中英

Win32 Window Styles Overlap Issue

I have two listboxes windows created by:

_objectList = CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | LBS_STANDARD | LBS_SORT, 5, 50, 10, 50, _windowParent, NULL, _windowInstance, 0);
_resourceList = CreateWindow("LISTBOX", NULL, WS_CHILD | WS_VISIBLE | LBS_STANDARD | LBS_SORT, 5, 50, 10, 50, _windowParent, NULL, _windowInstance, 0);

ShowWindow(_objectList, 1);
ShowWindow(_resourceList, 0);

They're positioned inside a TabControl box, and when I click a tab, I want to show one/hide the other. I'm doing this with:

//In the message proc function
if(uMsg == WM_NOTIFY)
{
    if(((LPNMHDR)lParam)->code == TCN_SELCHANGE)
    {
        if(((LPNMHDR)lParam)->hwndFrom == _tabControl.GetWindowHandle())
        {
            int index = SendMessage(_tabControl.GetWindowHandle(), TCM_GETCURSEL, 0, 0);
            _tabControl.showTab(index); //this function will call the ShowWindow(); to show only the tab I'd like to display
        }
    }
}

This is how the listbox looks when I first run the code (the ObjectList to the right): Listbox Properly Showing http://img.photobucket.com/albums/v204/Shakazahn/ListboxOK_zpsee5c62b9.jpg

This is when I click the tab: Listbox Got Ugly All of a Sudden http://img.photobucket.com/albums/v204/Shakazahn/ListboxNotOK_zps5d05a019.jpg

And if I click to show the first Listbox, I also get: First Listbox Got Infected as Well http://img.photobucket.com/albums/v204/Shakazahn/ListboxNotOK2_zpsc1dca19a.jpg

I tried changing some of the window Styles but nothing worked, also, I don't have a clue why this is happening... any fixes for this?

edit : After some tests, I found out that this is happening because both Listboxes are children of the mainWindow, not the tabControl window. If I set the parentWindow of both to the tabControl, they display fine, but I was having issues with window grandchildren and lots of subclassing, so I'm making all windows children of my main window. How can I fix this display issue?

在两个列表框和选项卡控件上设置WS_CLIPSIBLINGS样式,并确保z顺序使得两个列表框在选项卡后绘制。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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