image - Why is my Delphi code not executing in order?
问题描述
I am creating a program, and I need to display an image and then block input for a few seconds before allowing it again. The problem I am running into is that Delphi is not running the code in order and is executing the Sleep()
command before the image command. I have run into this problem before when using Sleep()
with a video before displaying a message.
The code looks as follows:
procedure TtForm.WindowsMediaPlayer2Click(ASender: TObject;
nButton, nShiftState: SmallInt; fX, fY: Integer);
Var
buttonSelected: Integer;
begin
buttonSelected := MessageDlg('Well done Monkey!-_-', mtError, mbOKCancel, 0);
if buttonSelected = mrOK then
begin
Pages.Visible := False;
WindowsMediaPlayer2.Visible := False;
imgEroor.BringToFront;
BorderStyle := bsNone;
WindowState := wsMaximized;
imgEroor.Top := 0;
imgEroor.Left := 0;
imgEroor.Width := Screen.Width;
imgEroor.Height := Screen.Height;
imgEroor.BringToFront;
BlockInput(True);
Sleep(10000);
BlockInput(False);
end;
if buttonSelected = mrCancel then
begin
Pages.Visible := False;
WindowsMediaPlayer2.Visible := False;
imgEroor.BringToFront;
BorderStyle := bsNone;
WindowState := wsMaximized;
imgEroor.Top := 0;
imgEroor.Left := 0;
imgEroor.Width := Screen.Width;
imgEroor.Height := Screen.Height;
imgEroor.BringToFront;
BlockInput(True);
Sleep(10000);
BlockInput(False);
end;
end;
解决方案
推荐阅读
- python - 如何从 npy 数组创建 3d 散点图
- sql - 如何将随机值从一个表插入到另一个表(oracle sql)?
- macros - SAS 宏未运行
- xml - 用完整的命名空间 URI 值替换 XML 命名空间前缀?
- c++ - 仅用一个内环打印图案
- json - 如何在 Stackblitz 项目中加载 JSON?
- python - Pyqt5 Qt Designer 后退按钮问题
- excel - 根据 9 月 1 日至 9 月 30 日的条件,将数据从主数据复制到多个工作表
- angular - 大于 Angular Validator 中的跨字段验证
- sass - Grunt/SASS:将 CSS 输出到单个文件中,并保持源映射真实到多个源文件