Home All Groups Group Topic Archive Search About

MsgBox and a pop up form

Author
13 Aug 2010 12:54 PM
phil hunt
I have an application that pop up a form (vbModal) asking for password in
order to proceed. It pops up after a period of idling. It works prettty
well.
The hassle comes when there is a MsgBox popping up and the user does not
respond, then the modal form pop up. Now I got 2 modal things, and you
cannot click anything to move on. I have been sidestepping the problem by
disabling the modal form whenever I show msgbox. I am wondering if there is
a better way to do this.

Author
13 Aug 2010 1:48 PM
Nobody
"phil hunt" <a@abc.com> wrote in message
news:i43f9i$k9b$1@speranza.aioe.org...
>I have an application that pop up a form (vbModal) asking for password in
>order to proceed. It pops up after a period of idling. It works prettty
>well.
> The hassle comes when there is a MsgBox popping up and the user does not
> respond, then the modal form pop up. Now I got 2 modal things, and you
> cannot click anything to move on. I have been sidestepping the problem by
> disabling the modal form whenever I show msgbox. I am wondering if there
> is a better way to do this.

Do you have any minimized windows, even hidden background ones? Try calling
this routine before showing the password form and MsgBox:

Public Declare Sub OutputDebugString Lib "kernel32" Alias _
    "OutputDebugStringA" (ByVal lpOutputString As String)

Public Sub PrintAllMinimizedForms()
    Dim frm As Form

    For Each frm In Forms
        If frm.WindowState = vbMinimized Then
            DebugPrint "PrintAllMinimizedForms: " & frm.Name
        End If
    Next

End Sub

Public Sub DebugPrint(ByRef s As String)
    Debug.Print s
    OutputDebugString s & vbCrLf
End Sub

Use the following software to view the output when running in the EXE:

DebugView:
http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx

One similar problem I had is when showing a prompt, it would be out of
focus. It turned out that I had a background form that is hidden and
minimized. The form was minimized to save memory. Just by making it
minimized, my app Mem Usage in Task Manager stays at 4 MB, instead of 10 MB,
even when the form is hidden in both cases. The Form was used as a Winsock
host. If I don't minimize it, then the problem disappears. Eventually I had
to use ForceForegroundWindow() function, but I don't like this solution as
MS would probably block it some day:

http://vb.mvps.org/samples/ForceFore/

If you had no luck, can you post code that duplicates the problem?
Author
13 Aug 2010 1:53 PM
phil hunt
The codes are intertwined, that's why I am asking if anyone had other
option.
Just wondering if there is way to show a "free-flowing " msgbox.


Show quoteHide quote
"Nobody" <nob***@nobody.com> wrote in message
news:i43ift$ttu$1@speranza.aioe.org...
> "phil hunt" <a@abc.com> wrote in message
> news:i43f9i$k9b$1@speranza.aioe.org...
>>I have an application that pop up a form (vbModal) asking for password in
>>order to proceed. It pops up after a period of idling. It works prettty
>>well.
>> The hassle comes when there is a MsgBox popping up and the user does not
>> respond, then the modal form pop up. Now I got 2 modal things, and you
>> cannot click anything to move on. I have been sidestepping the problem by
>> disabling the modal form whenever I show msgbox. I am wondering if there
>> is a better way to do this.
>
> Do you have any minimized windows, even hidden background ones? Try
> calling this routine before showing the password form and MsgBox:
>
> Public Declare Sub OutputDebugString Lib "kernel32" Alias _
>    "OutputDebugStringA" (ByVal lpOutputString As String)
>
> Public Sub PrintAllMinimizedForms()
>    Dim frm As Form
>
>    For Each frm In Forms
>        If frm.WindowState = vbMinimized Then
>            DebugPrint "PrintAllMinimizedForms: " & frm.Name
>        End If
>    Next
>
> End Sub
>
> Public Sub DebugPrint(ByRef s As String)
>    Debug.Print s
>    OutputDebugString s & vbCrLf
> End Sub
>
> Use the following software to view the output when running in the EXE:
>
> DebugView:
> http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
>
> One similar problem I had is when showing a prompt, it would be out of
> focus. It turned out that I had a background form that is hidden and
> minimized. The form was minimized to save memory. Just by making it
> minimized, my app Mem Usage in Task Manager stays at 4 MB, instead of 10
> MB, even when the form is hidden in both cases. The Form was used as a
> Winsock host. If I don't minimize it, then the problem disappears.
> Eventually I had to use ForceForegroundWindow() function, but I don't like
> this solution as MS would probably block it some day:
>
> http://vb.mvps.org/samples/ForceFore/
>
> If you had no luck, can you post code that duplicates the problem?
>
>
Author
13 Aug 2010 5:56 PM
Kevin Provance
"phil hunt" <a@abc.com> wrote in message
news:i43ioa$uo9$1@speranza.aioe.org...
: The codes are intertwined, that's why I am asking if anyone had other
: option.
: Just wondering if there is way to show a "free-flowing " msgbox.

