Solved

Api to hide msgbox after some time

Posted on 2006-11-20
2
1,199 Views
Last Modified: 2013-12-26
Hi, is there a way to hide a msgbox after a time?Maybe there's a windows api that does it that.



0
Comment
Question by:edwbear1976a
2 Comments
 
LVL 17

Accepted Solution

by:
vb_elmar earned 250 total points
ID: 17980789
Needs: 1 Timer and 1 Button
===================

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private 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
Private Const WM_SETTEXT = &HC
Private Const WM_GETTEXT = &HD
Private Const WM_CLOSE = &H10
Private Const MB_ABORTRETRYIGNORE = &H2&
Private Const MB_APPLMODAL = &H0&
Private Const MB_COMPOSITE = &H2
Private Const MB_DEFAULT_DESKTOP_ONLY = &H20000
Private Const MB_OKCANCEL = &H1&
Private Const MB_PRECOMPOSED = &H1
Private Const MB_RETRYCANCEL = &H5&
Private Const MB_DEFBUTTON1 = &H0&
Private Const MB_DEFBUTTON2 = &H100&
Private Const MB_DEFBUTTON3 = &H200&
Private Const MB_DEFMASK = &HF00&
Private Const MB_ICONASTERISK = &H40&
Private Const MB_ICONEXCLAMATION = &H30&
Private Const MB_ICONHAND = &H10&
Private Const MB_ICONMASK = &HF0&
Private Const MB_ICONQUESTION = &H20&
Private Const MB_SETFOREGROUND = &H10000
Private Const MB_SYSTEMMODAL = &H1000&
Private Const MB_TASKMODAL = &H2000&
Private Const MB_TYPEMASK = &HF&
Private Const MB_USEGLYPHCHARS = &H4
Private Const MB_YESNO = &H4&
Private Const MB_YESNOCANCEL = &H3&
Private Const MB_MISCMASK = &HC000&
Private Const MB_MODEMASK = &H3000&
Private Const MB_NOFOCUS = &H8000&
Private Const MB_OK = &H0&



Private Sub Command1_Click()
a = 2: Timer1.Interval = a * 1000
Dim strMsg As String
Dim lngReturn As Long
Dim l As Long
Timer1.Enabled = True
l = MessageBox(Me.hwnd, "Wait " & a & " Seconds...", "Title", MB_OK)
End Sub



Private Sub Timer1_Timer()
Dim lnghWnd As Long
If lnghWnd = 0 Then
lnghWnd = FindWindow(vbNullString, "Title")
End If
Call SendMessage(lnghWnd, WM_CLOSE, 0, ByVal 0&)
Timer1.Enabled = False
End Sub

0
 

Author Comment

by:edwbear1976a
ID: 17981793
thanks, it's just what I need
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now