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!
要求Style=csDropDown 时注意看清问题描述望各位控件高手踊跃参加
ComboBox1.DroppedDown := True;
就OK了
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!
FS的代码已经很清楚了,在点到Edit框中时,没有inherited,所以不能响应click,当然如果写在onenter,在setfocus以后点击也会无效。你可以
1 继承tcombobox自己写,重载窗口过程
2 在上面用一个panel或者edit等用“障眼法”
3 在容器form等中判断鼠标位置Message.XPos,Message.YPos或者GetMessagePos
---
抛砖引玉,献丑之言。
是大富翁上的一高手给指点的。现公布给大家,分享
继承TcomboBox,覆盖 ComboWndProc(message:Tmessage);
在其中处理WM_LBUTTONDOWN 即可问题结束
以上每人5分....