English 中文(简体)
ComboB ox子
原标题:ComboBox Subclassing Listbox

由于一些习俗原因,我试图将名单箱和Edit控制Combo箱子上下级。 下面是法典工作。 为Edit控制提供分级服务的工作是完美的,但清单箱没有达到MouseDown的幼.。

void Subclass(HWND hComboBox)
{
    HWND hEdit=FindWindowEx(hComboBox, NULL, WC_EDIT, NULL);
    HWND hCombo=FindWindowEx(hComboBox, NULL, WC_LISTBOX, NULL);
    SetProp(hEdit, TEXT("Wprc"), (HANDLE)GetWindowLongPtr(hEdit, GWL_WNDPROC));
    SubclassWindow(hEdit, ComboBox_Proc);
    SetProp(hCombo, TEXT("Wprc1"), (HANDLE)GetWindowLongPtr(hCombo, GWL_WNDPROC));
    SubclassWindow(hCombo, ComboBox_Proc1);
}


static LRESULT CALLBACK ComboBox_Proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{

    switch(msg)
    {
        case WM_CHAR:
            break;
        case WM_KEYDOWN:
            break;
        case WM_DESTROY:
            SetWindowLongPtr(hwnd, GWLP_WNDPROC, (DWORD)GetProp(hwnd, TEXT("Wprc")));
            RemoveProp(hwnd, TEXT("Wprc"));
            break;
        default:
            return CallWindowProc((WNDPROC)GetProp(hwnd, TEXT("Wprc")), hwnd, msg, wParam, lParam);
    }
    return FALSE;
}

static LRESULT CALLBACK ComboBox_Proc1(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
    switch(msg)
    {
        case WM_LBUTTONDOWN:
          //PROBLEM IS HERE
            break;
        case WM_DESTROY: 
            SetWindowLongPtr(hwnd, GWLP_WNDPROC, (DWORD)GetProp(hwnd, TEXT("Wprc1")));
            RemoveProp(hwnd, TEXT("Wprc1"));
            break;
        default:
            return CallWindowProc((WNDPROC)GetProp(hwnd, TEXT("Wprc1")), hwnd, msg, wParam, lParam);
    }
    return FALSE;
}
问题回答

ComboBox的一部分是COMBOLBOX( with L)。

The ComboLBox window is not a child of the ComboBox window. The only way I found to subclass the COMBOLBOX control is as follows.

Windows将WM_CTLCOLORLISTBOX电文发送到COMBOBOX(no L),然后提取清单箱。 该电文的灯帕塔载有清单箱的操作。

 case  WM_CTLCOLORLISTBOX:
 {       
    if ( !hSubclassedListBox ) 
    { 
        hSubclassedListBox = (HWND)lParam; 
        SubclassWindow(hSubclassedListBox , MyLBProc);
    }
 }

另见link

对于那些使用WINVER机的视力演播室的人(或后来的Windows XP),你可以使用GetComboBoxInfo功能(绕过ComboBox的操作),该功能(在COMBOBOX结构中)将处理Edit盒和ComboLBox(ListBox)两种。 然后,可以将处理器用于接收其所代表的由妇女委员会衍生的物体。





相关问题
Undefined reference

I m getting this linker error. I know a way around it, but it s bugging me because another part of the project s linking fine and it s designed almost identically. First, I have namespace LCD. Then I ...

C++ Equivalent of Tidy

Is there an equivalent to tidy for HTML code for C++? I have searched on the internet, but I find nothing but C++ wrappers for tidy, etc... I think the keyword tidy is what has me hung up. I am ...

Template Classes in C++ ... a required skill set?

I m new to C++ and am wondering how much time I should invest in learning how to implement template classes. Are they widely used in industry, or is this something I should move through quickly?

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

typedef ing STL wstring

Why is it when i do the following i get errors when relating to with wchar_t? namespace Foo { typedef std::wstring String; } Now i declare all my strings as Foo::String through out the program, ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

Window iconification status via Xlib

Is it possible to check with the means of pure X11/Xlib only whether the given window is iconified/minimized, and, if it is, how?

热门标签