dcsimg
Results 1 to 12 of 12

Thread: msgBox to front

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Ruinen, Drente, Netherlands
    Posts
    192

    msgBox to front

    How can I set a msgBox (or the main form) to de front of the screen after an other program is started?
    The form (my program) is in the taskbar, when I click on it is right there where I want it !

  2. #2
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    872

    Re: msgBox to front

    Quote Originally Posted by Kars Lensen View Post
    How can I set a msgBox (or the main form) to de front of the screen after an other program is started?
    The form (my program) is in the taskbar, when I click on it is right there where I want it !
    Since many years ago Windows has taken measures to avoid just that: that a program can steal the focus.
    The reason is because it is very anoying to the user when she/he is working on something on some program, suppose she is pressing keys because she is writing a letter in Word, and when she look at the Screen she finds that she didn't write anything, because there is a popup window there.

    Then, what Windows currently does, is to make the program that is requiring attention to blink in the taskbar.

    Another option is to show a balloon tooltip at the system tray.

    The question is, what other program is started? Why your program is not on focus?

    It is still possible to steal the focus, but it is not so easy and not recomended anyway for the reason stated above.

  3. #3
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,196

    Re: msgBox to front

    There is a vbSystemModal flag that can be used with the MsgBox. But, as Eduardo says, it's not very polite.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Ruinen, Drente, Netherlands
    Posts
    192

    Re: msgBox to front

    I understand your answers. The program chooses a printer (to pdf) and then shows the file, then the question is whether the user wants to email the file, but the question is then invisible.

    I don't now how to use the vbSystemModal flag; I am a hobby programmer and still VB6
    Last edited by Kars Lensen; Feb 9th, 2018 at 04:22 PM.

  5. #5
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,196

    Re: msgBox to front

    The vbSystemModal is just added to (or OR'd) with your other MsgBox flags, like vbYesNo, vbInformation, vbOkCancel, etc.

    Code:
    
    Option Explicit
    
    Private Sub Form_Load()
        MsgBox "This is a message", vbInformation + vbOKOnly + vbSystemModal
    End Sub
    
    
    EDIT1: Just to be complete, here's the MSDN on it.
    Last edited by Elroy; Feb 9th, 2018 at 04:27 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  6. #6
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    872

    Re: msgBox to front

    Quote Originally Posted by Kars Lensen View Post
    I understand your answers. The program chooses a printer (to pdf) and then shows the file, then the question is whether the user wants to email the file, but the question is then invisible.

    I don't now how to use the vbSystemModal flag; I am a hobby programmer and still VB6
    Code:
        If MsgBox("Do you want to email the file?", vbYesNo Or vbSystemModal) = vbYes Then
            ' email the file
        End If
    I'm surprised, in XP that works (steals the focus).

  7. #7
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,196

    Re: msgBox to front

    I'm on Win10-64 and it works here too.

    EDIT1: I've never done it but I feel certain I could do this to any form with the correct SendMessage call.
    EDIT2: I suppose it's actually not that different from using the HWND_TOPMOST flag with SetWindowPos.
    Last edited by Elroy; Feb 9th, 2018 at 04:38 PM.
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Ruinen, Drente, Netherlands
    Posts
    192

    Re: msgBox to front

    Thanks to all, I'l give it try (tomorrow) !

  9. #9
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    872

    Re: msgBox to front

    Quote Originally Posted by Elroy View Post
    I'm on Win10-64 and it works here too.

    EDIT1: I've never done it but I feel certain I could do this to any form with the correct SendMessage call.
    What I remember is that SetForeGroundWindow doesn't work anymore as in old times it used to do.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Apr 1999
    Location
    Ruinen, Drente, Netherlands
    Posts
    192

    Re: msgBox to front

    Eduard, it works fantastic, thanks a lot!

  11. #11
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    4,196

    Re: msgBox to front

    @Eduardo:
    Any software I post in these forums written by me is provided “AS IS” without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. Please understand that I’ve been programming since the mid-1970s and still have some of that code. My contemporary VB6 project is approaching 1,000 modules. In addition, I have a “VB6 random code folder” that is overflowing. I’ve been at this long enough to truly not know with absolute certainty from whence every single line of my code has come, with much of it coming from programmers under my employ who signed intellectual property transfers. I have not deliberately attempted to remove any licenses and/or attributions from any software. If someone finds that I have inadvertently done so, I sincerely apologize, and, upon notice and reasonable proof, will re-attach those licenses and/or attributions. To all, peace and happiness.

  12. #12
    Fanatic Member
    Join Date
    Feb 2017
    Posts
    872

    Re: msgBox to front

    Quote Originally Posted by Elroy View Post
    @Eduardo:
    Stealing the focus... and I stealing the credits

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.