好像是Delphi5.5的一个bug,问题如下:在主窗口form1上放一个edit1和一个edit2。在edit1的onKeyDown事件下写入如下代码:
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then edit2.SetFocus;
end;在edit1的onExit事件下写入如下代码:
procedure TForm1.Edit1Exit(Sender: TObject);
begin
if strtoint(edit1.text)>4 then
application.MessageBox('输入的数值大于5!','提示',mb_ok);
end;执行这个程序,在edit1中输入数值7,然后按回车键,跳出提示框“输入的数值大于5!”,这时正常情况光标应该在edit2上,可你会发现edit2上没有闪烁的光标,用鼠标点击也不行。但可以输入数值。把application.MessageBox换成showmessage或messagedlg,没有这种情况,但如果在edit1输入数值后不按回车键,而是用鼠标点击edit2时,左右动一动鼠标,你又会发现新问题!!!不知道有没有DELPHI顶尖高手可以解释这个问题,给出解决方法!!!
procedure TForm1.Edit1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=13 then edit2.SetFocus;
end;在edit1的onExit事件下写入如下代码:
procedure TForm1.Edit1Exit(Sender: TObject);
begin
if strtoint(edit1.text)>4 then
application.MessageBox('输入的数值大于5!','提示',mb_ok);
end;执行这个程序,在edit1中输入数值7,然后按回车键,跳出提示框“输入的数值大于5!”,这时正常情况光标应该在edit2上,可你会发现edit2上没有闪烁的光标,用鼠标点击也不行。但可以输入数值。把application.MessageBox换成showmessage或messagedlg,没有这种情况,但如果在edit1输入数值后不按回车键,而是用鼠标点击edit2时,左右动一动鼠标,你又会发现新问题!!!不知道有没有DELPHI顶尖高手可以解释这个问题,给出解决方法!!!
解决方案 »
- 给Webbrowser一网址,如何截屏保存JPG
- Treeview的組件使用問題,請各位大大幫忙解決..
- 请教:两位小数,用什么变量?很奇怪的一个问题,在Dbgrid中,编辑一个数字,比如1.20,无论如何也无法只取两位小数
- 关于离线数据处理..
- Rave 报表问题,各位同行先进援助一下(应为一张帖子乱码已经加到200,踊跃UP)
- 提问????谁有SUIPack For DelphiBCB V3.96的rar压缩包密码
- 如何用delphi写批处理及文件拷贝?
- 帮帮忙,有谁知道哪里有打印 UPC 条形码的的控件?
- 下列这个过程如何调用啊?
- 求救:如何去掉桌面上快捷方式图标的底色?
- 一个以showmodal方式打开的窗体退出时为何为这样?
- 招聘Delphi开发人员。
是你写的不好
procedure TForm1.Edit1Exit(Sender: TObject);
begin
if strtoint(edit1.text)>4 then
begin
application.MessageBox('输入的数值大于5!','提示',mb_ok);
edit2.setfocus;
end;
end;我试过了,调用windows的api函数显示信息,没有上面的问题!
靠,这也不算bug!?那泰森就不咬人耳朵了!!!
虽然Delphi8都出来了!但全都试过以后,还是决定用Delphi5.5。
吕方的《老情歌》中不是唱过:......情歌总是老的好,走遍天涯海角忘不了.....
就算是没念过大学的,也未必不能编制出经典的好软件!不怕不懂,因为可以永远的学下去!
就怕不懂装懂,以为自己会编个“Hello World!",就可以随意批判任何人!
我知道6和7都没有这个问题,以后的8也更不会有,但在5中就是有!而且不是程序编制问题,而是Delphi问题。如果楼上各位非要说是我程序编制有问题,那请问为何用相同的程序6和7没有问题呢!!!最好的矛碰到最好的盾了吧!!!
var
ActiveWindow: HWnd;
WindowList: Pointer;
MBMonitor, AppMonitor: HMonitor;
MonInfo: TMonitorInfo;
Rect: TRect;
begin
ActiveWindow := GetActiveWindow;
MBMonitor := MonitorFromWindow(ActiveWindow, MONITOR_DEFAULTTONEAREST);
AppMonitor := MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST);
if MBMonitor <> AppMonitor then
begin
MonInfo.cbSize := Sizeof(TMonitorInfo);
GetMonitorInfo(MBMonitor, @MonInfo);
GetWindowRect(Handle, Rect);
SetWindowPos(Handle, 0,
MonInfo.rcMonitor.Left + ((MonInfo.rcMonitor.Right - MonInfo.rcMonitor.Left) div 2),
MonInfo.rcMonitor.Top + ((MonInfo.rcMonitor.Bottom - MonInfo.rcMonitor.Top) div 2),
0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
end;
WindowList := DisableTaskWindows(0);
if UseRightToLeftReading then Flags := Flags or MB_RTLREADING;
try
Result := Windows.MessageBox(Handle, Text, Caption, Flags);
finally
if MBMonitor <> AppMonitor then
SetWindowPos(Handle, 0,
Rect.Left + ((Rect.Right - Rect.Left) div 2),
Rect.Top + ((Rect.Bottom - Rect.Top) div 2),
0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
EnableTaskWindows(WindowList);
SetActiveWindow(ActiveWindow);
end;
end;D7 中
function TApplication.MessageBox(const Text, Caption: PChar; Flags: Longint): Integer;
var
ActiveWindow: HWnd;
WindowList: Pointer;
MBMonitor, AppMonitor: HMonitor;
MonInfo: TMonitorInfo;
Rect: TRect;
FocusState: TFocusState;
begin
ActiveWindow := GetActiveWindow;
MBMonitor := MonitorFromWindow(ActiveWindow, MONITOR_DEFAULTTONEAREST);
AppMonitor := MonitorFromWindow(Handle, MONITOR_DEFAULTTONEAREST);
if MBMonitor <> AppMonitor then
begin
MonInfo.cbSize := Sizeof(TMonitorInfo);
GetMonitorInfo(MBMonitor, @MonInfo);
GetWindowRect(Handle, Rect);
SetWindowPos(Handle, 0,
MonInfo.rcMonitor.Left + ((MonInfo.rcMonitor.Right - MonInfo.rcMonitor.Left) div 2),
MonInfo.rcMonitor.Top + ((MonInfo.rcMonitor.Bottom - MonInfo.rcMonitor.Top) div 2),
0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
end;
WindowList := DisableTaskWindows(0);
FocusState := SaveFocusState;
if UseRightToLeftReading then Flags := Flags or MB_RTLREADING;
try
Result := Windows.MessageBox(Handle, Text, Caption, Flags);
finally
if MBMonitor <> AppMonitor then
SetWindowPos(Handle, 0,
Rect.Left + ((Rect.Right - Rect.Left) div 2),
Rect.Top + ((Rect.Bottom - Rect.Top) div 2),
0, 0, SWP_NOACTIVATE or SWP_NOREDRAW or SWP_NOSIZE or SWP_NOZORDER);
EnableTaskWindows(WindowList);
SetActiveWindow(ActiveWindow);
RestoreFocusState(FocusState);
end;
end;不知道大家注意了没有,看最后一行D7中多了 RestoreFocusState(FocusState);将焦点恢复了回来!!!的确D5中存在这个问题!!!
不象别的人,说什么对Delhpi5不感兴趣……、说什么系统的错或是我编制的程序问题……
更有甚者,以为自己多穿几条内裤,就有多了不起!我已经改了我编制的程序,用其它方式实现上述功能,避免了上面出现的问题,但我只是想知道为什么会有这个错误?
如果有谁告诉我一件事这样做是错的,那样做才对,我不会简单的照着他说的去做,我会弄清楚原因是什么!我知道应该不断的向前发展,所以现在的人多也在不断的去追求新的东西。
可我只是个山里的孩子,家里穷,买不起昂贵的Delphi6或更高的7和8,所以我一直在使用曾祖父留下的Delphi5,
因为幼儿园没能毕业,所以我只能靠仅仅会的汉语拼音试着编程,为了养家户口,我只能在出外放猪的时候编编小程序,
用来帮像中国×信这样的小公司管管用户通话计费。可因为我没学过数学,不懂为什么一分钟有57秒,所以不久就丢了这份工作。
现在只能帮家×福这样的小卖店编卖货程序……
日子就这样淡淡的过着…………
不用钱的,呵呵