Roll your own and call it like this:

frmMsgbox.Show

Do While frmMsgbox.Visible
    DoEvents
Loop

Unload frmMsgbox
Author
13 Aug 2010 2:23 PM
ralph
On Fri, 13 Aug 2010 08:54:14 -0400, "phil hunt" <a@abc.com> wrote:

>I have an application that pop up a form (vbModal) asking for password in
>order to proceed. It pops up after a period of idling. It works prettty
>well.
>The hassle comes when there is a MsgBox popping up and the user does not
>respond, then the modal form pop up. Now I got 2 modal things, and you
>cannot click anything to move on. I have been sidestepping the problem by
>disabling the modal form whenever I show msgbox. I am wondering if there is
>a better way to do this.
>

You might replace your MessageBox with a custom Form that
automatically closes.
http://www.freevbcode.com/ShowCode.asp?ID=8597

Not sure where or why these other messages are coming up, but you
might also simply redirect them to the popup password Form and display
them there.

-ralph
Author
13 Aug 2010 7:52 PM
Larry Serflaten
"phil hunt" <a@abc.com> wrote
> I have an application that pop up a form (vbModal) asking for password in
> order to proceed. It pops up after a period of idling. It works prettty
> well.
> The hassle comes when there is a MsgBox popping up and the user does not
> respond, then the modal form pop up. Now I got 2 modal things, and you
> cannot click anything to move on. I have been sidestepping the problem by
> disabling the modal form whenever I show msgbox. I am wondering if there is
> a better way to do this.

How are you detecting idle time?  If that is on a Timer, why not just disable the
timer before you show the msgbox?  You might wrap that up in a routine so as
to catch it every time:

Sub SimplePrompt(Msg As String, Optional Buttons As VbMsgBoxStyle = vbOKOnly)
  Timer1.Enabled = False
  If frmPassword.Visible Then
    Unload frmPassword
    MsgBox Msg, Buttons
    frmPassword.Show vbModal
  Else
    MsgBos Msg, Buttons
  End If
  Timer1.Enabled = True
End Sub


LFS
Author
13 Aug 2010 8:33 PM
Phil Hunt
That's what I am doing now. Over and over again. Ralph's link is pretty
good, b/c it is a closer approixmation than other "Timed message box".
Wouldn't it be nice if I can show a msgbox NON-Modal.


Show quoteHide quote
"Larry Serflaten" <serfla***@gmail.com> wrote in message
news:i447oj$p52$1@news.eternal-september.org...
>
> "phil hunt" <a@abc.com> wrote
>> I have an application that pop up a form (vbModal) asking for password in
>> order to proceed. It pops up after a period of idling. It works prettty
>> well.
>> The hassle comes when there is a MsgBox popping up and the user does not
>> respond, then the modal form pop up. Now I got 2 modal things, and you
>> cannot click anything to move on. I have been sidestepping the problem by
>> disabling the modal form whenever I show msgbox. I am wondering if there
>> is
>> a better way to do this.
>
> How are you detecting idle time?  If that is on a Timer, why not just
> disable the
> timer before you show the msgbox?  You might wrap that up in a routine so
> as
> to catch it every time:
>
> Sub SimplePrompt(Msg As String, Optional Buttons As VbMsgBoxStyle =
> vbOKOnly)
>  Timer1.Enabled = False
>  If frmPassword.Visible Then
>    Unload frmPassword
>    MsgBox Msg, Buttons
>    frmPassword.Show vbModal
>  Else
>    MsgBos Msg, Buttons
>  End If
>  Timer1.Enabled = True
> End Sub
>
>
> LFS
>
>