-
Feb 9th, 2018, 04:12 PM
#1
Thread Starter
Addicted Member
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 !
-
Feb 9th, 2018, 05:07 PM
#2
Re: msgBox to front
Originally Posted by Kars Lensen
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.
-
Feb 9th, 2018, 05:13 PM
#3
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. To all, peace and happiness.
-
Feb 9th, 2018, 05:18 PM
#4
Thread Starter
Addicted Member
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 05:22 PM.
-
Feb 9th, 2018, 05:23 PM
#5
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 05: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. To all, peace and happiness.
-
Feb 9th, 2018, 05:30 PM
#6
Re: msgBox to front
Originally Posted by Kars Lensen
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).
-
Feb 9th, 2018, 05:33 PM
#7
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 05: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. To all, peace and happiness.
-
Feb 9th, 2018, 05:33 PM
#8
Thread Starter
Addicted Member
Re: msgBox to front
Thanks to all, I'l give it try (tomorrow) !
-
Feb 9th, 2018, 05:37 PM
#9
Re: msgBox to front
Originally Posted by Elroy
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.
-
Feb 9th, 2018, 05:40 PM
#10
Thread Starter
Addicted Member
Re: msgBox to front
Eduard, it works fantastic, thanks a lot!
-
Feb 9th, 2018, 05:43 PM
#11
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. To all, peace and happiness.
-
Feb 9th, 2018, 06:46 PM
#12
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|