dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Dec 9, 1998

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


MessageBox Advantage

You've probably noticed that the display time stops when an application pops up VB's built-in MsgBox. Although the system timer continues to tick, the timer control isn't updated every second, nor do other events (such as painting) process. To update the timer, replace VB's built-in MsgBox with the MessageBox API function. MessageBox-generated dialogs don't stop the timer from updating, and they allow other normal processing, such as form painting:
 
' General Declarations in BAS module
Public Declare Function MessageBox Lib _
	"user32" Alias "MessageBoxA" (ByVal _
	hWnd As Long, ByVal lpText As String, _
	ByVal lpCaption As String, ByVal wType _
	As Long) As Long

' Call from within any form like this:
Call MessageBox(Me.hWnd, _
	"This is a test in API Message Box", _
	"API Message Box", vbInformation)
To use this technique in VB3, declare all parameters in the API call as integer. While calling, pass MB_ICONINFORMATION as the last parameter, instead of vbInformation. You can find the constant value for MB_ICONINFORMATION in the CONSTANT.txt file. Note that many of the intrinsic VB constants used with MsgBox also work with the MessageBox API. Now for the best news about this workaround-it's totally unnecessary under VB5! Timer (and other) events are never blocked by a MsgBox call when run from an EXE. It's important to understand that they'll still be blocked in the IDE, but take a look next time you compile and you'll see your clock just keeps on ticking.
Vasudevan Sampath
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.
Thanks for your registration, follow us on our social networks to keep up-to-date