Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2008 > Visual Basic 2008 Professionals
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
Visual Basic 2008 Professionals For advanced Visual Basic coders working in version 2008. Beginning-level questions will be redirected to other forums,
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2008 Professionals section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 17th, 2009, 07:40 PM
Authorized User
 
Join Date: Jul 2007
Location: Denver, CO, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default MsgBox not Modal?

Hi all,

I'm not sure if anyone has encountered this, but I have, and it baffled me. In the past, MsgBox() function should always display a modal message box, right?

Well, I'm using a timer in my VB 2008 code, and there is one part in the timer.Tick() event that's suposed to generate a message box. I always thought that the system would then pause and wait for users' reponse, but low and behold, the time starts up again, and it went back to the beginning of the timer.Tick() code section, thus generating mutiple instances of the message, and end up in an infinite loop.

I looked in VB Help and also searched online too, and came up with nothing. All descriptions about MsgBox() function say that it's supposed to be modal.

If you have seen this, and know how to get around this problem, I would really appreciate your help on this. The alternative to this, that I could think of is to create my own message box, and each time that it is shown, then make sure the form is displayed as system modal. I would like to avoid this if there is a better and more elegant solution to this problem.

Thank you very much for all your help.
__________________
Khoi Nguyen
Reply With Quote
  #2 (permalink)  
Old February 17th, 2009, 09:13 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

Hi there...

Well.. In vb5 (don't remember about 6) msgbox where bugged and you could just dispatch one from a user control, and continue working with the application like the msgbox never appeared.
More than a bug, I think this is a problem that comes to where the msgbox is modal from. Since you are just calling it from a different "thread" (in vb5, not a real one, but a control proccesing one), maybe the msgbox is modal to that thing and not your entire application.

A quickly way to solve it in your case, comes with two solution:

1) use a variable at form level, boolean, set it to false at the beginning of the form. In the timer event do something like this:
Code:
private sub timer_event(...) 
if variable = false then
variable = true do your thing... variable = false
endif


2) just disable the timer when you enter and re enable after the messagebox.

Anyway, I think that message box are system calls, so maybe windows is buggy (HEY if somebody ask I never say that!)
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
  #3 (permalink)  
Old February 17th, 2009, 10:05 PM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

I just remember.. That happens at run time or design time?? the weird thing in vb5 happens only at design time. In run time, the msgbox just go modal like any other.
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
  #4 (permalink)  
Old February 18th, 2009, 11:55 AM
Authorized User
 
Join Date: Jul 2007
Location: Denver, CO, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks for the comments. This happens at run time in VB 2008.

Unfortunately, I had to do what you had mentioned in Method #2, and it works ok. It is just annoying to have to do that everytime there is a timer involved though. But I guess that I have no choice, since it is buggy.

Thanks again for your help.
__________________
Khoi Nguyen
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Msgbox rwalker ASP.NET 1.x and 2.0 Application Design 28 March 20th, 2008 01:23 PM
Msgbox Help darrenb Access VBA 2 June 8th, 2007 12:53 AM
MsgBox prabodh_mishra Pro VB 6 1 December 29th, 2006 11:51 AM
msgbox Ramakrishna.G General .NET 3 September 14th, 2004 02:17 AM
msgbox bph Access VBA 2 February 6th, 2004 03:00 PM



All times are GMT -4. The time now is 01:05 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.