小弟写了如下代码:
if Application.MessageBox(pchar(mess), 'Question', MB_ICONQUESTION + MB_YESNO) = IDYES then
begin
enemystart(userdata);
result := true;
end
else
result := false;
end;有时弹出提示框后就找不到了,把主窗口拖到一边后发现这个提示框在主窗口后面呢,
请问如何可以让这个弹出的提示框在主窗口的前面显示??
if Application.MessageBox(pchar(mess), 'Question', MB_ICONQUESTION + MB_YESNO) = IDYES then
begin
enemystart(userdata);
result := true;
end
else
result := false;
end;有时弹出提示框后就找不到了,把主窗口拖到一边后发现这个提示框在主窗口后面呢,
请问如何可以让这个弹出的提示框在主窗口的前面显示??
单元:Dialogsor QDialogs
例子:showmessage('hello');
2.function MessageBox(const Text, Caption: PChar; Flags: Longint = MB_OK): Integer;
单元:Forms
例子:MessageBox('This should be on top.', 'Look', mb_OK)
注:delphi的帮助文档提供的例子好像有误他的最后一个参数是[sbmok]
3.function MessageDlg(const Msg: string; DlgType: TMsgDlgType; Buttons: TMsgDlgButtons; HelpCtx: Longint): Word;
单元:Dialogsor QDialogs
例子:if messagedlg('确定要退出吗?',mtwarnint,[mbyes,mbno],0)=mryes then close;
4.int MessageBox( HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
);
单元:windows API
例子:windows.messagebox(0,'标题','警告错误',MB_ICONSTOP);
windows.MessageBox(Handle, ........);
//主窗体句柄
application.messagebox('aa','aa',mb_ok+mb_iconinformation);
和
messagebox(0,'aa','aa',mb_ok+mb_iconinformation);
是一个意思。
主窗体的formstyle设为了fsStayOnTop 这样当然显不出来了
在执行这句时刚好转到另一个程序的界面是极易出现,只有用alt+tab切换到Delphi程序才能将将对话框重后面显到前面来。