Control’s OnExit eats up mouseup event for new control when showing@H_301_4@ another window
The problem can be replicated easily.
place 3 tedits on a form. write a showmessage(‘exit’) in edit1’s@H_301_4@ onexit event run the program give edit1 focus use the mouse to give@H_301_4@ edit3 focus,click ok to the showmessage observe how you can’t write@H_301_4@ anything in edit3 now,until you click with the mouse somewhere on the@H_301_4@ form ! give edit2 focus,then use to the mouse to give edit3 focus@H_301_4@ observe how you can type what you want in edit3 now !
So far I’ve established that the problem lies in the fact that edit3@H_301_4@ doesn’t receive a mouseup-message when the old controls onExit event@H_301_4@ displays a window of any kind,i’ve tried it as well with showing a@H_301_4@ form of my own in the onExit event,same result. In fact,windows is@H_301_4@ under the impression that the mouse is held down over edit3 after@H_301_4@ you’ve clicked Ok to the showmessage
I guess it’s a bug in Delphi/Windows but how to work around it ? I@H_301_4@ know i can force a WM_LBUTTONUP on edit3’s onMouseDown event (since@H_301_4@ its the last event called in the process) but that’s more than@H_301_4@ tedious,and not always applicable
我正在尝试做类似的事情:
在onexit事件中,我显示一个警告框,然后继续@H_301_4@正常 – 将焦点移动到用户实际点击的位置.@H_301_4@那可能吗?
解决方法
const WM_SHOWMYDIALOG = WM_APP + 321; TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; procedure Edit1Exit(Sender: TObject); private procedure WMSHOWMYDIALOG(var Message: TMessage); message WM_SHOWMYDIALOG; end; procedure TForm1.Edit1Exit(Sender: TObject); begin PostMessage(Self.Handle,WM_SHOWMYDIALOG,0); end; procedure TForm1.WMSHOWMYDIALOG(var Message: TMessage); begin ShowMessage('Nice one'); end;
一切都很好:)