简体   繁体   English

Win32窗口样式重叠问题

[英]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. 它们位于TabControl框中,当我单击一个选项卡时,我要显示一个/隐藏另一个。 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 这是我第一次运行代码(右侧的ObjectList)时列表框的外观: 列表框正确显示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 这是当我单击选项卡时: 列表框突然变丑了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 如果单击以显示第一个列表框,我也会得到: 第一个列表框也被感染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. 编辑 :经过一些测试,我发现这是因为两个列表框都是mainWindow的子级,而不是tabControl窗口的子级。 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. 如果将两者的parentWindow都设置为tabControl,它们将显示正常,但是我遇到了窗口孙子项和大量子类化的问题,因此我将所有Windows子窗口都作为主窗口的子项。 How can I fix this display issue? 如何解决此显示问题?

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

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

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