Win32 Window Styles Overlap Issue

708 views Asked by At

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?

1

There are 1 answers

1
Jonathan Potter On

Set the WS_CLIPSIBLINGS style on both listboxes and the tab control, and make sure the z-order is such that the two listboxes are drawn AFTER the tab.