I'm trying to create a modal messagebox that will not allow users to move the
focus away from the messagebox without first answering the question. I don't
even want them to be able to click Start. Here is my code:

ans = msgbox("My Message",vbYesNo + vbDefaultButton2 + vbQuestion +
vbApplicationModal + vbSystemModal,"My Title")

What am I missing here?

Re: MODAL MESSAGEBOX by Pegasus

Pegasus
Mon Mar 24 13:13:07 CDT 2008


"Dan" <Dan@discussions.microsoft.com> wrote in message
news:2FC975BF-F1DD-451F-9FDD-F0BD088EA6C1@microsoft.com...
> I'm trying to create a modal messagebox that will not allow users to move
> the
> focus away from the messagebox without first answering the question. I
> don't
> even want them to be able to click Start. Here is my code:
>
> ans = msgbox("My Message",vbYesNo + vbDefaultButton2 + vbQuestion +
> vbApplicationModal + vbSystemModal,"My Title")
>
> What am I missing here?

The modality feature may not be quite what you expect. Have
a look at the link below and look for the word "modal".
http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug07/hey0801.mspx



Re: MODAL MESSAGEBOX by Dan

Dan
Mon Mar 24 13:35:01 CDT 2008

Gotcha, I'm used to MS Access, which is different. So is there a way to
accomplish what I'm trying to do?

"Pegasus (MVP)" wrote:

>
> "Dan" <Dan@discussions.microsoft.com> wrote in message
> news:2FC975BF-F1DD-451F-9FDD-F0BD088EA6C1@microsoft.com...
> > I'm trying to create a modal messagebox that will not allow users to move
> > the
> > focus away from the messagebox without first answering the question. I
> > don't
> > even want them to be able to click Start. Here is my code:
> >
> > ans = msgbox("My Message",vbYesNo + vbDefaultButton2 + vbQuestion +
> > vbApplicationModal + vbSystemModal,"My Title")
> >
> > What am I missing here?
>
> The modality feature may not be quite what you expect. Have
> a look at the link below and look for the word "modal".
> http://www.microsoft.com/technet/scriptcenter/resources/qanda/aug07/hey0801.mspx
>
>
>

Re: MODAL MESSAGEBOX by mayayana

mayayana
Mon Mar 24 14:07:06 CDT 2008


> Gotcha, I'm used to MS Access, which is different. So is there a way to
> accomplish what I'm trying to do?
>

You can't even do that in software unless you hook
into the whole system. At one time system modal
meant that, but MS changed the way it worked
after the function was abused.

When you think about
it, the average person would expect a *very* good
reason for you to do such a thing. About the only
good reason I can think of is, "Mr. President, the missile
is about to launch. Would you like one last chance
to abort?"



Re: MODAL MESSAGEBOX by Dan

Dan
Mon Mar 24 15:08:04 CDT 2008

I can see how this would be abused, I was just hoping there was a workaround.
Thanks.

"mayayana" wrote:

>
> > Gotcha, I'm used to MS Access, which is different. So is there a way to
> > accomplish what I'm trying to do?
> >
>
> You can't even do that in software unless you hook
> into the whole system. At one time system modal
> meant that, but MS changed the way it worked
> after the function was abused.
>
> When you think about
> it, the average person would expect a *very* good
> reason for you to do such a thing. About the only
> good reason I can think of is, "Mr. President, the missile
> is about to launch. Would you like one last chance
> to abort?"
>
>
>

Re: MODAL MESSAGEBOX by mr_unreliable

mr_unreliable
Mon Mar 24 17:48:58 CDT 2008

Dan wrote:
> I'm trying to create a modal messagebox that will not allow users to move the
> focus away from the messagebox without first answering the question.

Dan, as the other folks said, you can't get what you want
with vbScript.

If you are absolutely determined to hold the focus (from script),
you are going to have to write some actX object which will do
system hooking -- and the "CBT Hook" should do it for you.

http://msdn2.microsoft.com/en-us/library/ms644977(VS.85).aspx

After you set the hook, the system will notify you when various
events are about to take place. One of the notifications
is: HCBT_SETFOCUS, meaning another window is about to receive
focus. At that point, you take over and "steal" the focus
back to where you want it. And, you keep stealing it back,
until your user answers your question (then UN-hook).

Maybe somebody else will come along with a better answer,
but afaik, using system hooks is the only way.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but,
no guarantee the answers will be applicable to the questions)