如何让TComboBox在Style=csDropDown时,单击Text区域也弹出下拉列表框?
由于其Text区域内好象没有Click事件,也缺少相应消息,不知如何处理
我对此研究了好久,找不到答案,望有经验的高手指点

解决方案 »

  1.   

    当然会的了,设置成csSimple就好了
      

  2.   

    to:ljmanage 
       要求Style=csDropDown 时注意看清问题描述望各位控件高手踊跃参加
      

  3.   

    ComboBox1.Perform(CB_SHOWDROPDOWN,Integer(True),0)
      

  4.   

    在ComboBox1的OnEnter中
    ComboBox1.DroppedDown := True;
    就OK了
      

  5.   

    我看了半天,没有方法,但看出点眉目,不知道对这个问题有没有帮助:TComboBox的直接父类TCustomComboBox里面的Private部分有个WMLButtonDown消息处理过程,我想应该只要能直接修改这个过程就可以了,但不知道如何去修改!?
      

  6.   

    procedure TCustomComboBox.WMLButtonDown(var Message: TWMLButtonDown);
    var
      Form: TCustomForm;
    begin
      if (DragMode = dmAutomatic) and (Style = csDropDownList) and
          (Message.XPos < (Width - GetSystemMetrics(SM_CXHSCROLL))) then
      begin
        SetFocus;
        BeginDrag(False);
        Exit;
      end;
      inherited;
      if MouseCapture then
      begin
        Form := GetParentForm(Self);
        if (Form <> nil) and (Form.ActiveControl <> Self) then
          MouseCapture := False;
      end;
    end;这个就是我说的那个消息处理过程,但这个过程的可见性是Private!
      

  7.   

    觉得你没必要这样做,既然你Style=csDropDown,单击Text区域就是进入编辑状态,你既要让它进入编辑状态,又要弹出下拉框,有这个必要吗?
      

  8.   

    同意 baguli(巴古里)、 trainbox(smdbs) 两位老大。
      

  9.   

    Noway directly.
    FS的代码已经很清楚了,在点到Edit框中时,没有inherited,所以不能响应click,当然如果写在onenter,在setfocus以后点击也会无效。你可以
    1 继承tcombobox自己写,重载窗口过程
    2 在上面用一个panel或者edit等用“障眼法”
    3 在容器form等中判断鼠标位置Message.XPos,Message.YPos或者GetMessagePos
    ---
    抛砖引玉,献丑之言。
      

  10.   

    谢谢各位参与,该问题已有答案
    是大富翁上的一高手给指点的。现公布给大家,分享
     
     继承TcomboBox,覆盖 ComboWndProc(message:Tmessage);  
    在其中处理WM_LBUTTONDOWN 即可问题结束
    以上每人5分....