For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > January 2006 > Determining if a VB6 form is modal









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Determining if a VB6 form is modal
Dan

2006-01-24, 6:55 pm

I want to loop through the forms collection and determine if any of them are
displayed modally. How can I do this?
Woodie Morris

2006-01-24, 6:55 pm

??? You can't - you won't be able to loop thru the forms if any of them are
currently shown modally because that would prevent any other code in your
app from running, unless the looping code is in the modally displayed form.

-Woodie

"Dan" <Dan@discussions.microsoft.com> wrote in message
news:A09FF894-8D16-413E-B7CC-CCE14F4DD482@microsoft.com...
>I want to loop through the forms collection and determine if any of them
>are
> displayed modally. How can I do this?



Dan

2006-01-24, 6:55 pm

Perhaps I should have made this clearer. The forms are in an activex exe.
An activex exe does not block calls from external threads when it displays a
modal window, thus you can call a function on it like ModalWindowIsDisplayed

Thus far, the best I've come up with is to search for forms with the
WS_DISABLED bit set; if it is set, then the exe is displaying a modal window.
It seems like there ought to be a better way.

"Woodie Morris" wrote:

> ??? You can't - you won't be able to loop thru the forms if any of them are
> currently shown modally because that would prevent any other code in your
> app from running, unless the looping code is in the modally displayed form.
>
> -Woodie
>
> "Dan" <Dan@discussions.microsoft.com> wrote in message
> news:A09FF894-8D16-413E-B7CC-CCE14F4DD482@microsoft.com...
>
>
>

Woodie Morris

2006-01-24, 9:55 pm

That makes sense Dan. Sorry, I don't have an answer for you. Maybe someone
else will chime in.

-Woodie

"Dan" <Dan@discussions.microsoft.com> wrote in message
news:CF00E224-ACDD-4278-97B2-6489F800D7D4@microsoft.com...[color=darkred]
> Perhaps I should have made this clearer. The forms are in an activex exe.
> An activex exe does not block calls from external threads when it displays
> a
> modal window, thus you can call a function on it like
> ModalWindowIsDisplayed
>
> Thus far, the best I've come up with is to search for forms with the
> WS_DISABLED bit set; if it is set, then the exe is displaying a modal
> window.
> It seems like there ought to be a better way.
>
> "Woodie Morris" wrote:
>


Mark Yudkin

2006-01-25, 3:56 am

app.NonModalAllowed

indicates if you are allowed to display a non modal window at the current
time. The answer is False when any modal window is showing and True if none
are showing. Hence "Not app.NonModalAllowed" answers your question.

"Dan" <Dan@discussions.microsoft.com> wrote in message
news:A09FF894-8D16-413E-B7CC-CCE14F4DD482@microsoft.com...
>I want to loop through the forms collection and determine if any of them
>are
> displayed modally. How can I do this?



Dan

2006-01-25, 7:55 am

This property does not appear to work as you have described it. If I display
modal dialogs in an ActiveX Exe (either via "show vbModal" or via MsgBox)
NonModalAllowed remains True.

"Mark Yudkin" wrote:

> app.NonModalAllowed
>
> indicates if you are allowed to display a non modal window at the current
> time. The answer is False when any modal window is showing and True if none
> are showing. Hence "Not app.NonModalAllowed" answers your question.
>
> "Dan" <Dan@discussions.microsoft.com> wrote in message
> news:A09FF894-8D16-413E-B7CC-CCE14F4DD482@microsoft.com...
>
>
>

Robert

2006-01-25, 6:56 pm

Not correct. It seems that way when you run the program from the IDE. When
running the EXE file, a modal form does not, for example, stop timers from
running. Therefore you can have code running while a modal form shows.

Robert

"Woodie Morris" <woodie7@comcast.net> wrote in message
news:O6j7XzTIGHA.3728@tk2msftngp13.phx.gbl...
> ??? You can't - you won't be able to loop thru the forms if any of them

are
> currently shown modally because that would prevent any other code in your
> app from running, unless the looping code is in the modally displayed

form.
>
> -Woodie
>
> "Dan" <Dan@discussions.microsoft.com> wrote in message
> news:A09FF894-8D16-413E-B7CC-CCE14F4DD482@microsoft.com...
>
>



Robert

2006-01-25, 6:56 pm

I've tried several ways to detect whether modal forms are open (although in
your case it sounds even more complicated...)
The only really reliable way I've found is to handle handle it yourself -
increase a counter of open modal forms just prior to the Show vbmodal or
MsgBox, and decrement immediately after.

Hope that helps

Robert

"Dan" <Dan@discussions.microsoft.com> wrote in message
news:14474D67-066F-4484-BBF4-A4B74F0B4C53@microsoft.com...
> This property does not appear to work as you have described it. If I

display[color=darkred]
> modal dialogs in an ActiveX Exe (either via "show vbModal" or via MsgBox)
> NonModalAllowed remains True.
>
> "Mark Yudkin" wrote:
>
current[color=darkred]
none[color=darkred]
them[color=darkred]


Ken Halter

2006-01-25, 6:56 pm

"Dan" <Dan@discussions.microsoft.com> wrote in message
news:A09FF894-8D16-413E-B7CC-CCE14F4DD482@microsoft.com...
>I want to loop through the forms collection and determine if any of them
>are
> displayed modally. How can I do this?


Here's one way...

Keep Form Titlebars in Focus when ToolWindows are Shown
"So to detect a modal form being shown, and to allow the title bar to
update, we can use a static variable to count the number of times the
WM_NCACTIVATE message has been sent between WM_ACTIVATE messages. If this
exceeds 2 we assume a modal form is being displayed and allow the default
processing to occur."
http://www.vbaccelerator.com/home/V...own/article.asp

--
Ken Halter - MS-MVP-VB - Please keep all discussions in the groups..
DLL Hell problems? Try ComGuard - http://www.vbsight.com/ComGuard.htm
Freeware 4 color Gradient Frame? http://www.vbsight.com/GradFrameCTL.htm


David J Mark

2006-01-25, 6:56 pm


"Dan" <Dan@discussions.microsoft.com> wrote in message
news:CF00E224-ACDD-4278-97B2-6489F800D7D4@microsoft.com...
> Perhaps I should have made this clearer. The forms are in an activex exe.
> An activex exe does not block calls from external threads when it displays
> a
> modal window, thus you can call a function on it like
> ModalWindowIsDisplayed
>
> Thus far, the best I've come up with is to search for forms with the
> WS_DISABLED bit set; if it is set, then the exe is displaying a modal
> window.
> It seems like there ought to be a better way.


There is. Keep track of which window you are opening modally in your code.
[color=darkred]
>
> "Woodie Morris" wrote:
>


Mark Yudkin

2006-01-29, 3:55 am

Are you calling app.NonModalAllowed from WITHIN the ActiveX Exe? (It sounds
like you're trying it from the "caller" - which obviously won't work).

"Dan" <Dan@discussions.microsoft.com> wrote in message
news:14474D67-066F-4484-BBF4-A4B74F0B4C53@microsoft.com...[color=darkred]
> This property does not appear to work as you have described it. If I
> display
> modal dialogs in an ActiveX Exe (either via "show vbModal" or via MsgBox)
> NonModalAllowed remains True.
>
> "Mark Yudkin" wrote:
>


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com