现在 DialogBox上有两个Combobox
分别为 Combobox1, Combobox2
Combobox1有 选项 1, 2, 3
我想让Combobox2 根据Combobox1的变化而变化
比如
Combobox1    Combobox2
1            A, B, C
2            D, E
3            F, G, H要怎么处理
是不是Combobox1在变化后会给主窗口发送什么消息呢?
MSDN上说 是WM_DRAWITEM 但是我测试 没有发送 环境
VC6 非MFC

解决方案 »

  1.   

    这个应该和自绘没什么关系了,你只要改变Combo的Items就可以了,具体方法是什么,自己找找吧。
      

  2.   

    响应CBN_SELCHANGE消息CBN_SELCHANGESee Also
    Combo Boxes Messages | SendMessage | CBN_DBLCLK | CB_SETCURSEL | WM_COMMANDRequirements
    OS Versions: Windows CE 1.0 and later.
    Header: Winuser.h.
    This message is sent when the selection in the list box of a combo box is about to be changed as a result of the user either clicking in the list box or changing the selection by using the arrow keys. The parent window of the combo box receives this message through the WM_COMMAND message. CBN_SELCHANGE idComboBox = (int)LOWORD(wParam); 
      hwndComboBox = (HWND) lParam;--------------------------------case WM_COMMAND:
      switch(LOWORD(wParam))
      {
       case CBN_SELCHANGE:
       if(hwndComboBox1 == (HWND)lParam)
       {
        int nIndex = SendMessage(hwndComboBox1, CB_GETCURSEL, (WPARAM)0, (LPARAM0);
        ::PostMessage(hwndComboBox2, CB_SETCURSEL, (WPARAM)nIndex , (LPARAM)0);
       }
       break;
       default:
       break;
      }
      break;
      

  3.   

    不是CBN_SELCHANGE消息吧,记得这个是Combobox编辑框的内容改变触发的。
    选择项触发的好象应该是CBN_SELENDOK消息
      

  4.   

    确实是 CBN_SELENDOK 消息
    可能和我的Combibox是 DropDownList
    有关 谢谢各位的答复了