1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Donation with Paypal!!!

    Go to your paypal account and send directly donation to [email protected]

    1 month - 10 $ - Standart VIP

    6 months - 20 $- Standart VIP

    1 year - 30 $- Standart VIP

    2 years - 50 $- Standart VIP

    Gold member for life - 150 $- Standart VIP

    High Vip (Standart VIP include) group please send PM or email to [email protected] for info

    After Donation please send email to [email protected]

  3. Donation Ways 2020


    Paysend
  4. Telegram
Dismiss Notice

Donation with Paypal!!!

Go to your paypal account and send directly donation to [email protected]

1 month - 10 $ - Standart VIP

6 months - 20 $- Standart VIP

1 year - 30 $- Standart VIP

2 years - 50 $- Standart VIP

Gold member for life - 150 $- Standart VIP

High Vip (Standart VIP include) group please send PM or email to [email protected] for info

After Donation please send email to [email protected]

Dismiss Notice
For open hidden message no need write thanks, thank etc. Enough is click to like button on right side of thread.

MessageDLG disappear to background

Discussion in 'Delphi Programming' started by aikona, Mar 6, 2014.

  1. aikona
    Offline

    aikona DF Member

    My software usualy runs minimized and is called ( maximized) to the foreground by another application.

    In my software there is a timer that brings up a messageDLG .Most times this message appears in front of all the other aplications but it sometimes happens that this message is hidden behind all the windows.

    Problem 1 : the timed warning is not seen and thus ignored.
    Problem 2 : When my software is then maximized this messageDLG is still in the background and it looks like my software is frozen.

    How can I get this message back to the foreground ... or cancel old message and create new one.

    Eric
     
  2. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    RE:

    maybe this code help to you :

    Code:
     unit Unit1;
     
     interface
     
     uses
       Windows, Messages, SysUtils, Variants, Classes,
       Graphics, Controls, Forms, Dialogs, ExtCtrls;
     
     type
       TForm1 = class(TForm)
       private
         procedure WMTimeChange(var Msg: TMessage) ; message WM_TIMECHANGE;
       public
         { Public declarations }
       end;
     
     var
       Form1: TForm1;
     
     implementation
     {$R *.dfm}
     
     procedure TForm1.WMTimeChange(var Msg: TMessage) ;
     begin
       Windows.MessageBox(
         handle,
         'This is a system modal message'#13#10'from an inactive application',
         'A message from an inactive application!',
         MB_SYSTEMMODAL or MB_SETFOREGROUND or MB_TOPMOST or MB_ICONHAND) ;
     end;
     
     end.

    Run the example and minimize it

    After this goto time and date and try change date or time on your windows;

    Good day
     
  3. aikona
    Offline

    aikona DF Member

    Ok , your code works ,now I just have to figure out how to include it in a timerevent

    This is more or less what I would like to do
    Ontime event

    If Something  = somethingElse then
     if  Messagedlg( 'Do you want to carry on 'mtWarning,[mbOK, mbCancel],0,mbCancel) = mrOk) then
     Begin // Do carry on stuff
     End
     Else // reset timer and display message again


    Thanks

    Eric
     
  4. AdminDF
    Online

    AdminDFAdminDF is a Verified Member Delphifan Staff Member DF Staff

    RE:

    i have this code sample 

    Code:
    ===Example test code=========================
    uses
      Unit2;
    
    
    procedure TForm1.Button1Click(Sender: TObject);
    var
      iRet: Integer;
      iFlags: Integer;
    begin
    // example 1
       iFlags := MB_OK or MB_SETFOREGROUND or MB_SYSTEMMODAL or 
    MB_ICONINFORMATION;
       MessageBoxTimeout(Application.Handle, 'Test a timeout of 2 seconds.', 
    'MessageBoxTimeout Test', iFlags, 0, 2000) ;
    
    
    // example 2
       iFlags := MB_YESNO or MB_SETFOREGROUND or MB_SYSTEMMODAL or 
    MB_ICONINFORMATION;
       iRet := MessageBoxTimeout(Application.Handle, 'Test a timeout of 5 
    seconds.', 'MessageBoxTimeout Test', iFlags, 0, 5000) ;
       case iRet of
         IDYES:
           ShowMessage('Yes') ;
         IDNO:
           ShowMessage('No') ;
         MB_TIMEDOUT:
           ShowMessage('TimedOut') ;
       end;
    end;
    ============================
    [font=Monaco, Consolas, Courier, monospace]iFlags you can set for this [/font][font=Monaco, Consolas, Courier, monospace]MB_SYSTEMMODAL or MB_SETFOREGROUND or MB_TOPMOST or MB_ICONHAND[/font]
    [font=Monaco, Consolas, Courier, monospace]In this example message after some second close automaticly.[/font]
     
  5. aikona
    Offline

    aikona DF Member

    Thanks

    I'll play around with this code .

    If the user does not take action after say 10 minutes then software will close message and just carry on as if the user said Ok


    Eric
     
  6. falcon2000
    Online

    falcon2000 Guest

    Let i test this !
     

Share This Page